Refine search
void clearAboveProfile(ImageProcessor ipProfile, double[] profile, int width, double yinc2) { byte[] pixels = (byte[])ipProfile.getPixels(); double ydelta = 0.0; int height = ipProfile.getHeight(); for(int x=0; x<width; x++) { ydelta += yinc2; int top = height - (int)(profile[x]+ydelta); for (int y=0,index=x; y<top; y++, index+=width) pixels[index] = (byte)255; } }
/** after watershed, set all pixels in the background and segmentation lines to 0 */ private void watershedPostProcess(ImageProcessor ip) { //new ImagePlus("before postprocess",ip.duplicate()).show(); byte[] pixels = (byte[])ip.getPixels(); int size = ip.getWidth()*ip.getHeight(); for (int i=0; i<size; i++) { if ((pixels[i]&255)<255) pixels[i] = (byte)0; } //new ImagePlus("after postprocess",ip.duplicate()).show(); }
void clearAboveProfile(ImageProcessor ipProfile, double[] profile, int width, double yinc2) { byte[] pixels = (byte[])ipProfile.getPixels(); double ydelta = 0.0; int height = ipProfile.getHeight(); for(int x=0; x<width; x++) { ydelta += yinc2; int top = height - (int)(profile[x]+ydelta); for (int y=0,index=x; y<top; y++, index+=width) pixels[index] = (byte)255; } }
/** after watershed, set all pixels in the background and segmentation lines to 0 */ private void watershedPostProcess(ImageProcessor ip) { //new ImagePlus("before postprocess",ip.duplicate()).show(); byte[] pixels = (byte[])ip.getPixels(); int size = ip.getWidth()*ip.getHeight(); for (int i=0; i<size; i++) { if ((pixels[i]&255)<255) pixels[i] = (byte)0; } //new ImagePlus("after postprocess",ip.duplicate()).show(); }
void normalizeFloat(ImageProcessor ip, double min, double max) { double scale = max>min?1.0/(max-min):1.0; int size = ip.getWidth()*ip.getHeight(); float[] pixels = (float[])ip.getPixels(); double v; for (int i=0; i<size; i++) { v = pixels[i] - min; if (v<0.0) v = 0.0; v *= scale; if (v>1.0) v = 1.0; pixels[i] = (float)v; } }
/** after watershed, set all pixels in the background and segmentation lines to 0 */ private void watershedPostProcess(ImageProcessor ip) { //new ImagePlus("before postprocess",ip.duplicate()).show(); byte[] pixels = (byte[])ip.getPixels(); int size = ip.getWidth()*ip.getHeight(); for (int i=0; i<size; i++) { if ((pixels[i]&255)<255) pixels[i] = (byte)0; } //new ImagePlus("after postprocess",ip.duplicate()).show(); }
void normalizeFloat(ImageProcessor ip, double min, double max) { double scale = max>min?1.0/(max-min):1.0; int size = ip.getWidth()*ip.getHeight(); float[] pixels = (float[])ip.getPixels(); double v; for (int i=0; i<size; i++) { v = pixels[i] - min; if (v<0.0) v = 0.0; v *= scale; if (v>1.0) v = 1.0; pixels[i] = (float)v; } }
/** Constructs a Wand object from an ImageProcessor. */ public Wand(ImageProcessor ip) { this.ip = ip; Object pixels = ip.getPixels(); if (pixels instanceof byte[]) bpixels = (byte[])pixels; else if (pixels instanceof int[]) cpixels = (int[])pixels; else if (pixels instanceof short[]) spixels = (short[])pixels; else if (pixels instanceof float[]) fpixels = (float[])pixels; width = ip.getWidth(); height = ip.getHeight(); }
/** Assigns the pixel array of an ImageProcessor to the specified slice, were 1<=n<=nslices. */ public void setProcessor(ImageProcessor ip, int n) { if (n<1 || n>nSlices) throw new IllegalArgumentException(outOfRange+n); if (type!=UNKNOWN && type!=getType(ip)) throw new IllegalArgumentException("Wrong type for this stack"); if (ip.getWidth()!=width || ip.getHeight()!=height) throw new IllegalArgumentException("Wrong dimensions for this stack"); stack[n-1] = ip.getPixels(); }