setting pixel width/height NONinteractively

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

setting pixel width/height NONinteractively

Kenneth Sloan-2
How can I specify the pixel width and height of an image I am creating in a Java plugin?

I see lots of documentation on how to do it using a Dialog - but I don't need any input from
the user.

For completeness: I want to set the units to "mm" and the pixel width/height to known values.

I'm sure it's in the documentation...somewhere...but I confess that I can't find it.

--
Kenneth Sloan
[hidden email]
Vision is the art of seeing what is invisible to others.

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

Re: setting pixel width/height NONinteractively

Kenneth Sloan-2
I don't think so.

AS I read the documentation,

imp = IJ.createImage("Untitled", "8-bit black", 1024, 1024, 4);

sets the width, height, and depth of the image.

I want to say that the pixels are x mm wide.  I see how to set the units to "mm", but could not find
a way to set the size of the pixels, except through an interactive dialog.

Ah...I think I found it.  Calibration has  public fields "pixelHeight", "pixelWidth" and "pixelDepth".

I'm not used to such things being exposed as public fields - it violates my personal coding standard - so I don't often look there.

I prefer getX() and setX() methods.  Calibration has (for example) getUnits() and setUnits() - but not getPixelWidth() or setPixelWidth()

My mistake.  Carry on!


--
Kenneth Sloan
[hidden email]
Vision is the art of seeing what is invisible to others.






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