Login  Register

how to get Pixel Width from Properties... ?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options Options
Embed post
Permalink
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

how to get Pixel Width from Properties... ?

M.Gbarin
hallo,

I try to write a java code to get a Pixel width from ImageJ ( Image->Properties...) !!
can someone help me ?!

when I wrote -- IJ.run("Properties..."); -- I became the propereties window but I could not save the Pixel Width in a variable !

where can be the problem ?
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: how to get Pixel Width from Properties... ?

Herbie-2
Hallo hallo,

in a IJ-macro you could use:
        getPixelSize(unit, pixelWidth, pixelHeight);

HTH

Herbie

On 11.12.12 12:57, M.Gbarin wrote:

> hallo,
>
> I try to write a java code to get a Pixel width from ImageJ (
> Image->Properties...) !!
> can someone help me ?!
>
> when I wrote -- IJ.run("Properties..."); -- I became the propereties window
> but I could not save the Pixel Width in a variable !
>
> where can be the problem ?
>
>
>
> --
> View this message in context: http://imagej.1557.n6.nabble.com/how-to-get-Pixel-Width-from-Properties-tp5001114.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
| More
Print post
Permalink

RE: how to get Pixel Width from Properties... ?

M.Gbarin


Hi Herbie,

thanks for your answer.
But I have a IJ-Plugin not a IJ-macro..!
how or where can I get this functios (getPixelSize();) ?

Thanks a lot,
Mahmud


Date: Tue, 11 Dec 2012 07:25:40 -0800
From: [hidden email]
To: [hidden email]
Subject: Re: how to get Pixel Width from Properties... ?

Hallo hallo,

in a IJ-macro you could use:
        getPixelSize(unit, pixelWidth, pixelHeight);

HTH

Herbie

On 11.12.12 12:57, M.Gbarin wrote:

> hallo,
>
> I try to write a java code to get a Pixel width from ImageJ (
> Image->Properties...) !!
> can someone help me ?!
>
> when I wrote -- IJ.run("Properties..."); -- I became the propereties window
> but I could not save the Pixel Width in a variable !
>
> where can be the problem ?
>
>
>
> --
> View this message in context: http://imagej.1557.n6.nabble.com/how-to-get-Pixel-Width-from-Properties-tp5001114.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.n6.nabble.com/how-to-get-Pixel-Width-from-Properties-tp5001114p5001117.html
To unsubscribe from how to get Pixel Width from Properties... ?, click here.
NAML
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: how to get Pixel Width from Properties... ?

Herbie-2
Mahmud,

you may have a look at "IJ.runMacro()" or "IJ.runMacroFile()".

 From the Java class that implements the built-in macro functions:

void getPixelSize() {
                Variable unit = getFirstVariable();
                Variable width = getNextVariable();
                Variable height = getNextVariable();
                Variable depth = null;
                if (interp.nextToken()==',')
                        depth = getNextVariable();
                interp.getRightParen();
                Calibration cal = getImage().getCalibration();
                unit.setString(cal.getUnits());
                width.setValue(cal.pixelWidth);
                height.setValue(cal.pixelHeight);
                if (depth!=null)
                depth.setValue(cal.pixelDepth);
}

HTH

Herbie


On 11.12.12 18:11, M.Gbarin wrote:

> Hi Herbie,
> thanks for your answer.But I have a IJ-Plugin not a IJ-macro..!how or where can I get this functios (getPixelSize();) ?
> Thanks a lot,Mahmud
> Date: Tue, 11 Dec 2012 07:25:40 -0800
> From: [hidden email]
> To: [hidden email]
> Subject: Re: how to get Pixel Width from Properties... ?
>
>
>
> Hallo hallo,
>
>
> in a IJ-macro you could use:
>
>          getPixelSize(unit, pixelWidth, pixelHeight);
>
>
> HTH
>
>
> Herbie
>
>
> On 11.12.12 12:57, M.Gbarin wrote:
>
>> hallo,
>
>>
>
>> I try to write a java code to get a Pixel width from ImageJ (
>
>> Image->Properties...) !!
>
>> can someone help me ?!
>
>>
>
>> when I wrote -- IJ.run("Properties..."); -- I became the propereties window
>
>> but I could not save the Pixel Width in a variable !
>
>>
>
>> where can be the problem ?
>
>>
>
>>
>
>>
>
>> --
>
>> View this message in context: http://imagej.1557.n6.nabble.com/how-to-get-Pixel-Width-from-Properties-tp5001114.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.n6.nabble.com/how-to-get-Pixel-Width-from-Properties-tp5001114p5001117.html
>
>
>
> To unsubscribe from how to get Pixel Width from Properties... ?, click here.
>
> NAML
>  
>
>
>
> --
> View this message in context: http://imagej.1557.n6.nabble.com/how-to-get-Pixel-Width-from-Properties-tp5001114p5001118.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
| More
Print post
Permalink

Re: how to get Pixel Width from Properties... ?

Jan Eglinger
In reply to this post by M.Gbarin
Hi Mahmud,

to get calibration data like the pixel size within an ImageJ plugin, you
can use:

ImagePlus imp = IJ.getImage();
Double pixelWidth = imp.getCalibration().pixelWidth;

The ImageJ API reference is a very useful source for that kind of
information:

http://rsbweb.nih.gov/ij/developer/api/index.html
http://rsbweb.nih.gov/ij/developer/api/ij/measure/Calibration.html

Hope that helps,
Jan


On 11.12.2012 6:11 PM, M.Gbarin wrote:

> Hi Herbie,
> thanks for your answer.But I have a IJ-Plugin not a IJ-macro..!how or where can I get this functios (getPixelSize();) ?
> Thanks a lot,Mahmud
> Date: Tue, 11 Dec 2012 07:25:40 -0800
> From: [hidden email]
> To: [hidden email]
> Subject: Re: how to get Pixel Width from Properties... ?
>
>
>
> Hallo hallo,
>
>
> in a IJ-macro you could use:
>
>         getPixelSize(unit, pixelWidth, pixelHeight);
>
>
> HTH
>
>
> Herbie
>
>
> On 11.12.12 12:57, M.Gbarin wrote:
>
>> hallo,
>
>>
>
>> I try to write a java code to get a Pixel width from ImageJ (
>
>> Image->Properties...) !!
>
>> can someone help me ?!
>
>>
>
>> when I wrote -- IJ.run("Properties..."); -- I became the propereties window
>
>> but I could not save the Pixel Width in a variable !
>
>>
>
>> where can be the problem ?
>
>>

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

Re: how to get Pixel Width from Properties... ?

M.Gbarin


@Herbie thanks a lot for your help

@Jan thank you very much this is exactly what I wanted :)