# Beginner needs a short macro

3 messages
Open this post in threaded view
|
Report Content as Inappropriate

## Beginner needs a short macro

 I would be grateful if someone would write a macro as show below. I've read the macro document but don't see a way to implement a math formula on two opened 16 bit .FIT images. The following method is used to calculate the Degree of Linear Polarization by working on two images: Image1 taken through a linear polarizer set to 0 degrees and Image2 set at 90 degrees. Calculate new values for each pixel as below: (Image1pixel value - Image2pixelvalue) / (Image1pixel value + Image2pixelvalue) Then the resulting image is: Normalized and stretched so it fills the whole 16 bit range of pixel brightness values.   Once I see how this works I will be able to modify it further as needed! Thanks!   Deane -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Open this post in threaded view
|
Report Content as Inappropriate

## Re: Beginner needs a short macro

 Hi Deane Actually if you have the Image Expression Parser plugin (comes with Fiji http://fiji.sc/, a distribution of ImageJ, very recommended), you can achieve this in one line (supposing the two images' window titles are Image1 and Image2): run("Image Expression Parser (Macro)", "expression=(A-B)/(A+B) a=[Image1] b=[Image2] c=[(A - B) / (A + B)]"); Cheers Thomas On 7 June 2017 at 14:32, D Williams <[hidden email]> wrote: > I would be grateful if someone would write a macro as show below. > > I've read the macro document but don't see a way to implement a math > > formula on two opened 16 bit .FIT images. > > The following method is used to calculate the Degree of Linear Polarization > by > > working on two images: Image1 taken through a linear polarizer set to 0 > degrees > > and Image2 set at 90 degrees. > > Calculate new values for each pixel as below: > > (Image1pixel value - Image2pixelvalue) / (Image1pixel value + > Image2pixelvalue) > > Then the resulting image is: > > Normalized and stretched so it fills the whole 16 bit range of pixel > brightness values. > > > > Once I see how this works I will be able to modify it further as needed! > > Thanks! > > > > Deane > > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html> -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html