Get the pixel Size

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

Get the pixel Size

BenDehap
Hello,

I have a simple problem and reading different forums didn't help me to resolve it.

I need for my ImageJ Plugins to attribute to a variable "x" the value of the pixel size in "µm" used in my pre-calibrated "image1".  

It would really help me if someone can help me on this case.

Thanks very much.

Ben
Reply | Threaded
Open this post in threaded view
|

Re: Get the pixel Size

Michael Entrup
Hi Ben,

each ImagePlus [1] has a method called ``getCalibration()``. It returns
the Calibration [2] instance of the ImagePlus. The Calibration Object
contains all the methods you need. ``getUnit()`` returns a String to
check if the unit is µm. ``getX(double x)`` converts a pixel value into
a physical unit.

Best regards
Michael

[1]: http://rsb.info.nih.gov/ij/developer/api/ij/ImagePlus.html
[2]: http://rsb.info.nih.gov/ij/developer/api/ij/measure/Calibration.html


On 31.01.2016 20:37, BenDehap wrote:

> Hello,
>
> I have a simple problem and reading different forums didn't help me to
> resolve it.
>
> I need for my ImageJ Plugins to attribute to a variable "x" the value of the
> pixel size in "µm" used in my pre-calibrated "image1".
>
> It would really help me if someone can help me on this case.
>
> Thanks very much.
>
> Ben
>
>
>
> --
> View this message in context: http://imagej.1557.x6.nabble.com/Get-the-pixel-Size-tp5015501.html
> Sent from the ImageJ mailing list archive at Nabble.com.
>
> --
> ImageJ mailing list: 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 the pixel Size

BenDehap
Hello Michael,

First thank you for your answer, someone give me a simple way to resolve my problem as following : 


getPixelSize (unit, pixelWidth, pixelHeight);
if (unit=="microns"){
x=pixelWidth;}
else exit ("No calibration");

but i seen that the method you propose is widely used on forums. 
Would it be possible to show me an example of code using "x" for the value of the pixel witdh and "image1" for the name of my image.

I don't know if you have the time to do it, but i'm a coding beginner and i feell a bit lost.

Thanks anyway.

Ben


2016-02-01 11:15 GMT+01:00 Michael Entrup [via ImageJ] <[hidden email]>:
Hi Ben,

each ImagePlus [1] has a method called ``getCalibration()``. It returns
the Calibration [2] instance of the ImagePlus. The Calibration Object
contains all the methods you need. ``getUnit()`` returns a String to
check if the unit is µm. ``getX(double x)`` converts a pixel value into
a physical unit.

Best regards
Michael

[1]: http://rsb.info.nih.gov/ij/developer/api/ij/ImagePlus.html
[2]: http://rsb.info.nih.gov/ij/developer/api/ij/measure/Calibration.html


On 31.01.2016 20:37, BenDehap wrote:

> Hello,
>
> I have a simple problem and reading different forums didn't help me to
> resolve it.
>
> I need for my ImageJ Plugins to attribute to a variable "x" the value of the
> pixel size in "µm" used in my pre-calibrated "image1".
>
> It would really help me if someone can help me on this case.
>
> Thanks very much.
>
> Ben
>
>
>
> --
> View this message in context: http://imagej.1557.x6.nabble.com/Get-the-pixel-Size-tp5015501.html
> Sent from the ImageJ mailing list archive at Nabble.com.
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

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



If you reply to this email, your message will be added to the discussion below:
http://imagej.1557.x6.nabble.com/Get-the-pixel-Size-tp5015501p5015507.html
To unsubscribe from Get the pixel Size, click here.
NAML

Reply | Threaded
Open this post in threaded view
|

Re: Get the pixel Size

Kenneth Sloan-2
Please excuse me for piggy-backing on this discussion, but…

With the rise in Stack processing - are there similar mechanisms to record, remember, and report back on the depth of voxels?  Simplest would be “getVoxelSize(unit, voxelWidth, voxelHeight, voxelDepth)” - but…I’ll take what I can get.

