Difference in Red, blue and green values of a pixel in Windows and Ubuntu OS lazarus / 39-Graphics ---------------------------------------------------------------------- newman · 2017-09-08 15:11 Hi, I am trying to create a program that captures a image from a webcam, the image will need to be analysed, for this I use the Canvas.Pixels function  to extract the TColor value of the pixel, from this I get the Red, green and blue components using Graphics.Red, Graphics.Blue and Graphics.Green functions. I find that the red, blue and green values of the pixels (same pixel is analysed) are different in Windows and Linux. Please remember that the pixel being checked is same in Windows and Linux. Could anyone explain why this difference is there ??? Shouldn't the values be same in Windows and Linux ??? thanks nm ---------------------------------------------------------------------- marcov · 2017-09-08 15:16 Webcams have settings to calibrate (autobalance) colors  and intensities. Differing drivers might do this differently. Or even in a different mode altogether. ---------------------------------------------------------------------- newman · 2017-09-08 15:54 I use the same JPEG file in windows and Linux..and still there is difference. Using Pinta in Linux I find that the Red, blue and green values match the ones in Windows.. However in Lazarus the values are entirely different. I use this code. var  tc:TColor; tc:= pbForm.Canvas.Pixels[X,Y]; r:= Graphics.Red(tc); b:= Graphics.Blue(tc); g:= Graphics.Green(tc); Here X and Y are derived from the PaintBox, X and Y coordinates of MouseMove function... ---------------------------------------------------------------------- Eugene Loza · 2017-09-08 15:58 Quote from: newman on September 08, 2017, 05:54:26 pmtc:= pbForm.Canvas.Pixels[X,Y];Have you tried to have a one-colored fill JPEG? Did you check that X,Y in Lazarus are counted from 0, and X,Y in a photo editor may count from 0 and may count from 1 - here you might get a 1 pixel shift, and obviously different values for different X,Y. How different are the values? I mean, are they absolutely different, or slightly different? (UPD)QuoteX and Y coordinates of MouseMove function...You may get significantly different values here, as there is a gap between the window "top" and the control (which is DIFFERENT in Windows and Linux). ---------------------------------------------------------------------- Handoko · 2017-09-08 16:13 Quote from: newman on September 08, 2017, 05:54:26 pmHowever in Lazarus the values are entirely different. You can try the tool I wrote some time ago to see if it works correctly: http://forum.lazarus.freepascal.org/index.php/topic,37242.msg252828.ht ml#msg252828 ---------------------------------------------------------------------- newman · 2017-09-08 16:21 thanks for the replies...I will check the tool, however I fail to understand why the very same project works in Windows whereas in Ubuntu I get different results.. The values are absolutely different... as obtained from Pinta (ms paint also very similar values all less than 50) Red=40 Green=57 Blue=21 While in lazarus application it is Red=88 Green=95 Blue=87 Very rarely do rgb values go below 40... The image I use contains some black sections and lighter sections,  I noticed while checking with Pinta (and MS paint) that lower the r,g,b values the darker the pixel color, however in my lazarus application  even the lighter segments have high values.. ---------------------------------------------------------------------- Handoko · 2017-09-08 16:31 Okay, my guess is: Programmers usually define RGB values using byte (0 .. 255) but designers usually define that values using percentage (0 .. 100). ---------------------------------------------------------------------- taazz · 2017-09-08 16:46 Quote from: Handoko on September 08, 2017, 06:31:51 pmOkay, my guess is: Programmers usually define RGB values using byte (0 .. 255) but designers usually define that values using percentage (0 .. 100). no rgb is always 0..255, 0..100 is CMY/CMYK in which case a a convertion is needed. ---------------------------------------------------------------------- newman · 2017-09-08 16:47 Thanks everyone, I created a new application, I tested out the Canvas.Pixels function on an TImage, and found that rgb values matched those of Pinta and Windows....clearly there is a bug in my program...that I need to figure out.. thanks everyone for the help.. nm ---------------------------------------------------------------------- Akira1364 · 2017-09-09 02:24 Quote from: newman on September 08, 2017, 05:11:52 pmHi, I am trying to create a program that captures a image from a webcam, the image will need to be analysed, for this I use the Canvas.Pixels function  to extract the TColor value of the pixel, from this I get the Red, green and blue components using Graphics.Red, Graphics.Blue and Graphics.Green functions. I find that the red, blue and green values of the pixels (same pixel is analysed) are different in Windows and Linux. Please remember that the pixel being checked is same in Windows and Linux. Could anyone explain why this difference is there ??? Shouldn't the values be same in Windows and Linux ??? thanks nm What is the Canvas.Pixels value when you build and run the application on Linux? (Presumably under GTK2, as it seems to be the only Linux widgetset that really works somewhat properly...) That's the value you should be comparing to the Windows canvas value, not the one you get from whatever Pinta is. ---------------------------------------------------------------------- Thaddy · 2017-09-09 13:17 rgb555? rgb565? I suspect it is a format issue. https://en.wikipedia.org/wiki/High_color ---------------------------------------------------------------------- BeniBela · 2017-09-09 20:09 Ubuntu must be more red, because open-source is communistic idea ---------------------------------------------------------------------- Akira1364 · 2017-09-10 01:59 Quote from: BeniBela on September 09, 2017, 10:09:47 pmUbuntu must be more red, because open-source is communistic idea *knows that BeniBela is German and is strongly resisting the urge to make a World War 2 joke about why he dislikes communism so much* But honestly that was pretty funny...... not sure these forums are the right place for politics though? (If anyone's wondering, I'm just a boring Canadian capitalist!) ---------------------------------------------------------------------- RAW · 2017-09-10 03:05 Behind the curtain capitalism and communism is exactly the same... and will always be the same! Of course everybody standing in front of the PUNCH and JUDY SHOW shouldn't know that... it's a nice tool/game... Yeah... I couldn't deny myself...  there are too many people out there who haven't yet understood this...  ... and sometimes a little bit more salt in the soup is very nice...