# Image Calculator Behavior

Dear Community,

We’ve recently encountered an interesting behavior with the image calculator, which is causing a bit of an inconsistency problem.
Consider Images A and B as shown here

Performing “A Add B” Yields the following image

So the behavior is “The newly returned image has the smallest dimensions of the two images”.

This behavior is the same if we have an image that is larger than the other in both dimensions
Suppose we have an image (C) that is 200x200 and another (D) that is 100x100, then the result of an Image Calculator Operation will be 100x100, No matter the order of the operation. So C/D is the same as D+C in terms of resulting image dimensions.

If we do this with an image and a stack, however the results are a bit inconsistent
Let’s say we have a stack X and a normal image Y, of different sizes

Doing “X Add Y” creates a new stack of the same size as X

but the operation “Y Add X” outputs a single image that follows the rule outlined above.

And this image is obtained by performing the “Add” operation between Y and the currently active slice of X

Personally I was kind of hoping that all of the calculations that I showed here would not be allowed!

It is rather inconsistent to want to perform calculations on images of different sizes, so even though the code can take it, i’d opt for this sort of output not being allowed.

Operations should be allowed if

1. Images have identical dimensions
2. Applying one slice to a stack, so long as the XY dimensions match

I don’t know, has anyone got any use cases where it would make sense / be necessary to perform Image Calculator operations on images with different XY dimensions?

 @Wayne, what do you think? I see that the code is within the ImageJ1 part so I am not sure I can contribute directly or whether this is warranted, as it might break backwards compatibility…

Best

Oli

5 Likes

Fully agree with you, fully.

1 Like

Hello oburri,
The image calculator averages the size of the images or the smaller of the two if linear dimentions. The way around this is to go to Edit > Scale and set the scale of one image to the other so that they match.
Either way you will get errors in the result.
Bob