ij.process.FloatProcessor Java Examples

The following examples show how to use ij.process.FloatProcessor. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DataGeneratorPlugIn.java    From thunderstorm with GNU General Public License v3.0 6 votes vote down vote up
private FloatProcessor readMask(String imagePath) {
    if((imagePath != null) && (imagePath.trim().length() > 0)) {
        ImagePlus imp = IJ.openImage(imagePath);
        if(imp != null) {
            // ensure that the maximum value cannot be more than 1.0 !
            FloatProcessor fmask = (FloatProcessor) imp.getProcessor().convertToFloat();
            float min = 0;
            float max = (float) fmask.getMax();
            if(max > 0) {
                for(int x = 0; x < fmask.getWidth(); x++) {
                    for(int y = 0; y < fmask.getHeight(); y++) {
                        fmask.setf(x, y, (fmask.getf(x, y) - min) / (max - min));
                    }
                }
            }
            return fmask;
        }
    }
    return ImageMath.ones(width, height);
}
 
Example #2
Source File: RankFiltersOrbit.java    From orbit-image-analysis with GNU General Public License v3.0 6 votes vote down vote up
void showMasks() {
	int w=150, h=150;
	ImageStack stack = new ImageStack(w, h);
	//for (double r=0.1; r<3; r+=0.01) {
	for (double r=0.5; r<50; r+=0.5) {
		ImageProcessor ip = new FloatProcessor(w,h,new int[w*h]);
		float[] pixels = (float[])ip.getPixels();
		int[] lineRadii = makeLineRadii(r);
		int kHeight = kHeight(lineRadii);
		int kRadius = kRadius(lineRadii);
		int y0 = h/2-kHeight/2;
		for (int i = 0, y = y0; i<kHeight; i++, y++)
			for (int x = w/2+lineRadii[2*i], p = x+y*w; x <= w/2+lineRadii[2*i+1]; x++, p++)
				pixels[p] = 1f;
		stack.addSlice("radius="+r+", size="+(2*kRadius+1), ip);
	}
	new ImagePlus("Masks", stack).show();
}
 
Example #3
Source File: LabelImages.java    From MorphoLibJ with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * 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;
	}
}
 
Example #4
Source File: ValueToNoise.java    From render with GNU General Public License v2.0 6 votes vote down vote up
@Override
public ImageProcessor process(final ImageProcessor ip,
                              final double scale) {
    try {
        if (FloatProcessor.class.isInstance(ip)) {
            if (Double.isNaN(value))
                processFloatNaN((FloatProcessor) ip, min, max);
            else
                processFloat((FloatProcessor) ip, (float) value, min, max);
        } else {
            if (ColorProcessor.class.isInstance(ip))
                processColor((ColorProcessor) ip, (int) Math.round(value),
                        (int) Math.round(min), (int) Math.round(max));
            else
                processGray(ip, (int) Math.round(value),
                        (int) Math.round(min), (int) Math.round(max));
        }
    } catch (final Exception e) {
        e.printStackTrace();
    }
    return ip;
}
 
Example #5
Source File: Util.java    From TrakEM2 with GNU General Public License v3.0 6 votes vote down vote up
/**
 * <p>Transfer and ARGB AWT image into a FloatProcessor with its grey values
 * and a FloatProcessor with its alpha values as [0...1].</p>
 * 
 * <p><em>Note</em>, this method currently relies on how ImageJ reuses the
 * pixels of an AWT image as generated by {@link Loader#getFlatAWTImage(ini.trakem2.display.Layer, java.awt.Rectangle, double, int, int, Class, java.util.List, boolean, java.awt.Color, ini.trakem2.display.Displayable) Loader.getFlatAWTImage(...)}
 * for creating a ColorProcessor.  This may change in the future as have
 * many things in the past.  This method is then the place to fix it. 
 * 
 * @param input
 * @param output
 * @param alpha
 */
final static public void imageToFloatAndMask( final Image input, final FloatProcessor output, final FloatProcessor alpha )
{
	final ColorProcessor cp = new ColorProcessor( input );
	final int[] inputPixels = ( int[] )cp.getPixels();
	for ( int i = 0; i < inputPixels.length; ++i )
	{
		final int argb = inputPixels[ i ];
		final int a = ( argb >> 24 ) & 0xff;
		final int r = ( argb >> 16 ) & 0xff;
		final int g = ( argb >> 8 ) & 0xff;
		final int b = argb & 0xff;
		
		final float v = ( r + g + b ) / ( float )3;
		final float w = a / ( float )255;
		
		output.setf( i, v );
		alpha.setf( i, w );
	}
}
 
