Login  Register

Re: What colour is RGB black?

Posted by Cammer, Michael on Jun 20, 2016; 5:58pm
URL: http://imagej.273.s1.nabble.com/What-colour-is-RGB-black-tp5016697p5016698.html

Take a look at this based on https://imagej.nih.gov/ij/macros/tools/ColorPickerTool.txt found in the getPixel(x, y) command at https://imagej.nih.gov/ij/developer/macro/functions.html#G.
Regardless, I do find it strange that when making a new image as black or expanding the canvas without specifying zero is a different zero value (looks like #FFFFFF which I would expect to be white) than when specifying the value as zero.


newImage("Untitled1", "RGB black", 128, 128, 1); run("Canvas Size...", "width=150 height=150 position=Center"); print(getPixel(0,0)+" \t"+ getPixel(128,128)); // close();

newImage("Untitled2", "RGB black", 128, 128, 1); run("Canvas Size...", "width=150 height=150 position=Center zero"); print(getPixel(0,0)+" \t"+ getPixel(128,128));

v = getPixel(128,128);
        if (bitDepth==24) {
            red = (v>>16)&0xff;  // extract red byte (bits 23-17)
            green = (v>>8)&0xff; // extract green byte (bits 15-8)
            blue = v&0xff;       // extract blue byte (bits 7-0)
            print(red+ " \t " + green + " \t "+ blue);
        } else




=========================================================================
 Michael Cammer, Microscopy Core & Skirball Institute, NYU Langone Medical Center
 Cell:  914-309-3270     Office: Skirball 2nd Floor main office, back right a.k.a. The Coldroom
 http://ocs.med.nyu.edu/microscopy & http://microscopynotes.com/

-----Original Message-----
From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of Gabriel Landini
Sent: Monday, June 20, 2016 11:36 AM
To: [hidden email]
Subject: What colour is RGB black?

I should know this... but when I resize a canvas, I get a different value for black, even if inspecting the pixels shows (000,000,000) when I use the "zero"
parameter.
.
Running the macro below with the background set in the colour picker set to white for the foreground and black for the background I get these two values for the background pixel at (0,0) :

-16777216
0

newImage("Untitled", "RGB white", 128, 128, 1); run("Canvas Size...", "width=150 height=150 position=Center"); print(getPixel(0,0)); close();

newImage("Untitled", "RGB white", 128, 128, 1); run("Canvas Size...", "width=150 height=150 position=Center zero"); print(getPixel(0,0));

I guess that it has to do with the representation of the RGB triplet, but I am most puzzled about it since they both are the same colour (or so I though!).
Cheers

Gabriel

--
ImageJ mailing list: https://urldefense.proofpoint.com/v2/url?u=http-3A__imagej.nih.gov_ij_list.html&d=CwICAg&c=j5oPpO0eBH1iio48DtsedbOBGmuw5jHLjgvtN2r4ehE&r=oU_05LztNstAydlbm5L5GDu_vAdjXk3frDLx_CqKkuo&m=3U3mcfPSctNGeEcypXArWy1-Uim1lXW41yChutEG9yc&s=GkdynkMtKkUzZhsK2kDHRlPYTPNje2sEpvHACawUgq8&e= 

------------------------------------------------------------
This email message, including any attachments, is for the sole use of the intended recipient(s) and may contain information that is proprietary, confidential, and exempt from disclosure under applicable law. Any unauthorized review, use, disclosure, or distribution is prohibited. If you have received this email in error please notify the sender by return email and delete the original message. Please note, the recipient should check this email and any attachments for the presence of viruses. The organization accepts no liability for any damage caused by any virus transmitted by this email.
=================================

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