Harry B
Harry B

Reputation: 371

Multiplying two images together in ImageJ

I'd like to do some image processing in FIJI / ImageJ but not sure how to go about it. I have a first image, call it "imageA" and would like to perform several operations on it. I know you can go to Process->Math and have some options for operations (add subtract multlipy etc) and there is a tool for writing a macro so that you can combine a few operations into one step, but I'm not sure how to approach it for adding in a second image which I'd like to include in the operation.

I'd like to take imageA and multiply it by a second image of the same size, imageB, together with a few other steps which are outlined in the function below:

output image = sqrt((constant*constant) + (constant2*constant2) + (imageB*imageB))

Image A * Output Image.

The constants are pretty straightforward inputs that I can simply add, but I'm not sure how to make it so imageB is also included in the function to produce the final output that I will then apply to imageA.

Upvotes: 0

Views: 4026

Answers (1)

Louis Leung
Louis Leung

Reputation: 508

The approach is to first open "imageB", perform the operations (using Process > Math) to create the "Output image", open "imageA" and then use the Process > Image Calculator, selecting imageA and Output image with the multiply operation.

In the ImageJ macro language, it will look something like this:

//open imageB
open("LOCATIONOFIMAGEB");
//square ImageB
run("Square");
//add your constants to image
run("Add...", "value=CONSTANT1"); //Constant1 should be an integer
run("Add...", "value=CONSTANT2"); //Constant2 should be an integer
//squareroot to make your outputImage
run("Square Root");
//open ImageA
open("LOCATIONOFIMAGEA");
//multiple images
imageCalculator("Multiply create", "WINDOWTITLEOFIMAGEA","WINDOWTITLEOFIMAGEB");

Insert the relevant constants, location of images and windowTitles and it should work...

Upvotes: 1

Related Questions