Pressing my luck - it’s common for slices in a stack to be less regularly spaced than, say, rows in an image.  Is there any mechanism for mapping slice number -> z value?


Kenneth Sloan
[hidden email] <mailto:[hidden email]>
Vision is the art of seeing what is invisible to others.

> On Feb 1, 2016, at 07:45, BenDehap <[hidden email]> wrote:
>
> Hello Michael,
>
> First thank you for your answer, someone give me a simple way to resolve my
> problem as following :
>
>
> getPixelSize (unit, pixelWidth, pixelHeight);
> if (unit=="microns"){
> x=pixelWidth;}
> else exit ("No calibration");
>
> but i seen that the method you propose is widely used on forums.
> Would it be possible to show me an example of code using "x" for the value
> of the pixel witdh and "image1" for the name of my image.
>
> I don't know if you have the time to do it, but i'm a coding beginner and i
> feell a bit lost.
>
> Thanks anyway.
>
> Ben
>
>
> 2016-02-01 11:15 GMT+01:00 Michael Entrup [via ImageJ] <
> [hidden email]>:
>
>> Hi Ben,
>>
>> each ImagePlus [1] has a method called ``getCalibration()``. It returns
>> the Calibration [2] instance of the ImagePlus. The Calibration Object
>> contains all the methods you need. ``getUnit()`` returns a String to
>> check if the unit is µm. ``getX(double x)`` converts a pixel value into
>> a physical unit.
>>
>> Best regards
>> Michael
>>
>> [1]: http://rsb.info.nih.gov/ij/developer/api/ij/ImagePlus.html
>> [2]: http://rsb.info.nih.gov/ij/developer/api/ij/measure/Calibration.html
>>
>>
>> On 31.01.2016 20:37, BenDehap wrote:
>>
>>> Hello,
>>>
>>> I have a simple problem and reading different forums didn't help me to
>>> resolve it.
>>>
>>> I need for my ImageJ Plugins to attribute to a variable "x" the value of
>> the
>>> pixel size in "µm" used in my pre-calibrated "image1".
>>>
>>> It would really help me if someone can help me on this case.
>>>
>>> Thanks very much.
>>>
>>> Ben
>>>
>>>
>>>
>>> --
>>> View this message in context:
>> http://imagej.1557.x6.nabble.com/Get-the-pixel-Size-tp5015501.html
>>> Sent from the ImageJ mailing list archive at Nabble.com.
>>>
>>> --
>>> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>>>
>>
>> --
>> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>>
>>
>> ------------------------------
>> If you reply to this email, your message will be added to the discussion
>> below:
>> http://imagej.1557.x6.nabble.com/Get-the-pixel-Size-tp5015501p5015507.html
>> To unsubscribe from Get the pixel Size, click here
>> <
>> .
>> NAML
>> <
http://imagej.1557.x6.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>>
>
>
>
>
> --
> View this message in context: http://imagej.1557.x6.nabble.com/Get-the-pixel-Size-tp5015501p5015510.html
> Sent from the ImageJ mailing list archive at Nabble.com.
>
> --
> ImageJ mailing list: 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 the pixel Size

Jan Eglinger
Hi Kenneth,

please consult the documentation:
http://imagej.net/developer/macro/functions.html#getVoxelSize

Jan


On 01.02.16 20:13, Kenneth Sloan wrote:

