I’m trying to resize and crop an image using ImageJ. Here’s the code:
ImagePlus ip1 = IJ.openImage("_Pic.jpg"); ImagePlus ip2 = IJ.openImage("_Pic.jpg"); ImageProcessor imgP1 = ip1.getProcessor(); ImageProcessor imgP2 = ip2.getProcessor(); FileSaver fs1 = new FileSaver(ip1); FileSaver fs2 = new FileSaver(ip2); /* Trying to resize */ imgP1.resize(100); // also tried with width and height fs1.saveAsJpeg("Resized.jpg"); /* Trying to crop */ imgP2.setRoi(100, 100, 200, 200); imgP2.crop(); fs2.saveAsJpeg("Cropped.jpg");
Unfortunately, the newly created files are identical as the original one.
So far I’ve found out how to blur, smooth, invert, translate, rotate… but these two are giving me hard time. Anybody has an idea?