Login  Register

Re: Displayed XY range

Posted by Rasband, Wayne (NIH/NIMH) [E] on Oct 25, 2015; 4:43pm
URL: http://imagej.273.s1.nabble.com/Displayed-XY-range-tp5014738p5014762.html

> On Oct 23, 2015, at 7:15 AM, Jean Ollion <[hidden email]> wrote:
>
> Hello,
>
> sometimes not all the XY range of an image is displayed in the image window
> (for instance when this zoom magnification is high enough). How is it
> possible to access to the displayed range (ie : Xmin, Xmax, Ymin, Ymax)
> from java code, and also to modify it (without changing the zoom
> magnification) also from java code

You can get the displayed range by calling the ImageCanvas.getSrcRect() method. You can modify the range by modifying the SrcRect and redrawing the image. Here is a JavaScript example:

  img = IJ.openImage("http://imagej.nih.gov/ij/images/NileBend.jpg");
  img.show();
  IJ.run(img, "View 100%", "");
  ic = img.getCanvas();
  srcRect = ic.getSrcRect();
  print(srcRect);
  IJ.wait(2000);
  srcRect.x = 400;
  srcRect.y = 370;
  img.draw();
  IJ.wait(2000);
  srcRect.x = 700;
  srcRect.y = 700;
  img.draw();

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html