Posted by
Pål Baggethun on
Oct 09, 2013; 12:10pm
URL: http://imagej.273.s1.nabble.com/Plot-getProcessor-vs-profile-plot-preferences-tp5005082p5005100.html
Oh yes, I forgot about the margins. It now works perfectly well for my application. Thank you very much.
Paul
-----Original Message-----
From: ImageJ Interest Group [mailto:
[hidden email]] On Behalf Of Rasband, Wayne (NIH/NIMH) [E]
Sent: 9. oktober 2013 02:10
To:
[hidden email]
Subject: Re: Plot.getProcessor() vs. profile plot preferences
On Oct 8, 2013, at 6:58 AM, Pål Baggethun wrote:
> Plot.getprocessor() returns an ImageProcessor that has different dimensions from those defined in the profile plot preferences pp.with and pp.height. Is this intentional?
You have to the add the plot margins, as this JavaScript example does:
w = h = 400;
Xval = [1];
Yval = [1];
p = new Plot("", "Test Plot PixelSize", "X", "Y", Xval, Yval);
p.setFrameSize(w, h);
ip = p.getProcessor();
print("width: "+ (w + Plot.LEFT_MARGIN + Plot.RIGHT_MARGIN));
print("height: "+ (h + Plot.TOP_MARGIN + Plot.BOTTOM_MARGIN));
print(ip);
This is the output:
width=478
height=455
ip[width=478, height=455, bits=8, min=0.0, max=255.0]
This example uses the setFrameSize() method to specify the plot size, which is better than changing "Width" and "Height" in Edit>Options>Profile Plot Options.
-wayne
> The test plugin below writes the following to my log:
> Plot ImageProcessor:
> getWith()=478
> getHeight()=455
> Plot Options:
> pp.width=400
> pp.height=400
>
> Sincerely,
> Pål Baggethun
> Research Engineer
> Elkem Technology
>
> TEST PLUGIN:
>
> import ij.*;
> import ij.process.*;
> import ij.gui.*;
> import ij.plugin.*;
> import ij.plugin.frame.*;
>
> public class Test_Plot_PixelSize implements PlugIn {
>
> public void run(String arg) {
>
> float[] Xval = new float[1];
> float[] Yval = new float[1];
>
> Plot p = new Plot( "Test Plot PixelSize", "X", "Y", Xval, Yval);
> ImageProcessor ip = p.getProcessor();
>
> IJ.log(
> "\nPlot ImageProcessor:\n getWith()="+ip.getWidth()+
> "\n getHeight()="+ip.getHeight()+
> "\n \nPlot Options:\n pp.width="+Prefs.getInt("pp.width",1)+
> "\n pp.height="+Prefs.getInt("pp.height",1)
> );
>
> }
>
> }
>
> MY JAVA PROPERTIES:
>
> java.version: 1.7.0_40
> java.vendor: Oracle Corporation
> os.name: Windows 7
> os.version: 6.1
> os.arch: amd64
> file.separator: \
> path.separator: ;
> line.separator: <cr><lf>
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.htmlNOTICE: Please immediately e-mail back to sender if you are not the intended recipient. Thereafter delete the e-mail along with any attachments without making copies. The sender reserves all rights of privilege, confidentiality and copyright.
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html