Re: Problem with setCalibration() and getCalibration

Posted by Dawid Krzempek on
URL: http://imagej.273.s1.nabble.com/Problem-with-setCalibration-and-getCalibration-tp5010425p5010431.html

Yes, you're right. It will be very useful for me, so thank you.

But even when I use setFunction() and write analogous code:

*                float [] param={146494f,3.55146f,2079.82f};*
*                Calibration calibr=new Calibration();*
*                float a=param[0];*
*                float b=param[1];*
*                float c=param[2];*
*                double b0=1.0;                double c0=-c;
double d0=-b;                double a0=-d0+a/c0;                double []
coef={a0,b0,c0,d0};
calibr.setFunction(Calibration.RODBARD,coef,"Gy");
img.setCalibration(calibr);
System.out.println(calibr.calibrated());
System.out.println(img.getCalibration().calibrated());*

the output is still 'true false'. So there is no problem in calibration
method, but with setCalibration(). *calib* seems to be not associated with
img.

img.setGlobalCalibration(calib) is not working properly too. I still dont
see 'value=650 (6500)'.

I still have to calibrate from code level, not from GUI level, because via
GUI I can't enforce values of coefficients, ImageJ requires fitting.
Best regards
David

2014-11-13 19:36 GMT+01:00 Michael Schmid <[hidden email]>:

> Hi David,
>
> to me it looks like you can use the built-in RODBARD function in your case
> anyhow:
>
> RODBARD:  y = d + (a-d)/(1+(x/c)^b) = d + (a-d)*c^b / (c^b+x^b)
>
> You have  y = -b + a/(x-c)
>
> If I got it right, the Rodbard parameters are
>
> b = 1
> d = -your_b
> c = -your_c
> a - d = your_a / c
>
> Nevertheless, if you see something like 'value=650 (6500)' in the status
> line, it means that your image is calibrated, the calibrated value is 650,
> the raw pixel value is 6500.
>
> Michael
> ________________________________________________________________
>
>
> On Nov 13, 2014, at 18:59, Dawid Krzempek wrote:
>
> > Thanks for your reply. Now I understand, but it's not the end of my
> problems. :)
> >
> > As you can see from my code, I try to calibrate image using values
> (table), not by function - my function is different than any of available
> in ImageJ.
> >
> > But when I calibrate like this, image after display it is not
> calibrated. I use calib in setCalibration() or setGlobalCalibration() -
> both are not working.
> > When Global calibration is using, there are some "tracks" of
> calibration. For example, when I am trying to open another Image, I get:
> > "The calibration of this image conflicts with the current global
> calibration...."
> > But in fact image is not calibrated. Information about pixel doesn't
> seem like that:
> > x=0, y=10 value=650 (6500)
> > It seems like that:
> > x=0, y=10 value=6500
> > So I don't have any information about calibrated value.
> > I have no idea, what I am doing wrong.
> > Maybe the function is obligatory to make ImageProcessor calibration
> possible?
> > Thanks in advance
> > David
> >
> > 2014-11-13 18:32 GMT+01:00 Michael Schmid <[hidden email]>:
> > Hi Wayne, David,
> >
> > looks like an unintended behavior in Calibration, currently calibrated()
> only checks for a function, not for a table (line 283...):
> >
> >     /** Returns true if this image is density calibrated. */
> >     public boolean calibrated() {
> >         return function!=NONE;
> >     }
> >
> >
> > I think that it should be
> > ...
> >         return function!=NONE || cTable != null;
> >
> >
> > Best regards,
> >
> > Michael
> > ________________________________________________________________
> > Michael Schmid                    email: [hidden email]
> > Institut für Angewandte Physik, Technische Universität Wien
> > Wiedner Hauptstr. 8-10/E134, A 1040 Wien, Austria
> > Tel. +43 1 58801-13452 or -13453, Fax +43 1 58801 13499
> > ________________________________________________________________
> >
> > On Nov 13, 2014, at 18:10, Dawid Krzempek wrote:
> >
> > > Hello,
> > > I am writing some Imagej plugin and have few problems with value
> calibration.
> > > I am not experienced in writing programs like this one, so the
> solution can be very simple.
> > >
> > > I try to calibrate ImagePlus. There is my code (img1 is ImagePlus
> object)
> > >
> > >                float [] param={146494f,3.55146f,2079.82f};
> > >                float cTable[]=new float[65536];
> > >                Calibration calibr=new Calibration();
> > >                float a=param[0];
> > >                float b=param[1];
> > >                float c=param[2];
> > >                for (int i=0;i<65536;i++){
> > >                    float value=-b+a/(i-c);
> > >                    if (value>10) cTable[i]=10;
> > >                    else if (value<0) cTable[i]=0;
> > >                    else cTable[i]=value;
> > >                }
> > >                calibr.setCTable(cTable,"Gy");
> > >                System.out.println(calibr.calibrated());
> > >                img1.setCalibration(calibr);;
> > >                System.out.println(img1.getCalibration().calibrated());
> > >
> > > The output then:
> > >
> > > true
> > > false
> > >
> > > setCalibration() seems not working. Image is not calibrated after
> using this method. I was expected "true true" output Could somebody tell
> me, where is my mistake?
> > > The goal of calibration is working on calibrated (Gy) values, not on
> signal values. Is there any other way to achieve it?
> > > Thanks for your help
> > > David
> > >
> > > --
> > > ImageJ mailing list: http://imagej.nih.gov/ij/list.html
> >
> >
>
>

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