Example #6
Source File: BinaryImagesTest.java    From MorphoLibJ with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Test
	public final void testDistanceMapImageProcessorFloatArrayBoolean() {
		ImageProcessor image = createBinarySquareImage();

		float[] weights = new float[]{3f, 4f};
		ImageProcessor result = BinaryImages.distanceMap(image, weights, true);
		
//		for (int y = 0; y < image.getHeight(); y++) {
//			for (int x = 0; x < image.getWidth(); x++) {
//				System.out.print(" " + result.getf(x, y));
//			}
//			System.out.println("");
//		}

		assertNotNull(result);
		assertTrue(result instanceof FloatProcessor);
		assertEquals(image.getWidth(), result.getWidth());
		assertEquals(image.getHeight(), result.getHeight());
		assertEquals(3, result.getf(4, 4), 1e-12);
	}
 
Example #7
Source File: BiplaneAnalysisPlugIn.java    From thunderstorm with GNU General Public License v3.0 6 votes vote down vote up
private void analyzeFrame(int frame, FloatProcessor fp1, FloatProcessor fp2) {
    // init
    IFilter filter = selectedFilterUI.getThreadLocalImplementation();
    IDetector detector = selectedDetectorUI.getThreadLocalImplementation();
    IBiplaneEstimator estimator = selectedEstimatorUI.getThreadLocalImplementation();

    // detection in first plane
    Thresholder.setCurrentImage(fp1);
    List<Point> det1 = detector.detectMoleculeCandidates(filter.filterImage(fp1));
    // detection in second plane
    Thresholder.setCurrentImage(fp2);
    List<Point> det2 = detector.detectMoleculeCandidates(filter.filterImage(fp2));

    // run fitting on the pairs
    List<Molecule> fits = estimator.estimateParameters(fp1, fp2, Point.applyRoiMask(roi1, det1), Point.applyRoiMask(roi2, det2));
    storeFits(fits, frame);
    if(fits.size() > 0) {
        renderingQueue.renderLater(fits);
    }
}
 
Example #8
Source File: ValueToNoise.java    From TrakEM2 with GNU General Public License v3.0 6 votes vote down vote up
@Override
public ImageProcessor process(final ImageProcessor ip) {
	try {
		if (FloatProcessor.class.isInstance(ip)) {
			if (Double.isNaN(value))
				processFloatNaN((FloatProcessor)ip, min, max);
			else
				processFloat((FloatProcessor)ip, (float)value, min, max);
		} else {
			if (ColorProcessor.class.isInstance(ip))
				processColor((ColorProcessor)ip, (int)Math.round(value), (int)Math.round(min), (int)Math.round(max));
			else
				processGray(ip, (int)Math.round(value), (int)Math.round(min), (int)Math.round(max));
		}
	} catch (final Exception e) {
		e.printStackTrace();
	}
	return ip;
}
 
Example #9
Source File: Normalize.java    From TrakEM2 with GNU General Public License v3.0 6 votes vote down vote up
@Override
public ImageProcessor process(ImageProcessor ip) {
	if (ip instanceof ColorProcessor) {
		FloatProcessor r = normalize(ip.toFloat(0, null)),
		               g = normalize(ip.toFloat(1, null)),
		               b = normalize(ip.toFloat(2, null));
		int[] p = new int[ip.getWidth() * ip.getHeight()];
		ColorProcessor cp = new ColorProcessor(ip.getWidth(), ip.getHeight(), p);
		final float[] rp = (float[]) r.getPixels(),
		              gp = (float[]) g.getPixels(),
		              bp = (float[]) b.getPixels();
		for (int i=0; i<p.length; ++i) {
			p[i] = ((int)rp[i] << 16) | ((int)gp[i] << 8) | (int)bp[i];
		}
		return cp;
	}
	final FloatProcessor fp = normalize((FloatProcessor)ip.convertToFloat());
	if (ip instanceof FloatProcessor) {
		return fp;
	}
	final int len = ip.getWidth() * ip.getHeight();
	for (int i=0; i<len; ++i) {
		ip.setf(i, fp.get(i));
	}
	return ip;
}
 
