math functions' point of view

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

math functions' point of view

Jarek Grodek
Hi,

I'm newbie to ImageJ and wondering is there a possibility to make it to
create an artificial image according to specified mathematic function,
e.g. y=2x^2+b.
If there is a chance to do it, is it possible to re-construct real image
into artificial one? Or maybe there is known plug-in which can modify
real image in mentioned conditions?

Thanks in advance

Jarek Grodek
Reply | Threaded
Open this post in threaded view
|

Re: math functions' point of view

Wayne Rasband
> I'm newbie to ImageJ and wondering is there a possibility to make it
> to create an artificial image according to specified mathematic
> function, e.g. y=2x^2+b.
> If there is a chance to do it, is it possible to re-construct real
> image into artificial one? Or maybe there is known plug-in which can
> modify real image in mentioned conditions?

Ulf Dittmer's Expression and ExpressionNT plugins at
<http://www.ulfdittmer.com/imagej/expression.html> apply user-specified
formulas to each pixel in an image. They can be used to alter existing
images or to create synthetic images.

-wayne
 
Reply | Threaded
Open this post in threaded view
|

Re: math functions' point of view

Jarek Grodek
Wayne Rasband napisał(a):

>> I'm newbie to ImageJ and wondering is there a possibility to make it
>> to create an artificial image according to specified mathematic
>> function, e.g. y=2x^2+b.
>> If there is a chance to do it, is it possible to re-construct real
>> image into artificial one? Or maybe there is known plug-in which can
>> modify real image in mentioned conditions?
>
> Ulf Dittmer's Expression and ExpressionNT plugins at
> <http://www.ulfdittmer.com/imagej/expression.html> apply
> user-specified formulas to each pixel in an image. They can be used to
> alter existing images or to create synthetic images.
>
> -wayne
>  
>
>
>
Thanks a lot, i'll check it.

jarek
Reply | Threaded
Open this post in threaded view
|

Re: math functions' point of view

dscho
In reply to this post by Jarek Grodek
Hi,

On Tue, 14 Feb 2006, Jarek wrote:

> I'm newbie to ImageJ and wondering is there a possibility to make it to
> create an artificial image according to specified mathematic function,
> e.g. y=2x^2+b.

You mean a new image, right? How about this macro:

-- snip --
xMin = -5; xMax = 5; yMin = -5; yMax = 5;
width = 400; height = 400;

function f(x) {
        return 2 * x * x - 3;
}

newImage("Math", "8-bit White", width, height 1);
for (i = 0; i < width; i++) {
        x = xMin + i * (xMax - xMin) / (width - 1);
        y = f(x);
        j = height - 1 - (y- yMin) * (height - 1) / (yMax - yMin);
        if (j >= 0 && j < height)
                setPixel(i, j, 0);
}
-- snap --

> If there is a chance to do it, is it possible to re-construct real image into
> artificial one?

You want to fit data to a function? That probably requires more knowledge
about the function, but should be feasible.

Ciao,
Dscho
Reply | Threaded
Open this post in threaded view
|

Re: math functions' point of view

Wayne Rasband
> I'm newbie to ImageJ and wondering is there a possibility to
> make it to create an artificial image according to specified
> mathematic function, e.g. y=2x^2+b.

Here is a macro that uses a math function to generate an image.

-wayne

   width = 500; height = 500;
   xc = width/2; yc = height/2;
   newImage("Math", "32-bit", 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);}
Reply | Threaded
Open this post in threaded view
|

Re: math functions' point of view

Nikos Katsikanis
In reply to this post by Jarek Grodek
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.
Reply | Threaded
Open this post in threaded view
|

Re: math functions' point of view

Jarek Grodek
In reply to this post by Wayne Rasband
Wayne Rasband napisał(a):

>> I'm newbie to ImageJ and wondering is there a possibility to
>> make it to create an artificial image according to specified
>> mathematic function, e.g. y=2x^2+b.
>
> Here is a macro that uses a math function to generate an image.
>
> -wayne
>
>   width = 500; height = 500;
>   xc = width/2; yc = height/2;
>   newImage("Math", "32-bit", 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);}
>
>
>
WOW!

