[SOLVED] Testing mouseColor function

Visuals, audio, animation. Blended, not stirred. If LiveCode is part of your rich media production toolbox, this is the forum for you.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

capellan
Posts: 654
Joined: Wed Aug 15, 2007 11:09 pm

[SOLVED] Testing mouseColor function

Post by capellan » Sat Jan 12, 2019 2:51 am

Hi All,

Could you verify if mouseColor function works correctly
in your own setup?

Download the attached stack, decompress it and
click the button to find the only two black pixels
in the very small image (12 pixels x 12 pixels)

The script find the first black pixel on two
different lines.

Now, click inside the small image and the image
script put the mousecolor in fld 2. Click the button
again and try to find the mousecolor among the
pixels of the clicked image. Most colors produced
by the mousecolor function are not found in the
image except a few like the color 255,255,255

Please test and post your results.
Thanks in advance!

Al
Find_ColorPixel_Coordinate_v01.livecode.zip
Last edited by capellan on Tue Jan 15, 2019 11:53 pm, edited 1 time in total.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9286
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Testing mouseColor function

Post by richmond62 » Sat Jan 12, 2019 7:54 am

1. Found selected pixel color at coordinates 4,11

2. Found selected pixel color at coordinates 6,3

3. Posted those values to the messageBox.

Clicked on the small image: 253,63,63

Button click: no result.

capellan
Posts: 654
Joined: Wed Aug 15, 2007 11:09 pm

Re: Testing mouseColor function

Post by capellan » Sat Jan 12, 2019 2:42 pm

Hi Richmond,
richmond62 wrote:
Sat Jan 12, 2019 7:54 am
1. Found selected pixel color at coordinates 4,11
2. Found selected pixel color at coordinates 6,3
3. Posted those values to the messageBox.
This is the correct result because the pixel color 0,0,0
is found with the small image.
Clicked on the small image: 253,63,63
Button click: no result.
You found the error. After clicking inside the image
and selecting a pixel color using the mousecolor
function, the script shows that this color
does not exists within the image.

Keep clicking inside the image and you will
notice that many colors reported by the
mousecolor function does not exists
within the image.

Al

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2718
Joined: Sat Dec 22, 2007 5:35 pm
Location: Genève
Contact:

Re: Testing mouseColor function

Post by jmburnod » Sat Jan 12, 2019 6:55 pm

Hi,
I found 2 black pixels here (topleft = 0,0) by hand
2,5 10.3

Results for black pixel using btn
0,0,0 4,11 6.3

Results for others colors using btn
253,111,111not found
253,189,189 not found
15,255,16 not found
255,0,0 1,2 2,2 3,2 4,2 6,12 8,3 9,3 10,3 11,3 12,3

Best
Jean-Marc
https://alternatic.ch

capellan
Posts: 654
Joined: Wed Aug 15, 2007 11:09 pm

Re: Testing mouseColor function

Post by capellan » Sat Jan 12, 2019 10:42 pm

I have updated the demo stack. Please download this new version
from the stack posted in the first message.

After testing many pixels, I suspect that the difference between
the actual pixel color and the mousecolor pixel color is the result
of a color conversion, maybe from hsl or hsv to rgb. Maybe that's
the explanation for these differences.

Al
Find_ColorPixel_Coordinate_v03.livecode.zip
Last edited by capellan on Tue Jan 15, 2019 8:37 pm, edited 1 time in total.

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Re: Testing mouseColor function

Post by [-hh] » Sun Jan 13, 2019 1:34 am

How do you define "the actual pixel color"?

Of course this is OS- and hardware-dependent!

If you mean the color of a pixel as you see it on your screen, then you could make a 1x1 snapshot.

The mouseColor does probably more: It takes the pixel color from the current "videobuffer".
This has also an alpha value. The mouseColor probably computes from that (a,r,g,b) quadrupel a possibly alpha-premultiplied (r,g,b) tripel.

Because LC doesn't set the screen display it cannot really know what the OS (and its hardware) makes with the color of a pixel that you set.
For the mousecolor LC tries to estimate a correct value, which may be, by the OS, moreover possibly bilinear (or by cubic splines) interpolated from surrouding pixels.

So it may be better to speak of "the visible pixel color" (from an 1x1 screenshot) and compare that to "the estimated pixel color" (from the mousecolor).
shiftLock happens

capellan
Posts: 654
Joined: Wed Aug 15, 2007 11:09 pm

Re: Testing mouseColor function

Post by capellan » Sun Jan 13, 2019 6:57 am

