[imagej] Commandline resize image

By.

min read

My profile

Share this:

resize an image and write the result as PNG

[code:1:fffc75c7e6] /**
* @author Ramon Fincken, http://www.ramonfincken.com/permalink/topic241.html
* @param source
* @param write_to_png
* @param width_factor
* @param height_factor
*/
public void resize_by(String source, String write_to_png, double width_factor, double height_factor)
{
ImagePlus imp1 = IJ.openImage(source);
ImageProcessor ip=imp1.getProcessor();

int new_width = (int)(ip.getWidth() * width_factor);
int new_height = (int)(ip.getHeight() * height_factor);

ip = ip.resize(new_width, new_height);

imp1.setProcessor(ip);
WindowManager.setTempCurrentImage(imp1);
IJ.saveAs(“PNG”, write_to_png);
}[/code:1:fffc75c7e6]

Share this:

Leave a Reply

Your email address will not be published. Required fields are marked *