Get and set voxel size within a plugin

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

Get and set voxel size within a plugin

José María Mateos
Hi everybody,

I have a 3D image with a certain voxel size. I have a plugin that does
some processing and returns a new image with the same dimensions as the
original one. However, the voxel size for the new image is 1x1x1, which
may lead to problems. I have not found a way to get or set the voxel
size using the methods from ImagePlus or ImageStack. I tried get and
setFileInfo() but it's not what I'm looking for.

Currently I am using a macro and the functions getVoxelSize(...) and
setVoxelSize(...) to copy that information from the original image to
the resulting image. This works, but is a workaround I'd like to avoid.
Is there any "pure" API call that I can use for this?

Best,

José María Mateos.

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Get and set voxel size within a plugin

ctrueden
Hi José,

> I have not found a way to get or set the voxel size using the methods
> from ImagePlus or ImageStack.

It's part of the Calibration class:

ImagePlus imp = ...;
double xVox = imp.getCalibration().pixelWidth;
double yVox = imp.getCalibration().pixelHeight;
double zVox = imp.getCalibration().pixelDepth;

Regards,
Curtis


On Fri, Oct 5, 2012 at 4:59 AM, José María Mateos <[hidden email]>wrote:

> Hi everybody,
>
> I have a 3D image with a certain voxel size. I have a plugin that does
> some processing and returns a new image with the same dimensions as the
> original one. However, the voxel size for the new image is 1x1x1, which may
> lead to problems. I have not found a way to get or set the voxel size using
> the methods from ImagePlus or ImageStack. I tried get and setFileInfo() but
> it's not what I'm looking for.
>
> Currently I am using a macro and the functions getVoxelSize(...) and
> setVoxelSize(...) to copy that information from the original image to the
> resulting image. This works, but is a workaround I'd like to avoid. Is
> there any "pure" API call that I can use for this?
>
> Best,
>
> José María Mateos.
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.**html<http://imagej.nih.gov/ij/list.html>
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Get and set voxel size within a plugin

José María Mateos
On 05/10/2012 17:08, Curtis Rueden wrote:
> It's part of the Calibration class:
>
> ImagePlus imp = ...;
> double xVox = imp.getCalibration().pixelWidth;
> double yVox = imp.getCalibration().pixelHeight;
> double zVox = imp.getCalibration().pixelDepth;
>
> Regards,
> Curtis

Thanks a lot for your answer, Curtis. Unfortunately, it is not working.
When creating my new image (actually a class that extends ImagePlus) I
added this line:

this.setCalibration(ip.getCalibration());

Where "ip" is the original ImagePlus object. When I get the info from
the generated image, the voxel size is still 1x1x1. Am I missing
something here?

Best,

José María Mateos.

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Get and set voxel size within a plugin

José María Mateos
On 05/10/2012 17:49, José María Mateos wrote:

>
> Thanks a lot for your answer, Curtis. Unfortunately, it is not working.
> When creating my new image (actually a class that extends ImagePlus) I
> added this line:
>
> this.setCalibration(ip.getCalibration());
>
> Where "ip" is the original ImagePlus object. When I get the info from
> the generated image, the voxel size is still 1x1x1. Am I missing
> something here?

Forget what I said, it's fixed now. I was not assigning the Calibration
data when creating my extended class.

Best,

José María Mateos.

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