Login  Register

Re: math functions' point of view

Posted by Wayne Rasband on Feb 15, 2006; 2:51pm
URL: http://imagej.273.s1.nabble.com/math-functions-point-of-view-tp3703556p3703561.html

> On my computer I find that when I use this marcro the plot
> profile of the images has inverted pixel values. For example
> black colours give me high pixel values in the plot profile.
> When I cut a part of this generated image and paste it into
> an other window i.e a sample picture with same image format,
> the normal plot profile occurs.

You are seeing inverted pixel values because the image created by the
macro has an inverting lookup table. You can fix this by changing the
third line of the macro from

   newImage("Math", "32-bit", width, height, 1);

to

   newImage("Math", "32-bit black", width, height, 1);

In ImageJ 1.35q and later, the default color for 16 and 32 bit images
will be black instead of white.

I have attached the complete macro.

-wayne

   width = 500; height = 500;
   xc = width/2; yc = height/2;
   newImage("Math", "32-bit black", width, height, 1);
   for (y= 0; y<height; y++) {
       for (x= 0; x<width; x++) {
           xx = sqrt ((x-xc)*(x-xc)+(y-yc)*(y-yc));
           setPixel(x, y, f1(xx));
       }
       if (y%20==0) showProgress(y, height);
   }
   resetMinAndMax();
   makeLine(0, 0, width, height);
   run("Plot Profile");
   exit;

   function f1(x) {return 2*x*x-3;}
   function f2(x) {return cos(x/10);}
   function f3(x) {return sqrt(x);}
   function f4(x) {if (x==0) return 0; else return log(x);}
   function f5(x) {return exp(x/100);}