how to resize an image / how to call an imagej-function in source code

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

how to resize an image / how to call an imagej-function in source code

Marko Ulbrich
Hi all,

i have the following problem:
how can i use imagej-resize-function in my plugins. I have a picture
with 1280x1024 pixels. I want to resize this to 320x256. What type of
image do i get back and how i can i work with the resized image.
In ImageJ itself that's no problem, but i don't know how to implement
this in my source code. (I don't know this for all other funcions too).

It would be great if somebody can help.
Thanks, Marko
Reply | Threaded
Open this post in threaded view
|

Re: how to resize an image / how to call an imagej-function in source code

Albert Cardona
Marko,

Use the ImageProcessor class resize(int new_width, int new_height) method,
such as:

ImagePlus imp_big = WindowManager.getCurrentImage();
ImageProcessor ip_big = imp_big.getProcessor();
ip_big.setInterpolate(true);
ImageProcessor ip_small = resize(320, 256);
ImagePlus small = new ImagePlus("small", ip_small);
small.show();

Of course you can write the above in a much compact manner, and there's not
much need to setup interpolation when scaling down. That's up to your style
and requirements.

Albert

--
Albert Cardona
Molecular Cell Developmental Biology
University of California Los Angeles
Tel +1 310 2067376
Programming: http://www.pensament.net/java/
Research: http://www.mcdb.ucla.edu/Research/Hartenstein/
Web design: http://www.pixelets.com