Re: reading channel display color

Posted by Krs5 on
URL: http://imagej.273.s1.nabble.com/reading-channel-display-color-tp5024126p5024132.html

Dear Leo,

The macro code below detect the colour of a channel.

run("Neuron (5 channels)");
Stack.getDimensions(width, height, channels, slices, frames);
color=newArray(channels+1);
for (i=1; i<=channels; i++){
if (channels>1) Stack.setChannel(i);
getLut(reds, greens, blues);
if ((reds[i]==i)&&(greens[i]==0)&&(blues[i]==0)) color[i] = "red";
if ((reds[i]==0)&&(greens[i]==i)&&(blues[i]==0)) color[i] = "green";
if ((reds[i]==0)&&(greens[i]==0)&&(blues[i]==i)) color[i] = "blue";
if ((reds[i]==0)&&(greens[i]==i)&&(blues[i]==i)) color[i] = "cyan";
if ((reds[i]==i)&&(greens[i]==0)&&(blues[i]==i)) color[i] = "magenta";
if ((reds[i]==i)&&(greens[i]==1)&&(blues[i]==0)) color[i] = "yellow";
if ((reds[i]==i)&&(greens[i]==i)&&(blues[i]==i)) color[i] = "gray";
print (color[i]);
}

You can then use this information to set the LUT for a channel.

Hope this helps

Best wishes

Kees


Dr Ir K.R. Straatman
Advanced Imaging Facility

University of Leicester
www.le.ac.uk/advanced-imaging-facility<https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.le.ac.uk%2Fadvanced-imaging-facility&data=02%7C01%7Ckrs5%40leicester.ac.uk%7C59b63365222d4a2d72dc08d7a0dad4b6%7Caebecd6a31d44b0195ce8274afe853d9%7C0%7C0%7C637154734055515186&sdata=821yl9l42Hs2RuVMTZexifQ2LAz%2FsheYZrJPxzgIxkE%3D&reserved=0>


________________________________
From: Leoncio Vergara
Sent: 27 October 2020 15:52
Subject: reading channel display color

Hi, I have a very simple question. Is there a macro instruction to read the display color for a channel in image J? I can read the min and max display values for the gray values, I can also setup the color for a given channel, but if I want to et the information from an open image and transfer it to another one, I cant find the solution. I would appreciate if anybody could point me in the right direction.

Thank you

Leo Vergara

--
ImageJ mailing list: https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fimagej.nih.gov%2Fij%2Flist.html&amp;data=04%7C01%7Ckrs5%40leicester.ac.uk%7C7230667c35a945820ee908d87a90d3fb%7Caebecd6a31d44b0195ce8274afe853d9%7C0%7C1%7C637394109748541556%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&amp;sdata=gBcVJZ1MZK46cphvDCoCHg%2BAYAVLIeJZH7SMjYNY2uk%3D&amp;reserved=0

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html