public static ImagePlus showVectorAsImage(float [] v, int width) { ImagePlus imp = new ImagePlus("v", new FloatProcessor(width, v.length / width, v, null)); imp.show(); return imp; } /**
@SuppressWarnings("unused") static private final void view( final long[] hist, final int w1, final int h1, final int nBins) { final float[] pixels = new float[w1 * h1 * nBins]; for (int i=0; i<hist.length; ++i) { pixels[i] = hist[i]; } new ImagePlus("Integral Histogram", new FloatProcessor(w1 * nBins, h1, pixels)).show(); }
public static ImagePlus createFeatureDescriptorImage( final String title, final Feature f ) { final int w = ( int )Math.sqrt( f.descriptor.length ); final FloatProcessor fp = new FloatProcessor( w, w ); drawFeatureDescriptor( fp, f ); return new ImagePlus( title, fp ); }
ImageProcessor calculateAmplitude(float[] fht, int maxN) { float[] amp = new float[maxN*maxN]; for (int row=0; row<maxN; row++) { amplitude(row, maxN, fht, amp); } ImageProcessor ip = new FloatProcessor(maxN, maxN, amp, null); swapQuadrants(ip); return ip; }
void swapQuadrants(ImageStack stack) { FHT fht = new FHT(new FloatProcessor(1, 1)); for (int i=1; i<=stack.getSize(); i++) fht.swapQuadrants(stack.getProcessor(i)); }
void postLudium() { if(var!=null) { double realMaxMutInf = getMaxVariance(); IJ.log("maximal MutInf: "+realMaxMutInf+", maximal variance: "+maxVarMutInf+" (std. dev.: "+Math.sqrt(maxVarMutInf)+"), ratio: "+maxMutInfRatio); } if(res3!=null) new ImagePlus("Edgelets", new FloatProcessor(ii.getWidth(), ii.getHeight(), res3)).show(); } }
public void setFromFloatArrays(float[][] arrays) { ImageProcessor ip2 = new FloatProcessor(roiWidth, roiHeight, arrays[0], null); ip2 = ip2.convertToByte(false); setPixels(ip2.getPixels()); //insert(ip2, roiX, roiY); }
int[] smooth(int[] a, int n) { FloatProcessor fp = new FloatProcessor(n, 1); for (int i=0; i<n; i++) fp.putPixelValue(i, 0, a[i]); GaussianBlur gb = new GaussianBlur(); gb.blur1Direction(fp, 2.0, 0.01, true, 0); for (int i=0; i<n; i++) a[i] = (int)Math.round(fp.getPixelValue(i, 0)); return a; }
import ij.process.FloatProcessor; public class SimpleTest { public static float[] func(float []bm, int nx, int ny) { FloatProcessor p = new FloatProcessor(nx,ny); p.setPixels(bm); float[] kernel = new float[{0.111f,0.111f,0.111f,0.111f, 0.111f,0.111f,0.111f,0.111f,0.111f}; p.convolve(kernel, 3, 3); return (float[]) p.getPixels(); } }
public ImagePlus toFloat() { ImageStack stack = new ImageStack(w, h); for(int z = 0; z < d; z++) { stack.addSlice("",new FloatProcessor(w,h,dist[z],null)); } return new ImagePlus("Distance", stack); }
static public final ImageProcessor createProcessor(final int type, final int width, final int height) { switch (type) { case ImagePlus.GRAY8: return new ByteProcessor(width, height); case ImagePlus.GRAY16: return new ShortProcessor(width, height); case ImagePlus.GRAY32: return new FloatProcessor(width, height); case ImagePlus.COLOR_RGB: return new ColorProcessor(width, height); } return null; }
float[] smooth(float[] a, int n) { FloatProcessor fp = new FloatProcessor(n, 1); for (int i=0; i<n; i++) fp.setf(i, 0, a[i]); GaussianBlur gb = new GaussianBlur(); gb.blur1Direction(fp, 2.0, 0.01, true, 0); for (int i=0; i<n; i++) a[i] = fp.getf(i, 0); return a; }
public ImageProcessor getProcessor() { return new FloatProcessor(imp.getProcessor().getWidth(), imp.getProcessor().getHeight(), result, null); } }
private void show(int n) { ImageStack stack = new ImageStack(w, h); for(int z = 0; z < d; z++) { stack.addSlice("", new FloatProcessor( w, h, u[n][z], null)); } new ImagePlus("Displacement_dim" + n, stack).show(); }
final static protected FloatProcessor scaleByte( final ByteProcessor bp ) { final FloatProcessor fp = new FloatProcessor( bp.getWidth(), bp.getHeight() ); final byte[] bytes = ( byte[] )bp.getPixels(); final float[] floats = ( float[] )fp.getPixels(); for ( int i = 0; i < bytes.length; ++i ) floats[ i ] = ( bytes[ i ] & 0xff ) / 255.0f; return fp; }
protected FloatProcessor convertToFloat( final ShortProcessor sp ) { final short[] pixS = (short[]) sp.getPixels(); loader.releaseToFit( pixS.length * 4 ); final float[] pixF = new float[pixS.length]; for ( int i=0; i<pixS.length; ++i) { pixF[i] = pixS[i] & 0xffff; } return new FloatProcessor( sp.getWidth(), sp.getHeight(), pixF ); }
/** Returns a new, blank FloatProcessor with the specified width and height. */ public ImageProcessor createProcessor(int width, int height) { ImageProcessor ip2 = new FloatProcessor(width, height, new float[width*height], getColorModel()); ip2.setMinAndMax(getMin(), getMax()); ip2.setInterpolationMethod(interpolationMethod); return ip2; }
private ImageStatistics getLineStatistics(Roi roi, ImageProcessor ip, int measurements, Calibration cal) { ImagePlus imp = new ImagePlus("", ip); imp.setRoi(roi); ProfilePlot profile = new ProfilePlot(imp); double[] values = profile.getProfile(); ImageProcessor ip2 = new FloatProcessor(values.length, 1, values); return ImageStatistics.getStatistics(ip2, measurements, cal); }
public static FloatProcessor toProcessor( final Img< ? extends RealType< ? > > img ) { final FloatProcessor fp = new FloatProcessor( (int)img.dimension( 0 ), (int)img.dimension( 1 ) ); final float[] array = (float[])fp.getPixels(); final Cursor< ? extends RealType< ? > > c = img.cursor(); for ( int i = 0; i < array.length; ++ i) array[ i ] = c.next().getRealFloat(); return fp; }
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; }