Login  Register

Re: reading channel display color

Posted by Jeremy Adler on Oct 28, 2020; 12:12pm
URL: http://imagej.273.s1.nabble.com/reading-channel-display-color-tp5024126p5024134.html

Hi Gabriel,

For added masochism you could compare the values of the LUT with the LUTs available in ImageJ - and find the LUT's actual name.
Except that the LUT might not be present and the name (e.g. glasbey) might not give dominant colour.

Jeremy Adler





-----Original Message-----
From: ImageJ Interest Group <[hidden email]> On Behalf Of Gabriel Landini
Sent: Wednesday, October 28, 2020 12:18 PM
To: [hidden email]
Subject: Re: reading channel display color

Hi Kees,
Nice script. Can I contribute a suggestion?
You could test if the LUT is incrementally linear for the R G B components of the LUT through the 256 levels, in case some other LUT has been applied or inverted.
For example when using a different lut the modification below would detect it (just uncomment line 2 to test).
There might be more elegant ways to test if the LUT linearly increases to 255.
The suggestion below checks that increments are all 1 between levels and that the highest LUT value is 255.

run("Neuron (5 channels)");
//run("Ice"); //uncomment to test a different LUT 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);
  chr= chg= chb=-1;
  for (j=0;j<255;j++) {
   if (reds[j+1]-reds[j]!=1) chr=0;
   if (greens[j+1]-greens[j]!=1) chg=0;
   if (blues[j+1]-blues[j]!=1) chb=0;
  }
  if (reds[255]!=255) chr=0;
  if (greens[255]!=255) chg=0;
  if (blues[255]!=255) chb=0;
  //print (chr, chg, chb);

 color[i]="unrecognised LUT";
  if (chr==-1 && chg ==0 && chb==0) color[i] = "red";
  if (chr==0 && chg ==-1 && chb==0)  color[i] = "green";
  if  (chr==0 && chg ==0 && chb==-1) color[i] = "blue";
  if  (chr==0 && chg ==-1 && chb==-1) color[i] = "cyan";
  if  (chr==-1 && chg ==0 && chb==-1)  color[i] = "magenta";
  if  (chr==-1 && chg ==-1 && chb==0) color[i] = "yellow";
  if  (chr==-1 && chg ==-1 && chb==-1) color[i] = "gray";
  print (color[i]);
}

Cheers

Gabriel

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








När du har kontakt med oss på Uppsala universitet med e-post så innebär det att vi behandlar dina personuppgifter. För att läsa mer om hur vi gör det kan du läsa här: http://www.uu.se/om-uu/dataskydd-personuppgifter/

E-mailing Uppsala University means that we will process your personal data. For more information on how this is performed, please read here: http://www.uu.se/en/about-uu/data-protection-policy

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