Unable to set min,max values correctly on density calibrated 8-bit images

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

Unable to set min,max values correctly on density calibrated 8-bit images

Stein Rørvik
There is a small bug when using the setMinAndMax(min,max) function for some density calibrated 8-bit images.

When using resetMinAndMax(), the min-max range is correctly set to the minimum / maximum value.
But when using setMinAndMax(min,max) with the same values, the result min,max values are lower.
This seems to be due to a round-off error as the latter case corresponds to a 0..254 range instead of 0..255
If you change the calibrated max value to 69300 in the below example it works as it should.

Demo macro:
--------------------------------------------------
print("\\Clear");
run("Blobs (25K)");
run("Calibrate...", "function=[Straight Line] unit=[Gray Value] text1=[0 255] text2=[0 69400]");  //set rescale slope on full range
resetMinAndMax();
getMinAndMax(min,max);          //0 69400
print("case 1: ", bitDepth,min,max);
setMinAndMax(min,max);          //0 69400
getMinAndMax(min,max);          //0 69127.8431 = (69400/255)*254
print("case 2: ", bitDepth,min,max);
--------------------------------------------------
The same behaviour is seen when using the GUI:

B&C -> Reset => range 0..69400
B&C -> Set (0, 69400) => range 0..69127.8431

I am using daily build ImageJ 1.52o with Java 1.6 on Windows 7/64-bit.

Stein


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

Re: Unable to set min,max values correctly on density calibrated 8-bit images

Wayne Rasband-2
> On Mar 30, 2019, at 3:04 PM, Stein Rørvik <[hidden email]> wrote:
>
> There is a small bug when using the setMinAndMax(min,max) function for some density calibrated 8-bit images.

This setMinAndMax(min,max) rounding error is fixed in the latest ImageJ daily build (1.52o12).

-wayne

> When using resetMinAndMax(), the min-max range is correctly set to the minimum / maximum value.
> But when using setMinAndMax(min,max) with the same values, the result min,max values are lower.
> This seems to be due to a round-off error as the latter case corresponds to a 0..254 range instead of 0..255
> If you change the calibrated max value to 69300 in the below example it works as it should.
>
> Demo macro:
> --------------------------------------------------
> print("\\Clear");
> run("Blobs (25K)");
> run("Calibrate...", "function=[Straight Line] unit=[Gray Value] text1=[0 255] text2=[0 69400]");  //set rescale slope on full range
> resetMinAndMax();
> getMinAndMax(min,max);          //0 69400
> print("case 1: ", bitDepth,min,max);
> setMinAndMax(min,max);          //0 69400
> getMinAndMax(min,max);          //0 69127.8431 = (69400/255)*254
> print("case 2: ", bitDepth,min,max);
> --------------------------------------------------
> The same behaviour is seen when using the GUI:
>
> B&C -> Reset => range 0..69400
> B&C -> Set (0, 69400) => range 0..69127.8431
>
> I am using daily build ImageJ 1.52o with Java 1.6 on Windows 7/64-bit.
>
> Stein

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