/** Returns a new, blank ColorProcessor with the specified width and height. */ public ImageProcessor createProcessor(int width, int height) { ImageProcessor ip2 = new ColorProcessor(width, height); ip2.setInterpolationMethod(interpolationMethod); return ip2; }
/** Returns a new, blank ColorProcessor with the specified width and height. */ public ImageProcessor createProcessor(int width, int height) { ImageProcessor ip2 = new ColorProcessor(width, height); ip2.setInterpolationMethod(interpolationMethod); return ip2; }
public void run(ImageProcessor ip) { ip.setInterpolationMethod(interpolationMethod); ip.translate(xOffset, yOffset); }
public void run(ImageProcessor ip) { ip.setInterpolationMethod(interpolationMethod); ip.translate(xOffset, yOffset); }
/** Returns a new, blank ByteProcessor with the specified width and height. */ public ImageProcessor createProcessor(int width, int height) { ImageProcessor ip2; ip2 = new ByteProcessor(width, height, new byte[width*height], getColorModel()); if (baseCM!=null) ip2.setMinAndMax(min, max); ip2.setInterpolationMethod(interpolationMethod); return ip2; }
final public ImageProcessor createMappedImageInterpolated( final ImageProcessor source ) { Rectangle boundingBox = transform.getBoundingBox(); final ImageProcessor target = source.createProcessor( boundingBox.width, boundingBox.height ); source.setInterpolationMethod( ImageProcessor.BILINEAR ); mapInterpolated( source, target ); return target; }
/** Returns a new, blank ByteProcessor with the specified width and height. */ public ImageProcessor createProcessor(int width, int height) { ImageProcessor ip2; ip2 = new ByteProcessor(width, height, new byte[width*height], getColorModel()); if (baseCM!=null) ip2.setMinAndMax(min, max); ip2.setInterpolationMethod(interpolationMethod); return ip2; }
/** * Scale an image with good quality in both up and down direction */ final static public ImageProcessor scale( final ImageProcessor source, final float scale ) { if ( scale == 1.0f ) return source.duplicate(); else if ( scale < 1.0f ) return createDownsampled( source, scale, 0.5f, 0.5f ); else { source.setInterpolationMethod( ImageProcessor.BILINEAR ); return source.resize( Math.round( scale * source.getWidth() ) ); } }
import ij.IJ; import ij.ImagePlus; import ij.io.Opener; import ij.process.ImageProcessor; public class Resizer { public static void main(String[] args) { processPicture("X0aPT.jpg", "output.jpg", 0.0198, ImageProcessor.NONE, 0.3); } public static void processPicture(String inputFile, String outputFilePath, double scaleFactor, int interpolationMethod, double sigmaFactor) { Opener opener = new Opener(); ImageProcessor ip = opener.openImage(inputFile).getProcessor(); ip.blurGaussian(sigmaFactor / scaleFactor); ip.setInterpolationMethod(interpolationMethod); ImageProcessor outputProcessor = ip.resize((int)(ip.getWidth() * scaleFactor), (int)(ip.getHeight()*scaleFactor)); IJ.saveAs(new ImagePlus("", outputProcessor), outputFilePath.substring(outputFilePath.lastIndexOf('.')+1), outputFilePath); } }
/** 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; }
/** Returns a new, blank ShortProcessor with the specified width and height. */ public ImageProcessor createProcessor(int width, int height) { ImageProcessor ip2 = new ShortProcessor(width, height, new short[width*height], getColorModel()); ip2.setMinAndMax(getMin(), getMax()); ip2.setInterpolationMethod(interpolationMethod); return ip2; }
/** Returns a new, blank ShortProcessor with the specified width and height. */ public ImageProcessor createProcessor(int width, int height) { ImageProcessor ip2 = new ShortProcessor(width, height, new short[width*height], getColorModel()); ip2.setMinAndMax(getMin(), getMax()); ip2.setInterpolationMethod(interpolationMethod); return ip2; }
/** 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; }
/** * Scale an image with good quality in both up and down direction */ final static public ImageProcessor scale( final ImageProcessor source, final float scale ) { final ImageProcessor target; if ( scale == 1.0f ) target = source.duplicate(); else if ( scale < 1.0f ) target = createDownsampled( source, scale, 0.5f, 0.5f ); else { source.setInterpolationMethod( ImageProcessor.BILINEAR ); target = source.resize( Math.round( scale * source.getWidth() ) ); } target.setMinAndMax( source.getMin(), source.getMax() ); return target; } }
/** * Scale an image with good quality in both up and down direction */ final static public ImageProcessor scale( final ImageProcessor source, final float scale ) { final ImageProcessor target; if ( scale == 1.0f ) target = source.duplicate(); else if ( scale < 1.0f ) target = createDownsampled( source, scale, 0.5f, 0.5f ); else { source.setInterpolationMethod( ImageProcessor.BILINEAR ); target = source.resize( Math.round( scale * source.getWidth() ) ); } target.setMinAndMax( source.getMin(), source.getMax() ); return target; } }
private ImagePlus resizeZ(ImagePlus imp, int newDepth, int interpolationMethod) { ImageStack stack1 = imp.getStack(); int width = stack1.getWidth(); int height = stack1.getHeight(); int depth = stack1.getSize(); int bitDepth = imp.getBitDepth(); ImagePlus imp2 = IJ.createImage(imp.getTitle(), bitDepth+"-bit", width, height, newDepth); if (imp2==null) return null; ImageStack stack2 = imp2.getStack(); ImageProcessor ip = imp.getProcessor(); ImageProcessor xzPlane1 = ip.createProcessor(width, depth); xzPlane1.setInterpolationMethod(interpolationMethod); ImageProcessor xzPlane2; Object xzpixels1 = xzPlane1.getPixels(); IJ.showStatus("Z Scaling..."); for (int y=0; y<height; y++) { IJ.showProgress(y, height-1); for (int z=0; z<depth; z++) { // get xz plane at y Object pixels1 = stack1.getPixels(z+1); System.arraycopy(pixels1, y*width, xzpixels1, z*width, width); } xzPlane2 = xzPlane1.resize(width, newDepth, averageWhenDownsizing); Object xypixels2 = xzPlane2.getPixels(); for (int z=0; z<newDepth; z++) { Object pixels2 = stack2.getPixels(z+1); System.arraycopy(xypixels2, z*width, pixels2, y*width, width); } } return imp2; }
ip = imp.getStack().getProcessor(slice); ip.setInterpolationMethod(interpolationMethod); if (fillWithBackground) { Color bgc = Toolbar.getBackgroundColor();
@Override public void run( final String arg ) { /* cleanup */ m.clear(); imp = IJ.getImage(); target = imp.getProcessor(); source = target.duplicate(); source.setInterpolationMethod( ImageProcessor.BILINEAR ); init(); createMapping(); painter = new MappingThread( imp, source, target, pleaseRepaint, mapping, interpolate ); painter.start(); Toolbar.getInstance().setTool( Toolbar.getInstance().addTool( "Add_and_drag_handles." ) ); imp.getCanvas().addMouseListener( this ); imp.getCanvas().addMouseMotionListener( this ); imp.getCanvas().addKeyListener( this ); imp.getWindow().addKeyListener( this ); IJ.getInstance().addKeyListener( this ); }
@Override public void run() { final int si = imp.getStackIndex( imp.getChannel(), imp.getSlice(), imp.getFrame() ); final ImageStack stack = imp.getStack(); for ( int i = 1; i <= stack.getSize(); ++i ) { final ImageProcessor source = stack.getProcessor( i ).duplicate(); final ImageProcessor target = source.createProcessor( source.getWidth(), source.getHeight() ); source.setInterpolationMethod( ImageProcessor.BILINEAR ); mapping.mapInterpolated( source, target ); if ( i == si ) imp.getProcessor().setPixels( target.getPixels() ); stack.setPixels( target.getPixels(), i ); IJ.showProgress( i, stack.getSize() ); } if ( imp.isComposite() ) ( ( CompositeImage )imp ).setChannelsUpdated(); imp.updateAndDraw(); } } );
@Override public void run() { final int si = imp.getStackIndex( imp.getChannel(), imp.getSlice(), imp.getFrame() ); final ImageStack stack = imp.getStack(); for ( int i = 1; i <= stack.getSize(); ++i ) { final ImageProcessor source = stack.getProcessor( i ).duplicate(); final ImageProcessor target = source.createProcessor( source.getWidth(), source.getHeight() ); source.setInterpolationMethod( ImageProcessor.BILINEAR ); mapping.mapInterpolated( source, target ); if ( i == si ) imp.getProcessor().setPixels( target.getPixels() ); stack.setPixels( target.getPixels(), i ); IJ.showProgress( i, stack.getSize() ); } if ( imp.isComposite() ) ( ( CompositeImage )imp ).setChannelsUpdated(); imp.updateAndDraw(); } } );