> Please excuse me for piggy-backing on this discussion, but…
>
> With the rise in Stack processing - are there similar mechanisms to record, remember, and report back on the depth of voxels?  Simplest would be “getVoxelSize(unit, voxelWidth, voxelHeight, voxelDepth)” - but…I’ll take what I can get.
>
> Pressing my luck - it’s common for slices in a stack to be less regularly spaced than, say, rows in an image.  Is there any mechanism for mapping slice number -> z value?
>
> —
> Kenneth Sloan
> [hidden email] <mailto:[hidden email]>
> Vision is the art of seeing what is invisible to others.
>
>> On Feb 1, 2016, at 07:45, BenDehap <[hidden email]> wrote:
>>
>> Hello Michael,
>>
>> First thank you for your answer, someone give me a simple way to resolve my
>> problem as following :
>>
>>
>> getPixelSize (unit, pixelWidth, pixelHeight);
>> if (unit=="microns"){
>> x=pixelWidth;}
>> else exit ("No calibration");
>>
>> but i seen that the method you propose is widely used on forums.
>> Would it be possible to show me an example of code using "x" for the value
>> of the pixel witdh and "image1" for the name of my image.
>>
>> I don't know if you have the time to do it, but i'm a coding beginner and i
>> feell a bit lost.
>>
>> Thanks anyway.
>>
>> Ben
>>
>>
>> 2016-02-01 11:15 GMT+01:00 Michael Entrup [via ImageJ] <
>> [hidden email]>:
>>
>>> Hi Ben,
>>>
>>> each ImagePlus [1] has a method called ``getCalibration()``. It returns
>>> the Calibration [2] instance of the ImagePlus. The Calibration Object
>>> contains all the methods you need. ``getUnit()`` returns a String to
>>> check if the unit is µm. ``getX(double x)`` converts a pixel value into
>>> a physical unit.
>>>
>>> Best regards
>>> Michael
>>>
>>> [1]: http://rsb.info.nih.gov/ij/developer/api/ij/ImagePlus.html
>>> [2]: http://rsb.info.nih.gov/ij/developer/api/ij/measure/Calibration.html
>>>
>>>
>>> On 31.01.2016 20:37, BenDehap wrote:
>>>
>>>> Hello,
>>>>
>>>> I have a simple problem and reading different forums didn't help me to
>>>> resolve it.
>>>>
>>>> I need for my ImageJ Plugins to attribute to a variable "x" the value of
>>> the
>>>> pixel size in "µm" used in my pre-calibrated "image1".
>>>>
>>>> It would really help me if someone can help me on this case.
>>>>
>>>> Thanks very much.
>>>>
>>>> Ben
>>>>
>>>>
>>>>
>>>> --
>>>> View this message in context:
>>> http://imagej.1557.x6.nabble.com/Get-the-pixel-Size-tp5015501.html
>>>> Sent from the ImageJ mailing list archive at Nabble.com.
>>>>
>>>> --
>>>> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>>>>
>>>
>>> --
>>> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>>>
>>>
>>> ------------------------------
>>> If you reply to this email, your message will be added to the discussion
>>> below:
>>> http://imagej.1557.x6.nabble.com/Get-the-pixel-Size-tp5015501p5015507.html
>>> To unsubscribe from Get the pixel Size, click here
>>> <
>>> .
>>> NAML
>>> <
http://imagej.1557.x6.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>>>
>>
>>
>>
>>
>> --
>> View this message in context: http://imagej.1557.x6.nabble.com/Get-the-pixel-Size-tp5015501p5015510.html
>> Sent from the ImageJ mailing list archive at Nabble.com.
>>
>> --
>> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>
>
> --
> ImageJ mailing list: 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 the pixel Size

Cammer, Michael
In reply to this post by Kenneth Sloan-2
http://rsbweb.nih.gov/ij/developer/macro/functions.html
getVoxelSize(width, height, depth, unit)


=========================================================================
 Michael Cammer, Microscopy Core & Skirball Institute, NYU Langone Medical Center
                      Cell:  914-309-3270     ** Office: Skirball 2nd Floor main office, back right **
          http://ocs.med.nyu.edu/microscopy & http://microscopynotes.com/


-----Original Message-----
From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of Kenneth Sloan
Sent: Monday, February 01, 2016 2:13 PM
To: [hidden email]
Subject: Re: Get the pixel Size

Please excuse me for piggy-backing on this discussion, but…