Example #10
Source File: GeodesicDistanceTransformFloat.java    From MorphoLibJ with GNU Lesser General Public License v3.0 6 votes vote down vote up
private FloatProcessor initialize(ImageProcessor marker)
{
	// size of image
	sizeX = marker.getWidth();
	sizeY = marker.getHeight();
	
	FloatProcessor distMap = new FloatProcessor(sizeX, sizeY);
	distMap.setValue(0);
	distMap.fill();

	// initialize empty image with either 0 (foreground) or NaN (background)
	for (int y = 0; y < sizeY; y++) 
	{
		for (int x = 0; x < sizeX; x++) 
		{
			int val = marker.get(x, y) & 0x00ff;
			distMap.setf(x, y, val == 0 ? Float.POSITIVE_INFINITY : 0);
		}
	}

	return distMap;
}
 
Example #11
Source File: ImageCalculatorTest.java    From MorphoLibJ with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Test method for {@link inra.ijpb.math.ImageCalculator#combineImages(ij.process.ImageProcessor, ij.process.ImageProcessor, inra.ijpb.math.ImageCalculator.Operation)}.
 */
@Test
public final void testCombineImages_FloatFloat_Times_Self()
{
    int width = 30;
    int height = 20;
    ImageProcessor image1 = new FloatProcessor(width, height);
    for (int i = 0; i < width; i++)
    {
        for (int j = 0; j < height; j++)
        {
            image1.setf(i, j, (float) (i+j));
        }
    }
    
    ImageCalculator.Operation op = ImageCalculator.Operation.TIMES;
    ImageProcessor result = ImageCalculator.combineImages(image1, image1, op);
    
    assertTrue(result instanceof FloatProcessor);
    assertEquals(30, result.getWidth());
    assertEquals(20, result.getHeight());
    
    assertEquals(48f*48f, result.getf(29, 19), .001);
    assertEquals(29f*29f, result.getf(29, 0), .001);
    assertEquals(19f*19f, result.getf(0, 19), .001);
}
 
Example #12
Source File: DistanceTransform5x5Float.java    From MorphoLibJ with GNU Lesser General Public License v3.0 6 votes vote down vote up
private void normalizeResult(FloatProcessor distMap, ImageProcessor labelImage)
{
	this.fireStatusChanged(new AlgoEvent(this, "Normalization"));
	
	// size of image
	int sizeX = labelImage.getWidth();
	int sizeY = labelImage.getHeight();

	// normalization weight
	float w0 = weights[0];
	
	for (int y = 0; y < sizeY; y++)
	{
		for (int x = 0; x < sizeX; x++)
		{
			if ((int) labelImage.getf(x, y) > 0)
			{
				distMap.setf(x, y, distMap.getf(x, y) / w0);
			}
		}
	}
}
 
Example #13
Source File: CompoundWaveletFilter.java    From thunderstorm with GNU General Public License v3.0 6 votes vote down vote up
@NotNull
@Override
public HashMap<String, FloatProcessor> exportVariables(boolean reevaluate) {
    if(export_variables == null) {
        export_variables = new HashMap<>();
    }
    //
    if(reevaluate) {
        filterImage(Thresholder.getCurrentImage());
    }
    //
    export_variables.put("I", input);
    export_variables.put("F", result);
    export_variables.put("F1", result_F1);
    export_variables.put("F2", result_F2);
    return export_variables;
}
 
Example #14
Source File: GrayscaleAttributeFilteringPlugin.java    From MorphoLibJ with GNU Lesser General Public License v3.0 6 votes vote down vote up
private void resetPreview()
{
	ImageProcessor image = this.imagePlus.getProcessor();
	if (image instanceof FloatProcessor)
	{
		for (int i = 0; i < image.getPixelCount(); i++)
			image.setf(i, this.baseImage.getf(i));
	}
	else
	{
		for (int i = 0; i < image.getPixelCount(); i++)
			image.set(i, this.baseImage.get(i));
	}
	image.resetMinAndMax();
	imagePlus.updateAndDraw();
}
 
Example #15
Source File: IJImager.java    From DeconvolutionLab2 with GNU General Public License v3.0 6 votes vote down vote up
private ImagePlus build(RealSignal signal, Imager.Type type) {
	if (signal == null)
		return null;

	ImageStack stack = new ImageStack(signal.nx, signal.ny);
	for (int k = 0; k < signal.nz; k++) {
		ImageProcessor ip = new FloatProcessor(signal.nx, signal.ny, signal.getXY(k));
		switch (type) {
		case BYTE:
			stack.addSlice(ip.convertToByteProcessor(false));
			break;
		case SHORT:
			stack.addSlice(ip.convertToShortProcessor(false));
			break;
		case FLOAT:
			stack.addSlice(ip);
		default:
			break;
		}
	}
	return new ImagePlus("", stack);
}
 
Example #16
Source File: DifferenceOfBoxFilters.java    From thunderstorm with GNU General Public License v3.0 6 votes vote down vote up
@Override
public HashMap<String, FloatProcessor> exportVariables(boolean reevaluate) {
    if(export_variables == null) {
        export_variables = new HashMap<String, FloatProcessor>();
    }
    //
    if(reevaluate) {
        filterImage(Thresholder.getCurrentImage());
    }
    //
    export_variables.put("I", input);
    export_variables.put("B1", result_B1);
    export_variables.put("B2", result_B2);
    export_variables.put("F", result);
    return export_variables;
}
 
Example #17
Source File: ImageMath.java    From thunderstorm with GNU General Public License v3.0 5 votes vote down vote up
public static FloatProcessor modulo(float val, FloatProcessor mat) {
    FloatProcessor res = new FloatProcessor(mat.getWidth(), mat.getHeight());
    res.setMask(mat.getMask());
    float tmp;
    for (int i = 0, im = mat.getWidth(); i < im; i++) {
        for (int j = 0, jm = mat.getHeight(); j < jm; j++) {
            tmp = val / mat.getf(i, j);
            res.setf(i, j, val - (((float)((int)tmp)) * mat.getf(i, j)));
        }
    }
    return res;
}
 
Example #18
Source File: GeodesicReconstructionHybridTest.java    From MorphoLibJ with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Test
public void testReconstructByDilationFloatC8() {
	// size of images
	int width = 16;
	int height = 10;

	FloatProcessor mask 		= new FloatProcessor(16, 10);
	FloatProcessor marker 		= new FloatProcessor(16, 10);
	FloatProcessor expected 	= new FloatProcessor(16, 10);

	// initialize mask, marker, and expected images
	int[] maskProfile = {10, 10, 40, 40, 40, 40, 20, 20, 30, 30, 10, 10, 30, 30, 0, 0};
	int[] markerProfile = {0, 0, 0, 30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
	int[] expectedProfile = {10, 10, 30, 30, 30, 30, 20, 20, 20, 20, 10, 10, 10, 10, 0, 0};
	for (int y = 0; y < height; y++) {
		for (int x = 0; x < width; x++) {
			mask.setf(x, y, maskProfile[x]);
			marker.setf(x, y, markerProfile[x]);
			expected.setf(x, y, expectedProfile[x]);
		}
	}

	// Compute geodesic reconstruction by dilation
	GeodesicReconstructionHybrid algo = new GeodesicReconstructionHybrid(
			GeodesicReconstructionType.BY_DILATION, 8);
	ImageProcessor result = algo.applyTo(marker, mask);
	//		printImage(result);

	for (int y = 0; y < height; y++) {
		for (int x = 0; x < width; x++) {
			assertEquals(expectedProfile[x], result.getf(x, y), .01);
		}
	}

}
 
Example #19
Source File: DownsamplerTest.java    From TrakEM2 with GNU General Public License v3.0 5 votes vote down vote up
/**
	 * Test downsampling the pyramid of a short image + byte alpha channel
	 * including the byte mapping of the short doing the alpha channel in a
	 * separate loop.
	 * 
	 * @param ba
	 */
	final private static void testFloatAlphaIndependently( Pair< FloatProcessor, byte[] > ba, ByteProcessor alpha )
	{
		while( ba.a.getWidth() > 32 )
		{
			ba = Downsampler.downsampleFloat( ba.a );
			alpha = Downsampler.downsampleByteProcessor( alpha );
//			new ImagePlus( "pixels " + ba.a.getWidth(), ba.a ).show();
//			new ImagePlus( "pixels to byte " + ba.a.getWidth(), new ByteProcessor( ba.a.getWidth(), ba.a.getHeight(), ba.b[ 0 ], null ) ).show();
//			new ImagePlus( "alpha " + ba.a.getWidth(), new ByteProcessor( ba.a.getWidth(), ba.a.getHeight(), ba.b[ 1 ], null ) ).show();
		}
	}
 
Example #20
Source File: ImageMath.java    From thunderstorm with GNU General Public License v3.0 5 votes vote down vote up
public static FloatProcessor relGt(Double val, FloatProcessor mat) {
    float v = val.floatValue();
    FloatProcessor res = new FloatProcessor(mat.getWidth(), mat.getHeight());
    for(int x = 0; x < mat.getWidth(); x++) {
        for(int y = 0; y < mat.getHeight(); y++) {
            res.setf(x, y, ((v > mat.getf(x, y)) ? 1.0f : 0.0f));
        }
    }
    return res;
}
 
Example #21
Source File: LoweredGaussianFilter.java    From thunderstorm with GNU General Public License v3.0 5 votes vote down vote up
@NotNull
@Override
public HashMap<String, FloatProcessor> exportVariables(boolean reevaluate) {
    if(export_variables == null) export_variables = new HashMap<>();
    //
    if(reevaluate) {
      filterImage(Thresholder.getCurrentImage());
    }
    //
    export_variables.put("I", input);
    export_variables.put("F", result);
    return export_variables;
}
 
Example #22
Source File: ValueToNoise.java    From TrakEM2 with GNU General Public License v3.0 5 votes vote down vote up
final static private void processFloatNaN(final FloatProcessor ip, final double min, final double max) {
	final double scale = max - min;
	final Random rnd = new Random();
	final int n = ip.getWidth() * ip.getHeight();
	for (int i =0; i < n; ++i) {
		final float v = ip.getf(i);
		if (Float.isNaN(v))
			ip.setf(i, (float)(rnd.nextDouble() * scale + min));
	}
}
 
Example #23
Source File: ImageMath.java    From thunderstorm with GNU General Public License v3.0 5 votes vote down vote up
public static FloatProcessor relLt(FloatProcessor a, FloatProcessor b) {
    if((a.getWidth() != b.getWidth()) || (a.getHeight()!= b.getHeight())) {
        throw new IllegalArgumentException("Error during evaluation of `a<b` expression! Both operands must be of the same size!");
    }
    FloatProcessor res = new FloatProcessor(a.getWidth(), a.getHeight());
    res.setMask(a.getMask() != null ? a.getMask(): b.getMask());
    for(int x = 0; x < a.getWidth(); x++) {
        for(int y = 0; y < a.getHeight(); y++) {
            res.setf(x, y, ((a.getf(x, y) < b.getf(x, y)) ? 1.0f : 0.0f));
        }
    }
    return res;
}
 
Example #24
Source File: ImageMath.java    From thunderstorm with GNU General Public License v3.0 5 votes vote down vote up
public static FloatProcessor relGt(FloatProcessor a, FloatProcessor b) {
    if((a.getWidth() != b.getWidth()) || (a.getHeight()!= b.getHeight())) {
        throw new IllegalArgumentException("Error during evaluation of `a<b` expression! Both operands must be of the same size!");
    }
    FloatProcessor res = new FloatProcessor(a.getWidth(), a.getHeight());
    res.setMask(a.getMask() != null ? a.getMask(): b.getMask());
    for(int x = 0; x < a.getWidth(); x++) {
        for(int y = 0; y < a.getHeight(); y++) {
            res.setf(x, y, ((a.getf(x, y) > b.getf(x, y)) ? 1.0f : 0.0f));
        }
    }
    return res;
}
 
Example #25
Source File: ImageMath.java    From thunderstorm with GNU General Public License v3.0 5 votes vote down vote up
public static FloatProcessor relNeq(FloatProcessor a, FloatProcessor b) {
    if((a.getWidth() != b.getWidth()) || (a.getHeight()!= b.getHeight())) {
        throw new IllegalArgumentException("Error during evaluation of `a<b` expression! Both operands must be of the same size!");
    }
    FloatProcessor res = new FloatProcessor(a.getWidth(), a.getHeight());
    res.setMask(a.getMask() != null ? a.getMask(): b.getMask());
    for(int x = 0; x < a.getWidth(); x++) {
        for(int y = 0; y < a.getHeight(); y++) {
            res.setf(x, y, ((a.getf(x, y) != b.getf(x, y)) ? 1.0f : 0.0f));
        }
    }
    return res;
}
 
Example #26
Source File: ImageMath.java    From thunderstorm with GNU General Public License v3.0 5 votes vote down vote up
public static FloatProcessor relEq(FloatProcessor a, FloatProcessor b) {
    if((a.getWidth() != b.getWidth()) || (a.getHeight()!= b.getHeight())) {
        throw new IllegalArgumentException("Error during evaluation of `a<b` expression! Both operands must be of the same size!");
    }
    FloatProcessor res = new FloatProcessor(a.getWidth(), a.getHeight());
    res.setMask(a.getMask() != null ? a.getMask(): b.getMask());
    for(int x = 0; x < a.getWidth(); x++) {
        for(int y = 0; y < a.getHeight(); y++) {
            res.setf(x, y, ((a.getf(x, y) == b.getf(x, y)) ? 1.0f : 0.0f));
        }
    }
    return res;
}
 
Example #27
Source File: Max_Project.java    From SPIM_Registration with GNU General Public License v2.0 5 votes vote down vote up
public static < T extends RealType< T > & NativeType< T > > boolean maxProject(
		final List< ? extends ViewDescription > vds,
		final ImgLoader imgLoader,
		final T type )
{
	Collections.sort( vds );

	final ArrayList< TimePoint > tps = SpimData2.getAllTimePointsSorted( vds );
	final ArrayList< ViewSetup > setups = SpimData2.getAllViewSetups( vds );

	for ( final ViewSetup setup : setups )
	{
		ImageStack stack = null;

		for ( final TimePoint t : tps )
			for ( final ViewDescription vd : vds )
				if ( vd.getTimePointId() == t.getId() && vd.getViewSetupId() == setup.getId() )
				{
					IOFunctions.println( "(" + new Date( System.currentTimeMillis() ) + "): Loading image for timepoint " + t.getId() + " viewsetup " + vd.getViewSetupId() );

					final RandomAccessibleInterval< T > img = ProcessFusion.getImage( type, imgLoader, vd, false );

					final FloatProcessor fp =
							toProcessor( ExtractPSF.computeMaxProjection( img, new ArrayImgFactory< T >(), 2 ) );

					if ( stack == null )
						stack = new ImageStack( fp.getWidth(), fp.getHeight() );

					stack.addSlice( "Timepoint=" + t.getId(), fp);
				}

		final ImagePlus imp = new ImagePlus( "ViewSetupId=" + setup.getId(), stack );
		imp.setDimensions( 1, 1, stack.getSize() );
		imp.show();
	}

	return true;
}
 
Example #28
Source File: GaussianFilter.java    From thunderstorm with GNU General Public License v3.0 5 votes vote down vote up
@NotNull
@Override
public FloatProcessor filterImage(@NotNull FloatProcessor image) throws StoppedByUserException {
    GUI.checkIJEscapePressed();

    input = image;
    result = GrayScaleImageImpl.convertToFloatProcessor(filter.filter(new GrayScaleImageImpl(image)));
    return result;
}
 
Example #29
Source File: DownsamplerTest.java    From TrakEM2 with GNU General Public License v3.0 5 votes vote down vote up
final private static void testFloat( FloatProcessor ipFloat )
{
	final double min = ipFloat.getMin();
	final double max = ipFloat.getMax();
	
	while( ipFloat.getWidth() > 32 )
	{
		ipFloat = Downsampler.downsampleFloatProcessor( ipFloat );
		ipFloat.setMinAndMax( min, max );
	}
}
 
Example #30
Source File: Function.java    From thunderstorm with GNU General Public License v3.0 5 votes vote down vote up
protected double std(Object param) {
    RetVal val = arg.eval(param);
    if(val.isMatrix()) {    // FloatProcessor
        return (FloatStatistics.getStatistics((FloatProcessor)val.get(), Measurements.STD_DEV, null)).stdDev;
    } else if(val.isVector()) {
        return VectorMath.stddev((Number[])val.get()).doubleValue();
    } else if(val.isValue()) {    // Double
        return ((Double)val.get()).doubleValue();
    }
    throw new FormulaParserException("Variables can be only scalars, vectors, or matrices!");
}