private void putRow(final ImageProcessor ip, int x, final int y, final float[] data, final int length) { if (rgb) { for (int i = 0; i < length; i++) ip.putPixel(x++, y, Float.floatToIntBits(data[i])); } else { for (int i = 0; i < length; i++) ip.putPixelValue(x++, y, data[i]); } }
private void putColumn(final ImageProcessor ip, final int x, int y, final float[] data, final int length) { if (rgb) { for (int i = 0; i < length; i++) ip.putPixel(x, y++, Float.floatToIntBits(data[i])); } else { for (int i = 0; i < length; i++) ip.putPixelValue(x, y++, data[i]); } }
public void putPixelValue(int x, int y, double value) { record("putPixelValue", new Object[] {new Integer(x), new Integer(y), new Double(value)}, new Class[] {int.class, int.class, double.class}); proc.putPixelValue(x, y, value); }
public void putRow(ImageProcessor ip, int x, int y, float[] data, int length) { if (rgb) { for (int i=0; i<length; i++) ip.putPixel(x++, y, Float.floatToIntBits(data[i])); } else { for (int i=0; i<length; i++) ip.putPixelValue(x++, y, data[i]); } }
public void putColumn(ImageProcessor ip, int x, int y, float[] data, int length) { if (rgb) { for (int i=0; i<length; i++) ip.putPixel(x, y++, Float.floatToIntBits(data[i])); } else { for (int i=0; i<length; i++) ip.putPixelValue(x, y++, data[i]); } }
public void putRow(ImageProcessor ip, int x, int y, float[] data, int length) { if (rgb) { for (int i=0; i<length; i++) ip.putPixel(x++, y, Float.floatToIntBits(data[i])); } else { for (int i=0; i<length; i++) ip.putPixelValue(x++, y, data[i]); } }
public void putColumn(ImageProcessor ip, int x, int y, float[] data, int length) { if (rgb) { for (int i=0; i<length; i++) ip.putPixel(x, y++, Float.floatToIntBits(data[i])); } else { for (int i=0; i<length; i++) ip.putPixelValue(x, y++, data[i]); } }
public void putRow(ImageProcessor ip, int x, int y, float[] data, int length) { if (rgb) { for (int i=0; i<length; i++) ip.putPixel(x++, y, Float.floatToIntBits(data[i])); } else { for (int i=0; i<length; i++) ip.putPixelValue(x++, y, data[i]); } }
public void putPixelValue(int x, int y, double value) { record("putPixelValue", new Object[] {new Integer(x), new Integer(y), new Double(value)}, new Class[] {int.class, int.class, double.class}); proc.putPixelValue(x, y, value); }
void fixLut(ImageProcessor ip) { if(!lut.isGrayscale() && lut.getMapSize() == 256){ for(int y=0;y<ip.getHeight();y++){ for(int x=0;x<ip.getWidth();x++){ if(ip.getPixelValue(x, y)==0){ ip.putPixelValue(x, y, 1); }else if(ip.getPixelValue(x, y)==255){ ip.putPixelValue(x, y, 254); } } } byte[] rLUT = lut.getReds(); //new byte[256]; byte[] gLUT = lut.getGreens(); //new byte[256]; byte[] bLUT = lut.getBlues(); //new byte[256]; rLUT[0] = (byte)0; gLUT[0] = (byte)0; bLUT[0] = (byte)0; rLUT[255] = (byte)255; gLUT[255] = (byte)255; bLUT[255] = (byte)255; ip.setColorModel(new IndexColorModel(8, 256, rLUT, gLUT, bLUT)); } }
public ImagePlus composeImages(ArrayList<ImagePlus> imageList){ int sumWidth = 0; int maxHeight = 0; for(ImagePlus imp : imageList){ sumWidth = sumWidth +imp.getWidth(); if(imp.getHeight() > maxHeight) maxHeight = imp.getWidth(); } ImagePlus impComposite = new ImagePlus(); ImageProcessor ipComposite = new ShortProcessor(sumWidth, maxHeight); for(int i=0; i<sumWidth; i++){ for(int j=0; j<sumWidth; j++){ ipComposite.putPixelValue(i, j, figureOutThis); } } impComposite.setProcessor(ipComposite); return impComposite; }
void fixLut(ImageProcessor ip) { if(!lut.isGrayscale() && lut.getMapSize() == 256){ for(int y=0;y<ip.getHeight();y++){ for(int x=0;x<ip.getWidth();x++){ if(ip.getPixelValue(x, y)==0){ ip.putPixelValue(x, y, 1); }else if(ip.getPixelValue(x, y)==255){ ip.putPixelValue(x, y, 254); } } } byte[] rLUT = lut.getReds(); //new byte[256]; byte[] gLUT = lut.getGreens(); //new byte[256]; byte[] bLUT = lut.getBlues(); //new byte[256]; rLUT[0] = (byte)0; gLUT[0] = (byte)0; bLUT[0] = (byte)0; rLUT[255] = (byte)255; gLUT[255] = (byte)255; bLUT[255] = (byte)255; ip.setColorModel(new IndexColorModel(8, 256, rLUT, gLUT, bLUT)); } }
regip.putPixelValue(x, y, ip.getInterpolatedPixel(x - p[0], y - p[1]));
/** * Creates a 2D Sholl heatmap by applying measured values to the foreground * pixels of a copy of the analyzed image */ public ImageProcessor getMaskProcessor(final boolean floatProcessor, final double[] maskValues) { checkUnsetFields(); // Work on a stack projection when dealing with a volume final ImageProcessor ip = imp.getNSlices() > 1 ? projImp() : imp.getProcessor(); // NB: 16-bit image: Negative values will be set to 0 final ImageProcessor mp = floatProcessor ? new FloatProcessor(ip.getWidth(), ip.getHeight()) : new ShortProcessor(ip.getWidth(), ip.getHeight()); final int drawSteps = maskValues.length; final int sRadius = (int) Math.round(profile.startRadius() / voxelSize); final int drawWidth = (int) Math.round((profile.endRadius() - profile.startRadius()) / drawSteps); for (int i = 0; i < drawSteps; i++) { int drawRadius = sRadius + i * drawWidth; for (int j = 0; j < drawWidth; j++) { // this will already exclude pixels out of bounds final int[][] points = getCircumferencePoints(xc, yc, drawRadius++); for (final int[] point : points) { final double value = ip.getPixel(point[0], point[1]); if (withinThreshold(value)) { mp.putPixelValue(point[0], point[1], maskValues[i]); } } } } mp.resetMinAndMax(); return mp; }
ImagePlus doMedianProjection() { IJ.showStatus("Calculating median..."); ImageStack stack = imp.getStack(); ImageProcessor[] slices = new ImageProcessor[sliceCount]; int index = 0; for (int slice=startSlice; slice<=stopSlice; slice+=increment) slices[index++] = stack.getProcessor(slice); ImageProcessor ip2 = slices[0].duplicate(); ip2 = ip2.convertToFloat(); float[] values = new float[sliceCount]; int width = ip2.getWidth(); int height = ip2.getHeight(); int inc = Math.max(height/30, 1); for (int y=0; y<height; y++) { if (y%inc==0) IJ.showProgress(y, height-1); for (int x=0; x<width; x++) { for (int i=0; i<sliceCount; i++) values[i] = slices[i].getPixelValue(x, y); ip2.putPixelValue(x, y, median(values)); } } if (imp.getBitDepth()==8) ip2 = ip2.convertToByte(false); IJ.showProgress(1, 1); return new ImagePlus(makeTitle(), ip2); }
ImagePlus doMedianProjection() { IJ.showStatus("Calculating median..."); ImageStack stack = imp.getStack(); ImageProcessor[] slices = new ImageProcessor[sliceCount]; int index = 0; for (int slice=startSlice; slice<=stopSlice; slice+=increment) slices[index++] = stack.getProcessor(slice); ImageProcessor ip2 = slices[0].duplicate(); ip2 = ip2.convertToFloat(); float[] values = new float[sliceCount]; int width = ip2.getWidth(); int height = ip2.getHeight(); int inc = Math.max(height/30, 1); for (int y=0; y<height; y++) { if (y%inc==0) IJ.showProgress(y, height-1); for (int x=0; x<width; x++) { for (int i=0; i<sliceCount; i++) values[i] = slices[i].getPixelValue(x, y); ip2.putPixelValue(x, y, median(values)); } } if (imp.getBitDepth()==8) ip2 = ip2.convertToByte(false); IJ.showProgress(1, 1); return new ImagePlus(makeTitle(), ip2); }
if (replace) { if (isFloat) ip.putPixelValue(x, y, darg3); else ip.putPixel(x, y, (int)darg3);
void setPixel() { interp.getLeftParen(); int a1 = (int)interp.getExpression(); interp.getComma(); double a2 = interp.getExpression(); interp.getToken(); ImageProcessor ip = getProcessor(); if (interp.token==',') { double a3 = interp.getExpression(); interp.getRightParen(); if (ip instanceof FloatProcessor) ip.putPixelValue(a1, (int)a2, a3); else ip.putPixel(a1, (int)a2, (int)a3); } else { if (interp.token!=')') interp.error("')' expected"); if (ip instanceof ColorProcessor) ip.set(a1, (int)a2); else ip.setf(a1, (float)a2); } updateNeeded = true; }
if (replace) { if (isFloat) ip.putPixelValue(x, y, darg3); else ip.putPixel(x, y, (int)darg3);
void setPixel() { interp.getLeftParen(); int a1 = (int)interp.getExpression(); interp.getComma(); double a2 = interp.getExpression(); interp.getToken(); ImageProcessor ip = getProcessor(); if (interp.token==',') { double a3 = interp.getExpression(); interp.getRightParen(); if (ip instanceof FloatProcessor) ip.putPixelValue(a1, (int)a2, a3); else ip.putPixel(a1, (int)a2, (int)a3); } else { if (interp.token!=')') interp.error("')' expected"); if (ip instanceof ColorProcessor) ip.set(a1, (int)a2); else ip.setf(a1, (float)a2); } updateNeeded = true; }