Probably I have to test in all desktop platforms
before reaching a definitive conclusion, but
at least in this Mac, only grays, black and white
are picked correctly by the mouseColor.

Red (255,0,0), Green (0,255,0) and Blue (0,0,255)
are converted into other similar colors.

Maybe changing screen colors it's normal in all
Mac Operating System or just a particular setting
of this OSX version.

After testing in Linux and Windows, I will report.

Al

capellan
Posts: 654
Joined: Wed Aug 15, 2007 11:09 pm

Re: Testing mouseColor function

Post by capellan » Tue Jan 15, 2019 8:24 pm

After testing in Windows, using LC7, 8 and 9
the mouseColor function works correctly.

If you click a pixel with the color 255,0,0
then the mouseColor function returns
255,0,0 (not 245,44,11 for the same
color on Mac)

Could anyone test this stack in your
own setup and post your results?

Thanks in advance!

Al

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9802
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Testing mouseColor function

Post by FourthWorld » Tue Jan 15, 2019 8:43 pm

I'm confused: the sample stack posted above does not appear to use the mouseColor function, instead relying on a much more complicated method involving screen shots and approximating values across the pixels of the captured image.

FWIW I use mouseColor nearly weekly while developing, and have no recollection of it failing on Linux, Mac, or Windows.

Set the screenMouseLoc, get that color, set the screenMouseLoc back, done. Simple, efficient, fewer moving parts to break, no approximation needed.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Re: Testing mouseColor function

Post by [-hh] » Tue Jan 15, 2019 10:27 pm

And you believe that this is the percepted color of the pixel under the hotspot of your mouse?
shiftLock happens

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9802
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Testing mouseColor function

Post by FourthWorld » Tue Jan 15, 2019 10:32 pm

[-hh] wrote:
Tue Jan 15, 2019 10:27 pm
And you believe that this is the percepted color of the pixel under the hotspot of your mouse?
Given cognitive and retinal variance, I suppose that's an interesting question. All I know is that I use it all the time to pick up colors I later use for fills, and they seem to match, at least within the perceptual limits of my eyes.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Re: Testing mouseColor function

Post by [-hh] » Tue Jan 15, 2019 10:36 pm

and they seem to match, at least within the perceptual limits of my eyes.
... on your hardware. Also on (another) differently calibrated retina display?

Besides visual differences (that certainly are, as you say, individually determined) there may be another less "subjective" comparison way. There are also other (even specialized) apps that have a pipette.

On Mac I get, for instance, different values from the famous GraphicConverter pipette and the LC mouseColor. Both are, when using fills, a bit away from what I see (I have from a standardized medical test 100% color perception).
Differences come, as far as I can judge this, from the inclusion of the alpha channel (transparency) and possibly also, as Al says, from conversion "errors" between color models.
shiftLock happens

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9802
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Testing mouseColor function

Post by FourthWorld » Tue Jan 15, 2019 11:12 pm

[-hh] wrote:
Tue Jan 15, 2019 10:36 pm
and they seem to match, at least within the perceptual limits of my eyes.
... on your hardware. Also on (another) differently calibrated retina display?

Besides visual differences (that certainly are, as you say, individually determined) there may be another less "subjective" comparison way. There are also other (even specialized) apps that have a pipette.

On Mac I get, for instance, different values from the famous GraphicConverter pipette and the LC mouseColor. Both are, when using fills, a bit away from what I see (I have from a standardized medical test 100% color perception).
Differences come, as far as I can judge this, from the inclusion of the alpha channel (transparency) and possibly also, as Al says, from conversion "errors" between color models.
I don't understand. An Alpha channel has no color, it merely determines the degree to which a color may be influenced by colors beneath it. If using the composite display buffer, how could the affects of translucence be excluded? If not using the display buffer, what is being used?

If LC's doing it wrong let's report it. After all, they already included the function, so rather than create complex alternatives in script we should just make the built-in one work.

All I know is I've been using screenMouseColor for many years on all three desktop platforms, and so far none of my clients or customers have complained about mis-matched colors.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9802
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Testing mouseColor function

Post by FourthWorld » Tue Jan 15, 2019 11:18 pm

Searching the bug DB I found the relevant report, and have requested status there.

https://quality.livecode.com/show_bug.cgi?id=11502
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9802
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Testing mouseColor function

Post by FourthWorld » Tue Jan 15, 2019 11:22 pm

This report seems related, and suggests a role of specific OS-provided color profiles as a contributing factor:

https://quality.livecode.com/show_bug.cgi?id=21517
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Post Reply

Return to “Multimedia”