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 changeValuesAndSymmetrize(ImageProcessor ip, byte v1, byte v2) { byte[] pixels = (byte[])ip.getPixels(); int n = ip.getWidth(); for (int i=0; i<pixels.length; i++) { if (pixels[i] == v1) { //pixel has been edited for pass or filter, set symmetry-equivalent if (i%n==0) { //left edge if (i>0) pixels[n*n-i] = v1; } else if (i<n) //top edge pixels[n-i] = v1; else //no edge pixels[n*(n+1)-i] = v1; } else pixels[i] = v2; //reset all other pixel values } }
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; } }
void changeValuesAndSymmetrize(ImageProcessor ip, byte v1, byte v2) { byte[] pixels = (byte[])ip.getPixels(); int n = ip.getWidth(); for (int i=0; i<pixels.length; i++) { if (pixels[i] == v1) { //pixel has been edited for pass or filter, set symmetry-equivalent if (i%n==0) { //left edge if (i>0) pixels[n*n-i] = v1; } else if (i<n) //top edge pixels[n-i] = v1; else //no edge pixels[n*(n+1)-i] = v1; } else pixels[i] = v2; //reset all other pixel values } }
/** 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(); }
/** Reset region between inner rectangle 'roi' and outer rectangle 'roi1' to the snapshot */ private void resetRoiBoundary(ImageProcessor ip, Rectangle roi, Rectangle roi1) { int width = ip.getWidth(); Object pixels = ip.getPixels(); Object snapshot = ip.getSnapshotPixels(); for (int y=roi1.y, p = roi1.x+y*width; y<roi.y; y++,p+=width) System.arraycopy(snapshot, p, pixels, p, roi1.width); int leftWidth = roi.x - roi1.x; int rightWidth = roi1.x+roi1.width - (roi.x+roi.width); for (int y=roi.y, pL=roi1.x+y*width, pR=roi.x+roi.width+y*width; y<roi.y+roi.height; y++,pL+=width,pR+=width) { if (leftWidth > 0) System.arraycopy(snapshot, pL, pixels, pL, leftWidth); if (rightWidth > 0) System.arraycopy(snapshot, pR, pixels, pR, rightWidth); } for (int y=roi.y+roi.height, p = roi1.x+y*width; y<roi1.y+roi1.height; y++,p+=width) System.arraycopy(snapshot, p, pixels, p, roi1.width); }
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; } }
/** Reset region between inner rectangle 'roi' and outer rectangle 'roi1' to the snapshot */ private void resetRoiBoundary(ImageProcessor ip, Rectangle roi, Rectangle roi1) { int width = ip.getWidth(); Object pixels = ip.getPixels(); Object snapshot = ip.getSnapshotPixels(); for (int y=roi1.y, p = roi1.x+y*width; y<roi.y; y++,p+=width) System.arraycopy(snapshot, p, pixels, p, roi1.width); int leftWidth = roi.x - roi1.x; int rightWidth = roi1.x+roi1.width - (roi.x+roi.width); for (int y=roi.y, pL=roi1.x+y*width, pR=roi.x+roi.width+y*width; y<roi.y+roi.height; y++,pL+=width,pR+=width) { if (leftWidth > 0) System.arraycopy(snapshot, pL, pixels, pL, leftWidth); if (rightWidth > 0) System.arraycopy(snapshot, pR, pixels, pR, rightWidth); } for (int y=roi.y+roi.height, p = roi1.x+y*width; y<roi1.y+roi1.height; y++,p+=width) System.arraycopy(snapshot, p, pixels, p, roi1.width); }
/** 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(); }
/** 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(); }