With the rise in Stack processing - are there similar mechanisms to record, remember, and report back on the depth of voxels?  Simplest would be “getVoxelSize(unit, voxelWidth, voxelHeight, voxelDepth)” - but…I’ll take what I can get.

Pressing my luck - it’s common for slices in a stack to be less regularly spaced than, say, rows in an image.  Is there any mechanism for mapping slice number -> z value?


 

------------------------------------------------------------
This email message, including any attachments, is for the sole use of the intended recipient(s) and may contain information that is proprietary, confidential, and exempt from disclosure under applicable law. Any unauthorized review, use, disclosure, or distribution is prohibited. If you have received this email in error please notify the sender by return email and delete the original message. Please note, the recipient should check this email and any attachments for the presence of viruses. The organization accepts no liability for any damage caused by any virus transmitted by this email.
=================================


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

Re: Get the pixel Size

Kenneth Sloan-2
Thanks.  Any hope for irregular slice spacing?


Kenneth Sloan
[hidden email] <mailto:[hidden email]>
Vision is the art of seeing what is invisible to others.

> On Feb 1, 2016, at 13:22, Cammer, Michael <[hidden email]> wrote:
>
> http://rsbweb.nih.gov/ij/developer/macro/functions.html
> getVoxelSize(width, height, depth, unit)
>
>
> =========================================================================
> Michael Cammer, Microscopy Core & Skirball Institute, NYU Langone Medical Center
>                      Cell:  914-309-3270     ** Office: Skirball 2nd Floor main office, back right **
>          http://ocs.med.nyu.edu/microscopy & http://microscopynotes.com/
>
>
> -----Original Message-----
> From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of Kenneth Sloan
> Sent: Monday, February 01, 2016 2:13 PM
> To: [hidden email]
> Subject: Re: Get the pixel Size
>
> Please excuse me for piggy-backing on this discussion, but…
>
> With the rise in Stack processing - are there similar mechanisms to record, remember, and report back on the depth of voxels?  Simplest would be “getVoxelSize(unit, voxelWidth, voxelHeight, voxelDepth)” - but…I’ll take what I can get.
>
> Pressing my luck - it’s common for slices in a stack to be less regularly spaced than, say, rows in an image.  Is there any mechanism for mapping slice number -> z value?
>
> —
>
>
> ------------------------------------------------------------
> This email message, including any attachments, is for the sole use of the intended recipient(s) and may contain information that is proprietary, confidential, and exempt from disclosure under applicable law. Any unauthorized review, use, disclosure, or distribution is prohibited. If you have received this email in error please notify the sender by return email and delete the original message. Please note, the recipient should check this email and any attachments for the presence of viruses. The organization accepts no liability for any damage caused by any virus transmitted by this email.
> =================================
>
>
> --
> ImageJ mailing list: 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 the pixel Size

Saalfeld, Stephan
In reply to this post by Kenneth Sloan-2
Hi Kenneth,

the Calibration object has a pixelDepth field.

For non-homegeneous z-spacing, I suggest to use TrakEM2 where this is
possible and the norm.  It also has a built in mechanism to calculate
this spacing from aligned serial section image data

http://fiji.sc/Fiji/Z-Spacing_Correction

based on this paper

http://arxiv.org/pdf/1411.6970v2.pdf

Best,
Stephan



On Mon, 2016-02-01 at 13:13 -0600, Kenneth Sloan wrote:

> Please excuse me for piggy-backing on this discussion, but…
>
> With the rise in Stack processing - are there similar mechanisms to record, remember, and report back on the depth of voxels?  Simplest would be “getVoxelSize(unit, voxelWidth, voxelHeight, voxelDepth)” - but…I’ll take what I can get.
>
> Pressing my luck - it’s common for slices in a stack to be less regularly spaced than, say, rows in an image.  Is there any mechanism for mapping slice number -> z value?
>
> —
> Kenneth Sloan
> [hidden email] <mailto:[hidden email]>
> Vision is the art of seeing what is invisible to others.
>
> > On Feb 1, 2016, at 07:45, BenDehap <[hidden email]> wrote:
> >
> > Hello Michael,
> >
> > First thank you for your answer, someone give me a simple way to resolve my
> > problem as following :
> >
> >
> > getPixelSize (unit, pixelWidth, pixelHeight);
> > if (unit=="microns"){
> > x=pixelWidth;}
> > else exit ("No calibration");
> >
> > but i seen that the method you propose is widely used on forums.
> > Would it be possible to show me an example of code using "x" for the value
> > of the pixel witdh and "image1" for the name of my image.
> >
> > I don't know if you have the time to do it, but i'm a coding beginner and i
> > feell a bit lost.
> >
> > Thanks anyway.
> >
> > Ben
> >
> >
> > 2016-02-01 11:15 GMT+01:00 Michael Entrup [via ImageJ] <
> > [hidden email]>:
> >
> >> Hi Ben,
> >>
> >> each ImagePlus [1] has a method called ``getCalibration()``. It returns
> >> the Calibration [2] instance of the ImagePlus. The Calibration Object
> >> contains all the methods you need. ``getUnit()`` returns a String to
> >> check if the unit is µm. ``getX(double x)`` converts a pixel value into
> >> a physical unit.
> >>
> >> Best regards
> >> Michael
> >>
> >> [1]: http://rsb.info.nih.gov/ij/developer/api/ij/ImagePlus.html
> >> [2]: http://rsb.info.nih.gov/ij/developer/api/ij/measure/Calibration.html
> >>
> >>
> >> On 31.01.2016 20:37, BenDehap wrote:
> >>
> >>> Hello,
> >>>
> >>> I have a simple problem and reading different forums didn't help me to
> >>> resolve it.
> >>>
> >>> I need for my ImageJ Plugins to attribute to a variable "x" the value of
> >> the
> >>> pixel size in "µm" used in my pre-calibrated "image1".
> >>>
> >>> It would really help me if someone can help me on this case.
> >>>
> >>> Thanks very much.
> >>>
> >>> Ben
> >>>
> >>>
> >>>
> >>> --
> >>> View this message in context:
> >> http://imagej.1557.x6.nabble.com/Get-the-pixel-Size-tp5015501.html
> >>> Sent from the ImageJ mailing list archive at Nabble.com.
> >>>
> >>> --
> >>> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
> >>>
> >>
> >> --
> >> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
> >>
> >>
> >> ------------------------------
> >> If you reply to this email, your message will be added to the discussion
> >> below:
> >> http://imagej.1557.x6.nabble.com/Get-the-pixel-Size-tp5015501p5015507.html
> >> To unsubscribe from Get the pixel Size, click here
> >> <
> >> .
> >> NAML
> >> <
http://imagej.1557.x6.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
> >>
> >
> >
> >
> >
> > --
> > View this message in context: http://imagej.1557.x6.nabble.com/Get-the-pixel-Size-tp5015501p5015510.html
> > Sent from the ImageJ mailing list archive at Nabble.com.
> >
> > --
> > ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>
>
> --
> ImageJ mailing list: 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 the pixel Size

Kenneth Sloan-2
thank you - this looks perfect.


Kenneth Sloan
[hidden email] <mailto:[hidden email]>
Vision is the art of seeing what is invisible to others.

