Login  Register

Copy a ROI

Posted by Nikos Katsikanis on Feb 22, 2006; 4:05pm
URL: http://imagej.273.s1.nabble.com/Copy-a-ROI-tp3703632.html

I want to create a Roi interest in the plugin code. I then want to make a
new imagePlus withthese pixels. However in the new image I always get the
ROI pixels starting from x = 0 and y = 0 . in the following code,



r = new Rectangle(200,200, 500, 500);
  ip.setRoi(r);
 
  rectangle = ip.getRoi();
   ipW = (int)rectangle .getWidth();
   ipH = (int)rectangle .getHeight();

   ImagePlus image = NewImage.createByteImage("1", ipW, ipH,
    1, NewImage.FILL_BLACK);
  ImageProcessor ip2 = image.getProcessor();
  ip2.copyBits(ip, 0, 0, Blitter.COPY);
  splitRight.show();


what I want is another image 500 x 500 showing the pixels in the rectangle ie
(x range 200 - 700)
(y range 200 - 700)

. what I get  is a pixture with the Roi (0, 0, 300,300) from the original
picture ie

could anyone explain this please.