Login  Register

Re: Change canvas size for all images in a dicom image set.

Posted by Rasband, Wayne (NIH/NIMH) [E] on Feb 23, 2015; 4:45pm
URL: http://imagej.273.s1.nabble.com/Change-canvas-size-for-all-images-in-a-dicom-image-set-tp5011729p5011731.html

On Feb 23, 2015, at 10:29 AM, John Thaman <[hidden email]> wrote:
>
> Greetings,
>
> I am looking to use imagej to change the canvas size for a large set of DICOM images.The actual goal is to change the images suchthat they have equal numbers of columns and rows without changing the aspect ratio of the data. I can do this manually by changing canvas size and saving each individual image/slice. I am receiving increasingly larger image sets and wishto utilize a plugin or macro that will do this for me. Please advise if you know of an available tool.

You can do this using the macro below.

-wayne

  w = 1024;
  h = 1024
  dir1 = getDirectory("Choose Source Directory ");
  dir2 = getDirectory("Choose Destination Directory ");
  list = getFileList(dir1);
  setBatchMode(true);
  for (i=0; i<list.length; i++) {
     showProgress(i+1, list.length);
     open(dir1+list[i]);
     run("Canvas Size...", "width=&w height=&h position=Center zero");
     saveAs("tiff", dir2+list[i]);
     close();
  }

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