Collapse 16-bit RGB to single grayscale

My goal is to convert a 3 channel 16-bit RGB image into a single channel 16-bit image of average intensity gray values.
Using the GUI I do:
[Stk] button with red arrow triangle down | Z-project | Average Intensity [OK]
In the MacroRecorder that gives me only :


I believe that is wrong as when running


on a the same image it only applies the gray LUT to the Red channel.
If I do in GUI: Image | Stacks| Z-Project it again only records


There must be more happening in the background when using the Z-Project command.
How can I implement this in my own macro as the MacroRecorder is apparently not helping me?
I also would like a way to influence the options in the ZProjection window.
Is there a better way to achieve my original goal?
My current strategy would be, to split channels; Image | Color | Split Channel then divide each channel by 3 then add them sequentially using Image calculator.
Something like this (but “made generic”

run("Split Channels");
run("Divide...", "value=3");
run("Divide...", "value=3.000000");
run("Divide...", "value=3.000000");
run("Image Calculator...");
imageCalculator("Add create 32-bit", "C1-100xV_0003.tif","C2-100xV_0003.tif");
imageCalculator("Add create 32-bit", "Result of C1-100xV_0003.tif","C3-100xV_0003.tif");

At this time I do not understand that adding the 3 intermediate images gives me an intensity in the 40000s while the Z-project workflow gives me an image AVG_ very close to 64000.
My midterm goal is to create a Rodbard calibration separately for AVG_Gray and the 3 color channels using 15 neutral density filters. At this time I am only working with the white full intensity image.

I have also experimented with
Image | hyperstack |stack to Hyperstack
Image | hyperstack |reduce dimensionality ( but this step seems to not perform any averaging but simply throws away the green and blue channel and only keeps the red.

Have you tried Image > Color > Stack to RGB?

Thanks for the advice, but most of the images of interest will be very dark.
This would lose almost all the information. Initially I have 3 channels ranging from 0 to 65535 after “Stack to RGB” I only would have 8-bit data for each channel covering 0 to 255.

Sorry, I forgot about the 16-bit. You can use the following macro commands then:

//run("Channels Tool...");
run("Z Project...", "projection=[Average Intensity]");

Thank you so much that solves the problem.
How do I find from a code snippet what part of the GUI it originally relates to?
for example
Image | Color | Channels Tool |

But where did you get the “Z project…” with additional parameter?

Or when reading other code snippets on this site that I want to experiment with manually?

Thanks again.

I simply used the macro recorder (Plugins > Macros > Record).

A post was split to a new topic: "Z Project"command not macro-recorded from “Stk” menu

I forgot to answer this question. For me the easiest way to find the menu path to a command is using the command finder. There you have all the information you need.

1 Like