本文整理汇总了Java中ij.process.ShortProcessor类的典型用法代码示例。如果您正苦于以下问题:Java ShortProcessor类的具体用法?Java ShortProcessor怎么用?Java ShortProcessor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ShortProcessor类属于ij.process包,在下文中一共展示了ShortProcessor类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: setUp
import ij.process.ShortProcessor; //导入依赖的package包/类
/**
* Creates a test .tif file as an example background.
*/
@Before
public void setUp () throws IOException {
// Create an array of pixels increasing from 0 to 8.
int nX = 3; int nY = 3; int counter = 0;
int[][] pixels = new int[nY][nX];
for (int y = 0; y < nY; y++) {
for (int x = 0; x < nX; x++) {
pixels[y][x] = counter++;
}
}
// Create an image from the array of pixels
ShortProcessor sp = new ShortProcessor(nX, nY);
sp.setIntArray(pixels);
expResult = sp.getFloatArray();
// Save the example image
String filename = "Example-Background.tif";
backgroundFile = tempDir.newFile(filename);
ImagePlus imp = new ImagePlus("Example-Background", sp);
IJ.save(imp, backgroundFile.getAbsolutePath());
assertTrue(backgroundFile.exists());
}
开发者ID:LEB-EPFL,项目名称:SASS,代码行数:27,代码来源:GenerateBackgroundFromFileTest.java
示例2: convertImageFileToBI
import ij.process.ShortProcessor; //导入依赖的package包/类
/**
* Converts image file into a BufferedImage
*
* @param inputFile
* @return
* @throws IOException
*/
public static BufferedImage convertImageFileToBI(String inputFile) throws IOException {
BufferedImage bi = null;
try {
ImageIO.setUseCache(false);
bi = ImageIO.read(new File(inputFile));
} catch (javax.imageio.IIOException e) // in case tiff format is not recognized, try to resolve exception using ImagePlus (ImageJ) methods
{
if (inputFile.endsWith(".tif") || inputFile.endsWith(".tiff")) {
ImagePlus ip = new ImagePlus(inputFile); // :TODO validate if tiff to be read is truly 16 bit :: otherwise there could be a scaling issue occurring afterwards
bi = ((ShortProcessor) ip.getProcessor().convertToShort(false)).get16BitBufferedImage();
} else {
throw e;
}
}
return bi;
}
开发者ID:mstritt,项目名称:orbit-image-analysis,代码行数:28,代码来源:ImageUtils.java
示例3: labelImage
import ij.process.ShortProcessor; //导入依赖的package包/类
public static ShortProcessor labelImage(ImageProcessor ip, float threshold, boolean conn8) {
int w = ip.getWidth();
int h = ip.getHeight();
short shortMax = (short)65535;
ShortProcessor sp = new ShortProcessor(w, h);
short[] pxShort = (short[])sp.getPixels();
for (int i = 0; i < w*h; i++) {
if (ip.getf(i) > threshold)
pxShort[i] = shortMax;
}
// Loop through and flood fill
FloodFiller ff = new FloodFiller(sp);
double label = 0;
for (int i = 0; i < pxShort.length; i++) {
if (pxShort[i] == shortMax) {
label++;
sp.setValue(label);
if (conn8)
ff.fill8(i % w, i / w);
else
ff.fill(i % w, i / w);
}
}
sp.setMinAndMax(0, label);
return sp;
}
开发者ID:qupath,项目名称:qupath,代码行数:27,代码来源:ROILabeling.java
示例4: run
import ij.process.ShortProcessor; //导入依赖的package包/类
@Override
public void run() {
for(int f = frame_start; f <= frame_end; f++) {
if(Thread.interrupted()) {
local_stack.clear();
local_table.clear();
return;
}
processingNewFrame("ThunderSTORM is generating frame %d out of %d...");
FloatProcessor backgroundMeanIntensity;
backgroundMeanIntensity = createBackgroundIntensityImage();
Vector<EmitterModel> molecules = singleFixedMolecule
? datagen.generateSingleFixedMolecule(width, height, 0, 0, intensity_range, psf)
: datagen.generateMolecules(width, height, densityMask, density, intensity_range, psf);
ShortProcessor slice = datagen.renderFrame(width, height, f, drift, molecules, backgroundMeanIntensity);
local_stack.add(slice);
local_table.add(molecules);
}
}
开发者ID:zitmen,项目名称:thunderstorm,代码行数:20,代码来源:DataGeneratorPlugIn.java
示例5: createNewProcessor
import ij.process.ShortProcessor; //导入依赖的package包/类
private ImageProcessor createNewProcessor(int imageWidth, int imageHeight)
{
// Equalised display requires a 16-bit image to allow fast processing of the histogram
if ((displayFlags & DISPLAY_EQUALIZED) != 0)
{
pixels = new short[data.length];
return new ShortProcessor(imageWidth, imageHeight, (short[]) pixels, null);
}
else
{
pixels = new float[data.length];
// Special float processor that maps all values to 1-255 in the LUT.
// Zero is mapped to 0 in the LUT.
if ((displayFlags & DISPLAY_MAPPED) != 0)
{
MappedFloatProcessor fp = new MappedFloatProcessor(imageWidth, imageHeight, (float[]) pixels, null);
fp.setMapZero((displayFlags & DISPLAY_MAP_ZERO) != 0);
return fp;
}
return new FloatProcessor(imageWidth, imageHeight, (float[]) pixels, null);
}
}
开发者ID:aherbert,项目名称:GDSC-SMLM,代码行数:25,代码来源:IJImagePeakResults.java
示例6: convertArgbLabelTo16BitGray
import ij.process.ShortProcessor; //导入依赖的package包/类
/**
* Converts the specified ARGB label image to a 16-bit gray image.
* Only uses the two lowest order RGB bytes for each pixel (the green and blue values)
* to calculate the pixel's corresponding 16-bit gray value.
*
* @param image ARGB image to convert.
*
* @return a 16-bit gray image.
*/
public static BufferedImage convertArgbLabelTo16BitGray(final BufferedImage image) {
final long startTime = System.currentTimeMillis();
final int width = image.getWidth();
final int height = image.getHeight();
int p = 0;
final short[] convertedPixels = new short[width * height];
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
convertedPixels[p] = (short) image.getRGB(x, y);
p++;
}
}
final ShortProcessor sp = new ShortProcessor(width, height);
sp.setPixels(convertedPixels);
final long elapsedTime = System.currentTimeMillis() - startTime;
LOG.debug("convertArgbLabelTo16BitGray: converted {} pixels in {} milliseconds", convertedPixels.length, elapsedTime);
return sp.get16BitBufferedImage();
}
开发者ID:saalfeldlab,项目名称:render,代码行数:34,代码来源:BoxMipmapGenerator.java
示例7: createBorderManager
import ij.process.ShortProcessor; //导入依赖的package包/类
public BorderManager createBorderManager(ImageProcessor image) {
switch((Type) this) {
case REPLICATED:
return new ReplicatedBorder(image);
case PERIODIC:
return new PeriodicBorder(image);
case MIRRORED:
return new MirroringBorder(image);
case BLACK:
return new ConstantBorder(image, 0);
case WHITE:
return new ConstantBorder(image, 0xFFFFFF);
case GRAY:
if (image instanceof ColorProcessor)
return new ConstantBorder(image, 0x7F7F7F);
if (image instanceof ShortProcessor)
return new ConstantBorder(image, 0x007FFF);
return new ConstantBorder(image, 127);
default:
throw new RuntimeException("Unknown border manager for type " + this);
}
}
开发者ID:ijpb,项目名称:MorphoLibJ,代码行数:23,代码来源:BorderManager.java
示例8: createLabelImage
import ij.process.ShortProcessor; //导入依赖的package包/类
/**
* Creates a label image with the appropriate class to store the required
* number of labels.
*
* @param width
* the width of the new label image
* @param height
* the height of the new label image
* @param nLabels
* expected number of labels in new image
* @return a new ImageProcessor with type adapted to store the expected
* number of labels
*/
public static final ImageProcessor createLabelImage(int width, int height,
int nLabels)
{
if (nLabels < 256)
{
return new ByteProcessor(width, height);
}
else if (nLabels < 256 * 256)
{
return new ShortProcessor(width, height);
}
else if (nLabels < (0x01 << 23))
{
return new FloatProcessor(width, height);
}
else
{
IJ.error("Too many classes");
return null;
}
}
开发者ID:ijpb,项目名称:MorphoLibJ,代码行数:35,代码来源:LabelImages.java
示例9: initialize
import ij.process.ShortProcessor; //导入依赖的package包/类
private ShortProcessor initialize(ImageProcessor marker)
{
// size of image
sizeX = marker.getWidth();
sizeY = marker.getHeight();
ShortProcessor distMap = new ShortProcessor(sizeX, sizeY);
distMap.setValue(0);
distMap.fill();
// initialize empty image with either 0 (foreground) or Inf (background)
for (int y = 0; y < sizeY; y++)
{
for (int x = 0; x < sizeX; x++)
{
int val = marker.get(x, y) & 0x00ff;
distMap.set(x, y, val == 0 ? Short.MAX_VALUE : 0);
}
}
return distMap;
}
开发者ID:ijpb,项目名称:MorphoLibJ,代码行数:23,代码来源:GeodesicDistanceTransformShort5x5.java
示例10: initializeResult
import ij.process.ShortProcessor; //导入依赖的package包/类
private ShortProcessor initializeResult(ImageProcessor labelImage)
{
// size of image
int sizeX = labelImage.getWidth();
int sizeY = labelImage.getHeight();
// create new empty image, and fill it with black
ShortProcessor distMap = new ShortProcessor(sizeX, sizeY);
distMap.setValue(0);
distMap.fill();
// initialize empty image with either 0 (background) or Inf (foreground)
for (int y = 0; y < sizeY; y++)
{
for (int x = 0; x < sizeX; x++)
{
int label = (int) labelImage.getf(x, y);
distMap.set(x, y, label == 0 ? 0 : Short.MAX_VALUE);
}
}
return distMap;
}
开发者ID:ijpb,项目名称:MorphoLibJ,代码行数:24,代码来源:DistanceTransform5x5Short.java
示例11: normalise
import ij.process.ShortProcessor; //导入依赖的package包/类
/**
* Normalises the image. Performs a thresholding on the image using the Otsu method.
* Then scales the pixels above the threshold from 0 to 255.
*
* @param ip
* The input image
*/
private void normalise(FloatProcessor ip)
{
float[] pixels = (float[]) ip.getPixels();
ShortProcessor sp = (ShortProcessor) ip.convertToShort(true);
int[] data = sp.getHistogram();
int threshold = AutoThreshold.getThreshold(Method.OTSU, data);
float minf = (float) threshold;
float maxf = (float) sp.getMax();
float scaleFactor = 255.0f / (maxf - minf);
for (int i = pixels.length; i-- > 0;)
{
pixels[i] = (Math.max((float) sp.get(i), minf) - minf) * scaleFactor;
}
}
开发者ID:aherbert,项目名称:GDSC,代码行数:25,代码来源:Align_Stacks.java
示例12: toProcessor
import ij.process.ShortProcessor; //导入依赖的package包/类
/**
* Get an image processor containing the object mask.
*
* @return the image processor
*/
public ImageProcessor toProcessor()
{
int max = getMaxObject();
ImageProcessor ip = (max > 255) ? (max > 65535) ? new FloatProcessor(getWidth(), getHeight())
: new ShortProcessor(getWidth(), getHeight()) : new ByteProcessor(getWidth(), getHeight());
if (max > 65535)
{
for (int i = objectMask.length; i-- > 0;)
ip.setf(i, objectMask[i]);
}
else
{
for (int i = objectMask.length; i-- > 0;)
ip.set(i, objectMask[i]);
}
ip.setMinAndMax(0, max);
return ip;
}
开发者ID:aherbert,项目名称:GDSC,代码行数:24,代码来源:ObjectAnalyzer.java
示例13: isNoThreshold
import ij.process.ShortProcessor; //导入依赖的package包/类
public boolean isNoThreshold(ImagePlus imp)
{
boolean noThreshold = false;
ImageProcessor ip = imp.getProcessor();
double t1 = ip.getMinThreshold();
int imageType;
if (ip instanceof ShortProcessor)
imageType = SHORT;
else if (ip instanceof FloatProcessor)
imageType = FLOAT;
else
imageType = BYTE;
if (t1 == ImageProcessor.NO_THRESHOLD)
{
ImageStatistics stats = imp.getStatistics();
if (imageType != BYTE || (stats.histogram[0] + stats.histogram[255] != stats.pixelCount))
{
noThreshold = true;
}
}
return noThreshold;
}
开发者ID:aherbert,项目名称:GDSC,代码行数:23,代码来源:MaskParticleAnalyzer.java
示例14: createImageData3D
import ij.process.ShortProcessor; //导入依赖的package包/类
private static ImagePlus createImageData3D()
{
// Create an image with peaks
int size = 64;
int z = 5;
int n = 20;
float[][] data1 = createSpots3D(size, z, n, 5000, 10000, 2.5, 3.0);
float[][] data2 = createSpots3D(size, z, n, 10000, 20000, 4.5, 3.5);
float[][] data3 = createSpots3D(size, z, n, 20000, 40000, 6.5, 5);
ImageStack stack = new ImageStack(size, size);
for (int i = 0; i < data1.length; i++)
{
short[] data = combine(data1[i], data2[i], data3[i]);
stack.addSlice(new ShortProcessor(size, size, data, null));
}
// Show
String title = "FindFociTest3D";
//gdsc.core.ij.Utils.display(title, stack);
return new ImagePlus(title, stack);
}
开发者ID:aherbert,项目名称:GDSC,代码行数:21,代码来源:FindFociTest.java
示例15: simulateFrame
import ij.process.ShortProcessor; //导入依赖的package包/类
/**
* Generates a new frame based on the current device state, and moves
* device state forward.
* First the obstructions are drawn on the frame, then the fluorophores,
* and afterwards noise is added.
* @return simulated frame
*/
public ShortProcessor simulateFrame() {
float[][] pixels = new float[camera.res_x][camera.res_y];
for (int row = 0; row < pixels.length; row++)
Arrays.fill(pixels[row], 0.0f);
// Add obstructions
if (obstructors != null) {
for (Obstructor o: obstructors) {
o.applyTo(pixels);
}
}
// Add emitters
// The applyTo method also handles fluorophore state changes by calling
// the simulateBrightness() method of an emitter.
for (Fluorophore f: fluorophores) {
f.applyTo(pixels);
}
// Add noise
addNoises(pixels);
// Convert signal to ADU and add baseline.
for (int x = 0; x < pixels.length; x++) {
for (int y = 0; y < pixels[0].length; y++) {
pixels[x][y] *= camera.ADU_per_electron;
pixels[x][y] += camera.baseline;
}
}
// Convert to short array
FloatProcessor fp = new FloatProcessor(pixels);
return fp.convertToShortProcessor(false);
}
开发者ID:LEB-EPFL,项目名称:SASS,代码行数:41,代码来源:Device.java
示例16: simulateFrame
import ij.process.ShortProcessor; //导入依赖的package包/类
/**
* Generates a new frame and moves the device state forward.
*
* First the obstructors are drawn on the frame, then the fluorophores,
* and finally noise.
*
* @return simulated frame
*/
public ShortProcessor simulateFrame() {
float[][] pixels = new float[this.camera.getNX()][this.camera.getNY()];
for (int row = 0; row < pixels.length; row++)
Arrays.fill(pixels[row], 0.0f);
// Add obstructions
if (obstructors != null) {
for (Obstructor o: obstructors) {
o.applyTo(pixels);
}
}
// Add fluorophores
// The applyTo method also handles fluorophore state changes by calling
// the simulateBrightness() method of an emitter.
for (Fluorophore f: fluorophores) {
f.applyTo(pixels);
}
addBackground(pixels);
addNoise(pixels);
// Convert signal to ADU and add baseline.
for (int x = 0; x < pixels.length; x++) {
for (int y = 0; y < pixels[0].length; y++) {
pixels[x][y] *= this.camera.getAduPerElectron();
pixels[x][y] += this.camera.getBaseline();
}
}
// Convert to short array
FloatProcessor fp = new FloatProcessor(pixels);
return fp.convertToShortProcessor(false);
}
开发者ID:LEB-EPFL,项目名称:SASS,代码行数:42,代码来源:Microscope.java
示例17: makeLabelImageGray
import ij.process.ShortProcessor; //导入依赖的package包/类
private ShortProcessor makeLabelImageGray() {
ShortProcessor sp = new ShortProcessor(width, height);
for (int v = 0; v < height; v++) {
for (int u = 0; u < width; u++) {
int lb = getLabel(u, v);
sp.set(u, v, (lb >= 0) ? lb : 0);
}
}
sp.resetMinAndMax();
return sp;
}
开发者ID:imagingbook,项目名称:imagingbook-common,代码行数:12,代码来源:RegionLabeling.java
示例18: create
import ij.process.ShortProcessor; //导入依赖的package包/类
public static ImageAccessor.Scalar create(ImageProcessor ip, OutOfBoundsStrategy obs, InterpolationMethod ipm) {
if (ip instanceof ByteProcessor)
return new ImageAccessor.Byte((ByteProcessor) ip, obs, ipm);
if (ip instanceof ShortProcessor)
return new ImageAccessor.Short((ShortProcessor) ip, obs, ipm);
if (ip instanceof FloatProcessor)
return new ImageAccessor.Float((FloatProcessor) ip, obs, ipm);
throw new IllegalArgumentException("cannot create ImageAccessor.Gray for this processor");
}
开发者ID:imagingbook,项目名称:imagingbook-common,代码行数:10,代码来源:ImageAccessor.java
示例19: readImagePlusRegion
import ij.process.ShortProcessor; //导入依赖的package包/类
@Override
public PathImage<ImagePlus> readImagePlusRegion(RegionRequest request) {
// Create an ImagePlus from a BufferedImage
BufferedImage img = readBufferedImage(request);
ImagePlus imp = null;
SampleModel sampleModel = img.getSampleModel();
int dataType = sampleModel.getDataType();
int w = img.getWidth();
int h = img.getHeight();
if ((dataType == DataBuffer.TYPE_BYTE && sampleModel.getNumBands() != 1) ||
dataType == DataBuffer.TYPE_USHORT || dataType == DataBuffer.TYPE_SHORT || dataType == DataBuffer.TYPE_FLOAT || dataType == DataBuffer.TYPE_DOUBLE) {
// Handle non-8-bit images
ImageStack stack = new ImageStack(w, h);
for (int b = 0; b < sampleModel.getNumBands(); b++) {
// Read data as float (no matter what it is)
FloatProcessor fp = new FloatProcessor(w, h);
float[] pixels = (float[])fp.getPixels();
sampleModel.getSamples(0, 0, w, h, b, pixels, img.getRaster().getDataBuffer());
// Convert to 8 or 16-bit, if appropriate
if (dataType == DataBuffer.TYPE_BYTE) {
ByteProcessor bp = new ByteProcessor(w, h);
bp.setPixels(0, fp);
stack.addSlice(bp);
} else if (dataType == DataBuffer.TYPE_USHORT) {
ShortProcessor sp = new ShortProcessor(w, h);
sp.setPixels(0, fp);
stack.addSlice(sp);
} else
stack.addSlice(fp);
}
imp = new ImagePlus(getShortServerName(), stack);
} else
// Create whatever image ImageJ will give us
imp = new ImagePlus(getShortServerName(), img);
imp.setDimensions(imp.getNSlices(), 1, 1);
IJTools.calibrateImagePlus(imp, request, this);
return PathImagePlus.createPathImage(this, request, imp);
}
开发者ID:qupath,项目名称:qupath,代码行数:39,代码来源:BufferedImagePlusServer.java
示例20: setImage
import ij.process.ShortProcessor; //导入依赖的package包/类
/**
* Set image to be segmented. Supported types are: {@link ByteProcessor}, {@link ShortProcessor}, and {@link FloatProcessor}.
*
* @param image image.
*/
public void setImage(final ImageProcessor image) {
Validate.argumentNotNull(image, "image");
if (image instanceof ByteProcessor) {
setImage((ByteProcessor) image);
} else if (image instanceof ShortProcessor) {
setImage((ShortProcessor) image);
} else if (image instanceof FloatProcessor) {
setImage((FloatProcessor) image);
} else {
throw new IllegalArgumentException("Unsupported image type: " + image.getClass().getName());
}
}
开发者ID:ij-plugins,项目名称:ijp-toolkit,代码行数:18,代码来源:SRG.java
注:本文中的ij.process.ShortProcessor类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论