> On Feb 1, 2016, at 13:28, Saalfeld, Stephan <[hidden email]> wrote:
>
> Hi Kenneth,
>
> the Calibration object has a pixelDepth field.
>
> For non-homegeneous z-spacing, I suggest to use TrakEM2 where this is
> possible and the norm.  It also has a built in mechanism to calculate
> this spacing from aligned serial section image data
>
> http://fiji.sc/Fiji/Z-Spacing_Correction <http://fiji.sc/Fiji/Z-Spacing_Correction>
>
> based on this paper
>
> http://arxiv.org/pdf/1411.6970v2.pdf <http://arxiv.org/pdf/1411.6970v2.pdf>
>
> Best,
> Stephan
>
>
>
> On Mon, 2016-02-01 at 13:13 -0600, Kenneth Sloan wrote:
>> Please excuse me for piggy-backing on this discussion, but…
>>
>> With the rise in Stack processing - are there similar mechanisms to record, remember, and report back on the depth of voxels?  Simplest would be “getVoxelSize(unit, voxelWidth, voxelHeight, voxelDepth)” - but…I’ll take what I can get.
>>
>> Pressing my luck - it’s common for slices in a stack to be less regularly spaced than, say, rows in an image.  Is there any mechanism for mapping slice number -> z value?
>>
>> —
>> Kenneth Sloan
>> [hidden email] <mailto:[hidden email]> <mailto:[hidden email] <mailto:[hidden email]>>
>> Vision is the art of seeing what is invisible to others.
>>
>>> On Feb 1, 2016, at 07:45, BenDehap <[hidden email]> wrote:
>>>
>>> Hello Michael,
>>>
>>> First thank you for your answer, someone give me a simple way to resolve my
>>> problem as following :
>>>
>>>
>>> getPixelSize (unit, pixelWidth, pixelHeight);
>>> if (unit=="microns"){
>>> x=pixelWidth;}
>>> else exit ("No calibration");
>>>
>>> but i seen that the method you propose is widely used on forums.
>>> Would it be possible to show me an example of code using "x" for the value
>>> of the pixel witdh and "image1" for the name of my image.
>>>
>>> I don't know if you have the time to do it, but i'm a coding beginner and i
>>> feell a bit lost.
>>>
>>> Thanks anyway.
>>>
>>> Ben
>>>
>>>
>>> 2016-02-01 11:15 GMT+01:00 Michael Entrup [via ImageJ] <
>>> [hidden email]>:
>>>
>>>> Hi Ben,
>>>>
>>>> each ImagePlus [1] has a method called ``getCalibration()``. It returns
>>>> the Calibration [2] instance of the ImagePlus. The Calibration Object
>>>> contains all the methods you need. ``getUnit()`` returns a String to
>>>> check if the unit is µm. ``getX(double x)`` converts a pixel value into
>>>> a physical unit.
>>>>
>>>> Best regards
>>>> Michael
>>>>
>>>> [1]: http://rsb.info.nih.gov/ij/developer/api/ij/ImagePlus.html
>>>> [2]: http://rsb.info.nih.gov/ij/developer/api/ij/measure/Calibration.html
>>>>
>>>>
>>>> On 31.01.2016 20:37, BenDehap wrote:
>>>>
>>>>> Hello,
>>>>>
>>>>> I have a simple problem and reading different forums didn't help me to
>>>>> resolve it.
>>>>>
>>>>> I need for my ImageJ Plugins to attribute to a variable "x" the value of
>>>> the
>>>>> pixel size in "µm" used in my pre-calibrated "image1".
>>>>>
>>>>> It would really help me if someone can help me on this case.
>>>>>
>>>>> Thanks very much.
>>>>>
>>>>> Ben
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> View this message in context:
>>>> http://imagej.1557.x6.nabble.com/Get-the-pixel-Size-tp5015501.html
>>>>> Sent from the ImageJ mailing list archive at Nabble.com.
>>>>>
>>>>> --
>>>>> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>>>>>
>>>>
>>>> --
>>>> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>>>>
>>>>
>>>> ------------------------------
>>>> If you reply to this email, your message will be added to the discussion
>>>> below:
>>>> http://imagej.1557.x6.nabble.com/Get-the-pixel-Size-tp5015501p5015507.html
>>>> To unsubscribe from Get the pixel Size, click here
>>>> <
>>>> .
>>>> NAML
>>>> <
http://imagej.1557.x6.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>>>>
>>>
>>>
>>>
>>>
>>> --
>>> View this message in context: http://imagej.1557.x6.nabble.com/Get-the-pixel-Size-tp5015501p5015510.html
>>> Sent from the ImageJ mailing list archive at Nabble.com.
>>>
>>> --
>>> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>>
>>
>> --
>> 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 <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 the pixel Size

