Login  Register

Re: standardize an image

Posted by Michael Schmid on Oct 09, 2013; 5:59pm
URL: http://imagej.273.s1.nabble.com/standardize-an-image-tp5005105p5005109.html

Hi Stanislav,

looks like a task for a simple macro:

run("32-bit");  //convert to floating-point data
setThreshold(1e-30, 1e30);
run("Create Selection");  //select only pixels with value>0
getStatistics(area, mean, min, max, std);
run("Subtract...", "value=&mean");
run("Divide...", "value=&std");
run("Max...", "value=4.5");  //limit pixel values
run("Min...", "value=-4.5");
resetMinAndMax();  //display actual range of pixel values
//setMinAndMax(-4.5000, 4.5000); //alternatively, use this for 0-255
run("Conversions...", "scale weighted"); //use displayed range
run("8-bit"); //Conversion to to 8 bits per pixel

If you want to keep the original image, duplicate it before starting.
To determine how to do this in a macro, use Process>Macros>Record and do the operation manually.

Michael
________________________________________________________________


On Oct 9, 2013, at 16:55, Stanislav Aggerwal wrote:

> I would like to do the following, which I give below in pseudocode.
>
> Let's call the image z
> znew=standardize(z)
>
> standardize(z)
> {
> zz = (z[z>0]-mean(z[z>0]))/sd(z[z>0])
> #where z[z>0] means the pixels that have greylevels >0
> zz[zz>4.5] = 4.5
> zz[zz< -4.5] = -4.5
> zz=rescale(zz, 0, 255)   #rescale the zz values to be in the range (0,255)
> return(zz)
> }
>
> Could someone please tell me how to do this with ImageJ/Fiji?
>
> Thanks very much for any help.
>
> Stan
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html

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