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: http://imagej.nih.gov/ij/list.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 |
In reply to this post by Gabriel Landini
I’m not an expert on ImageJ’s internal representation of RGB values, but -16777216 is:
0xFF000000 This looks to me like an ARGB value with: A = 255 R = G = B = 0 Going further, the “zero” parameter seems to set the pixel value to 0 = 0x00000000, which (if my interpretation is correct, would be: A = R = G = B = 0. The conclusion is that “black” is not the same thing as “zero”. Zero appears to be taken literally as 0x00000000, while “black” is represented as 0xFF00000000 (that is, OPAQUE black). The point is that “black” has R=G=B=0, but A=255. “zero” = 0x00000000 is not “black”. It is “black, but completely transparent”. My apologies if my WAG’s are wrong. If I’m right - this simply illustrates the perils of trying to parse (or create) internal representations at the bit level. The purist in me even want the parameter “zero” to be an error when applied to an RGB image. It’s a type violation. But, this kind of bit-twiddling has a long tradition and is difficult to stamp out. -- Kenneth Sloan [hidden email] Vision is the art of seeing what is invisible to others. > On Jun 20, 2016, at 17:35 , Gabriel Landini <[hidden email]> wrote: > > 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: http://imagej.nih.gov/ij/list.html -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Thank you Kenneth and Michael for the follow up and the explanation.
On Monday 20 Jun 2016 20:16:42 Kenneth Sloan wrote: > “zero” = 0x00000000 is not “black”. It is “black, but completely > transparent”. This reminds me of the old joke: What is red and invisible? Answer: No tomatoes! Cheers Gabriel -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Free forum by Nabble | Edit this page |