Michael Entrup
In reply to this post by BenDehap
Hi Ben,

in your first mail you wrote about "my ImageJ Plugins" and that is why I
was assuming you will need information on how to get the pixel size in Java.

If you want to write a macro, the code from your last mail is nearly
everything you need. Just make sure "image1" is selected before running
the macro. If "image1" is the tile of the image, you can use this
modified version:

var x = getNumber("Enter a value for x", 1);
var unit, pixelwidth, pixelHeight;
selectWindow("image1");
getPixelSize (unit, pixelWidth, pixelHeight);
var x_cal = x;
if (unit=="microns"){
        x_cal = pixelWidth * x;
}
else IJ.log("No calibration");
IJ.log("x is "+ x_cal + unit);

To learn how to program macros have a look at [1], [2] and for a command
reference [3].

Best regards
Michael

[1]: http://imagej.net/Introduction_into_Macro_Programming
[2]: http://rsbweb.nih.gov/ij/developer/macro/macros.html
[3]: http://rsbweb.nih.gov/ij/developer/macro/functions.html


On 01.02.2016 14:45, BenDehap wrote:

> Hello Michael,
>
> First thank you for your answer, someone give me a simple way to resolve my
> problem as following :
>
>
> getPixelSize (unit, pixelWidth, pixelHeight);
> if (unit=="microns"){
> x=pixelWidth;}
> else exit ("No calibration");
>
> but i seen that the method you propose is widely used on forums.
> Would it be possible to show me an example of code using "x" for the value
> of the pixel witdh and "image1" for the name of my image.
>
> I don't know if you have the time to do it, but i'm a coding beginner and i
> feell a bit lost.
>
> Thanks anyway.
>
> Ben
>
>
> 2016-02-01 11:15 GMT+01:00 Michael Entrup [via ImageJ] <
> [hidden email]>:
>
>> Hi Ben,
>>
>> each ImagePlus [1] has a method called ``getCalibration()``. It returns
>> the Calibration [2] instance of the ImagePlus. The Calibration Object
>> contains all the methods you need. ``getUnit()`` returns a String to
>> check if the unit is µm. ``getX(double x)`` converts a pixel value into
>> a physical unit.
>>
>> Best regards
>> Michael
>>
>> [1]: http://rsb.info.nih.gov/ij/developer/api/ij/ImagePlus.html
>> [2]: http://rsb.info.nih.gov/ij/developer/api/ij/measure/Calibration.html
>>
>>
>> On 31.01.2016 20:37, BenDehap wrote:
>>
>>> Hello,
>>>
>>> I have a simple problem and reading different forums didn't help me to
>>> resolve it.
>>>
>>> I need for my ImageJ Plugins to attribute to a variable "x" the value of
>> the
>>> pixel size in "µm" used in my pre-calibrated "image1".
>>>
>>> It would really help me if someone can help me on this case.
>>>
>>> Thanks very much.
>>>
>>> Ben
>>>
>>>
>>>
>>> --
>>> View this message in context:
>> http://imagej.1557.x6.nabble.com/Get-the-pixel-Size-tp5015501.html
>>> Sent from the ImageJ mailing list archive at Nabble.com.
>>>
>>> --
>>> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>>>
>>
>> --
>> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>>
>>
>> ------------------------------
>> If you reply to this email, your message will be added to the discussion
>> below:
>> http://imagej.1557.x6.nabble.com/Get-the-pixel-Size-tp5015501p5015507.html
>> To unsubscribe from Get the pixel Size, click here
>> <
>> .
>> NAML
>> <
http://imagej.1557.x6.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>>
>
>
>
>
> --
> View this message in context: http://imagej.1557.x6.nabble.com/Get-the-pixel-Size-tp5015501p5015510.html
> Sent from the ImageJ mailing list archive at Nabble.com.
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

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