Wayne, thank you very much, i'm impressed of your help. This is exactly
what i was looking for: the example of macro construction.
Greetings

jarek
Reply | Threaded
Open this post in threaded view
|

Re: math functions' point of view

Wayne Rasband
In reply to this post by Nikos Katsikanis
> 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);}
Reply | Threaded
Open this post in threaded view
|

Re: math functions' point of view

Liu, Dongfang (NIH/NIAID) [F]
In reply to this post by Jarek Grodek
you mean, using this equation(y=2x^2+b) fit the real image?

> ----------
> From: Jarek
> Reply To: List IMAGEJ
> Sent: Tuesday, February 14, 2006 8:32 AM
> To: List IMAGEJ
> Subject: math functions' point of view
>
> Hi,
>
> I'm newbie to ImageJ and wondering is there a possibility to make it to
> create an artificial image according to specified mathematic function,
> e.g. y=2x^2+b.
> If there is a chance to do it, is it possible to re-construct real image
> into artificial one? Or maybe there is known plug-in which can modify
> real image in mentioned conditions?
>
> Thanks in advance
>
> Jarek Grodek
>
Reply | Threaded
Open this post in threaded view
|

Re: math functions' point of view

Robert Dougherty
Polynomial Fit does something like this.

Bob

Robert P. Dougherty, Ph.D.
President, OptiNav, Inc.
Phone (425) 467-1118
Fax (425) 467-1119
www.optinav.com
 

> -----Original Message-----
> From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of Liu,
> Dongfang (NIH/NIAID) [E]
> Sent: Saturday, February 18, 2006 7:15 AM
> To: [hidden email]
> Subject: Re: math functions' point of view
>
> you mean, using this equation(y=2x^2+b) fit the real image?
>
> > ----------
> > From: Jarek
> > Reply To: List IMAGEJ
> > Sent: Tuesday, February 14, 2006 8:32 AM
> > To: List IMAGEJ
> > Subject: math functions' point of view
> >
> > Hi,
> >
> > I'm newbie to ImageJ and wondering is there a possibility to make it to
> > create an artificial image according to specified mathematic function,
> > e.g. y=2x^2+b.
> > If there is a chance to do it, is it possible to re-construct real image
> > into artificial one? Or maybe there is known plug-in which can modify
> > real image in mentioned conditions?
> >
> > Thanks in advance
> >
> > Jarek Grodek
> >
Reply | Threaded
Open this post in threaded view
|

Re: math functions' point of view

Jarek Grodek
In reply to this post by Liu, Dongfang (NIH/NIAID) [F]
Liu, Dongfang (NIH/NIAID) [E] napisał(a):

> you mean, using this equation(y=2x^2+b) fit the real image?
>
>  
>> ----------
>> From: Jarek
>> Reply To: List IMAGEJ
>> Sent: Tuesday, February 14, 2006 8:32 AM
>> To: List IMAGEJ
>> Subject: math functions' point of view
>>
>> Hi,
>>
>> I'm newbie to ImageJ and wondering is there a possibility to make it to
>> create an artificial image according to specified mathematic function,
>> e.g. y=2x^2+b.
>> If there is a chance to do it, is it possible to re-construct real image
>> into artificial one? Or maybe there is known plug-in which can modify
>> real image in mentioned conditions?
>>
>> Thanks in advance
>>
>> Jarek Grodek
>>
>>    
>
>
>
>  
What i meant was: let's take the picture of an object i.e.  
non-destructive technique examined material with internal defect. Object
of examination is not flat, let' s say it is a double roll, so when we
exponent tis object to x-ray projection we receive an image of which
line plot will look like an absolut value of sinus function. so the
defect area (ROI) will be darker than the rest of the image. what i
meant is: how to reconstruct the grey value profile of this ROI to
undefected? and how to do it in xy orientation? the best example would
be if i present an image, afraid it will not be destributed through
LIST.NIH server. the formula y=2x..... was just an example, what i'm
interested in to construct the plugin. I'm not involved with JAVA
programing, and JAVA token is still maybe not "black" but "black shade
of magic" for me.
Wayne responded with Expression plugin info, i think it's propably what
i'm looking for, but still have problem with making it work for me.

greetings,

Jarek