3D Image Cropping with ImageJ (Java)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

3D Image Cropping with ImageJ (Java)

neslihnaydn
Hi,

I want to crop area which is specified by the user (rectangle mouse selection). In the below code i just crop image with given coordinates. How can i show image then select rectangle and crop ?

public static void crop(ImagePlus imp, int width, int height) throws Exception{
          ImageStack stack = imp.getImageStack();
          ImageStack s2 = null;

          int cropX = 14;
          int cropY = 392;
          int cropZ = 0;
          s2 = stack.crop(cropX, cropY, cropZ, width, height, imp.getStackSize()); //stack crop
          imp.setStack(null, s2);
          //IJ.saveAsTiff(imp, "crop.tiff");
          imp.show();
   
  }

Thank you.