Login  Register

Re: resizing of a ROI

Posted by jmutterer on Nov 15, 2007; 7:22am
URL: http://imagej.273.s1.nabble.com/resizing-of-a-ROI-tp3698011p3698014.html

 Hi Eric,
You can use the Edit/Selection/Specify... dialog to specify a rectangular
ROI by numbers,
or you can use the makeRectangle(x,y,width,height); macro function.
or you can specify a given ROI, push it to the ROI Manager with Ctrl-T and
save it to a ROI file. Then you can open this ROI on any other image.

If you have to crop several images according to some ROI, use the following
macro, derived from the BatchMeasure and the FileDemo example macros :


macro "Batch Crop" {
dir = getDirectory("Choose a Directory ");
cropDir = dir+"cropped"+File.separator;
File.makeDirectory(cropDir);
  if (!File.exists(cropDir))
      exit("Unable to create cropped directory");
list = getFileList(dir);
setBatchMode(true);
for (i=0; i<list.length; i++) {
path = dir+list[i];
showProgress(i, list.length);
if (!endsWith(path,"/")) open(path);
if (nImages>=1) {
////// adjust according to your settings here
makeRectangle(0,0,getWidth()/2,getHeight()/2);
run("Crop");
////// adjust format as well
saveAs("Tiff", cropDir+getTitle());
close();
}
}
}
/// end Batch crop.
///

Jerome.

On Nov 15, 2007 5:59 AM, Eric BADEL < [hidden email] > wrote:
> Hi,
> Is there a way to define an ROI without the mouse but specifying the
> coordinates of the rectangle ?
> In fact I have to crop many images and I want to be sure that the crop
> is always the same.
>

>
> Eric
>
>
> Rasband Wayne wrote:
> > You can do this easily using the arrow keys.
> >
> >    1. press 'a' (select all)
> >    3. press the alt-left twice
> >    4. press the alt-up twice
> >    6. press right
> >    7. press down
> >
> > The arrow keys move the selection in one pixel increments. With the
> > alt key down, they move the right and bottom edges.
> >
> > -wayne
> >
> > On Nov 10, 2007, at 8:42 AM, Peter Cloetens wrote:
> >
> >> Hello,
> >> I'm trying to resize a rectangular roi to slightly smaller than the
> >> complete width, height of an image.
> >> When I use the handles on the left/right to change the width, this
> >> does not work when the original roi corresponds to the complete
> >> image. In that case I loose the roi and have to start again. If the
> >> height of the original roi is smaller than the vertical size of the
> >> image, I can change the width.
> >> This occurs both on Linux and Mac.
> >> Thanks,
> >> Peter
> >
>
>
> --
> **********************************************************
>
> Eric BADEL
> Charge de Recherches INRA
> Laboratoire d'Etudes et de Recherches sur le Materiau Bois
> LERMAB
> 14 rue Girardet
> 54 000 NANCY
> tel: (33) 3 83 39 68 86
> [hidden email]
>
> ***********************************************************
>