Hello:

I need to write an algorithm to recognize if there is a circle in a bmp.
The bmp is small in size, like an icon, and the circle center will be close
to the image center (or exactly).
Inside the circle may be anything.

Do you know of any existing algorithm to accomplish that?

Thanks in advance.

Re: shape recognition by Larry

Larry
Sat Oct 11 23:36:49 CDT 2008


"Eduardo" <mm@mm.com> wrote

> I need to write an algorithm to recognize if there is a circle in a bmp.
> The bmp is small in size, like an icon, and the circle center will be close
> to the image center (or exactly).
> Inside the circle may be anything.
>
> Do you know of any existing algorithm to accomplish that?


What is outside the circle?

LFS



Re: shape recognition by Eduardo

Eduardo
Sun Oct 12 00:02:09 CDT 2008

"Larry Serflaten" <serflaten@usinternet.com> escribió en el mensaje
news:u1uRUQCLJHA.3808@TK2MSFTNGP04.phx.gbl...
>
> "Eduardo" <mm@mm.com> wrote
>
>> I need to write an algorithm to recognize if there is a circle in a bmp.
>> The bmp is small in size, like an icon, and the circle center will be
>> close
>> to the image center (or exactly).
>> Inside the circle may be anything.
>>
>> Do you know of any existing algorithm to accomplish that?
>
>
> What is outside the circle?

A solid color, or almost solid.

Mi idea is:

Analyze the image in this way:
Start at the middle of each edge, and see the color of the pixels, each one
going towards the center.
Then go one pixel each time to one of the vertex and see if the same pattern
repeats, but more inward than when i looked in the middle.

I'm also thinking of making a function "ColorIsSimilar", because the color
may be not exactly the same, but similar.

I wondered if there was something already done, that's why i asked.

Thanks.



Re: shape recognition by Larry

Larry
Sun Oct 12 14:22:51 CDT 2008


"Eduardo" <mm@mm.com> wrote
> I'm also thinking of making a function "ColorIsSimilar", because the color
> may be not exactly the same, but similar.


If you AND your image data with &HC0C0C0 you will remove subtle
color changes. That may help if you want to examine the image pixel
by pixel.

LFS



Re: shape recognition by Eduardo

Eduardo
Sun Oct 12 17:16:07 CDT 2008

Ahh, thank you for the idea.

"Larry Serflaten" <serflaten@usinternet.com> escribió en el mensaje
news:O7Yca$JLJHA.728@TK2MSFTNGP03.phx.gbl...
>
> "Eduardo" <mm@mm.com> wrote
>> I'm also thinking of making a function "ColorIsSimilar", because the
>> color
>> may be not exactly the same, but similar.
>
>
> If you AND your image data with &HC0C0C0 you will remove subtle
> color changes. That may help if you want to examine the image pixel
> by pixel.
>
> LFS
>
>



Re: shape recognition by Eduardo

Eduardo
Mon Oct 13 03:35:13 CDT 2008

My function:

Private Function ColorsAreSimilar(nColor1 As Long, nColor2 As Long) As
Boolean
ColorsAreSimilar = False
If (nColor1 And &HE0E0E0) = (nColor2 And &HE0E0E0) Or ((nColor1 -
&HE0E0E0) And &HE0E0E0) = (nColor2 And &HE0E0E0) Then
ColorsAreSimilar = True
End If
End Function

seems to work.
Thanks again Larry.

"Eduardo" <mm@mm.com> escribió en el mensaje news:gctt14$mon$1@aioe.org...
> Ahh, thank you for the idea.
>
> "Larry Serflaten" <serflaten@usinternet.com> escribió en el mensaje
> news:O7Yca$JLJHA.728@TK2MSFTNGP03.phx.gbl...
>>
>> "Eduardo" <mm@mm.com> wrote
>>> I'm also thinking of making a function "ColorIsSimilar", because the
>>> color
>>> may be not exactly the same, but similar.
>>
>>
>> If you AND your image data with &HC0C0C0 you will remove subtle
>> color changes. That may help if you want to examine the image pixel
>> by pixel.
>>
>> LFS
>>
>>
>
>



Re: shape recognition by Eduardo

Eduardo
Mon Oct 13 03:57:58 CDT 2008

"Eduardo" <mm@mm.com> escribió en el mensaje news:gcv18c$ol7$1@aioe.org...
> My function:
>
> Private Function ColorsAreSimilar(nColor1 As Long, nColor2 As Long) As
> Boolean
> ColorsAreSimilar = False
> If (nColor1 And &HE0E0E0) = (nColor2 And &HE0E0E0) Or ((nColor1 -
> &HE0E0E0) And &HE0E0E0) = (nColor2 And &HE0E0E0) Then
> ColorsAreSimilar = True
> End If
> End Function
>
> seems to work.
> Thanks again Larry.

No, it's not working.

What i'm trying to do, is to eliminate the "steps" that this operation
generates.

For example:
nColor1 = &HFFFFC1
nColor2 = &HFFFFBF

are indeed very similar, and the function returns they are not.
The same happen if I "AND" with &HC0C0C0.
I'm thinking...



Re: shape recognition by Eduardo

Eduardo
Mon Oct 13 04:15:26 CDT 2008

I went back to my first idea:

Private Function ColorsAreSimilar(nColor1 As Long, nColor2 As Long) As
Boolean
Dim iR1 As Long
Dim iG1 As Long
Dim iB1 As Long
Dim iR2 As Long
Dim iG2 As Long
Dim iB2 As Long

ColorsAreSimilar = False

iR1 = nColor1 And 255
iG1 = (nColor1 \ 256) And 255
iB1 = (nColor1 \ 65536) And 255

iR2 = nColor2 And 255
iG2 = (nColor2 \ 256) And 255
iB2 = (nColor2 \ 65536) And 255

If Abs(iR1 - iR2) + Abs(iG1 - iG2) + Abs(iB1 - iB2) < 192 Then
ColorsAreSimilar = True
End If
End Function

It has to execute more code, but works for all colors.


"Eduardo" <mm@mm.com> escribió en el mensaje news:gcv2j1$ua8$1@aioe.org...



Re: shape recognition by Schmidt

Schmidt
Mon Oct 13 04:22:07 CDT 2008


"Eduardo" <mm@mm.com> schrieb im Newsbeitrag news:gcv2j1$ua8$1@aioe.org...

> For example:
> nColor1 = &HFFFFC1
> nColor2 = &HFFFFBF
>
> are indeed very similar, and the function returns they are not.
> The same happen if I "AND" with &HC0C0C0.
> I'm thinking...

Think you will have to compare the component-bytes
separately - normally you have access to the Bytes
in the DIB-Array - so that should not be a big problem.

You Function ColorsAreSimilar would then need
6 Arguments instead of 2 (or 7 if you want to give
the "similarity-delta" as a Param).

Function ColorsAreSimilar(B1 as Byte, G1 as Byte, R1 as Byte, _
B2 as Byte, G2 as Byte, R2 as Byte, _
optional byval Delta as Long=16) as Boolean
If Abs(B1-B2) > Delta Then Exit Function
If Abs(G1-G2) > Delta Then Exit Function
If Abs(R1-R2) > Delta Then Exit Function
ColorsAreSimilar = True
End Function

Olaf



Re: shape recognition by Eduardo

Eduardo
Mon Oct 13 04:47:37 CDT 2008

"Schmidt" <sss@online.de> escribió en el mensaje
news:u9BB4URLJHA.1156@TK2MSFTNGP04.phx.gbl...

> Think you will have to compare the component-bytes
> separately - normally you have access to the Bytes
> in the DIB-Array - so that should not be a big problem.
>
> You Function ColorsAreSimilar would then need
> 6 Arguments instead of 2 (or 7 if you want to give
> the "similarity-delta" as a Param).
>
> Function ColorsAreSimilar(B1 as Byte, G1 as Byte, R1 as Byte, _
> B2 as Byte, G2 as Byte, R2 as Byte, _
> optional byval Delta as Long=16) as Boolean
> If Abs(B1-B2) > Delta Then Exit Function
> If Abs(G1-G2) > Delta Then Exit Function
> If Abs(R1-R2) > Delta Then Exit Function
> ColorsAreSimilar = True
> End Function

Yes. See what I posted replying to the same message that you replied.
I'm now thinking whether i should compare the color difference separately as
you
did or as a whole as i did.

In my case, it allows all the difference to be in just one of the color
channels.
(BTW: 192 for Delta is a lot that i allowed as "similar")

In your case, with only one channel with Delta difference, then the color is
not
similar.

I think I'll set Delta in something like 64, and compute the three channels
together as I did.
I'd like to have your opinion.




Re: shape recognition by Schmidt

Schmidt
Mon Oct 13 05:45:47 CDT 2008


"Eduardo" <mm@mm.com> schrieb im Newsbeitrag news:gcv5i5$c9j$1@aioe.org...

> Yes. See what I posted replying to the same message
> that you replied.
Yep, our posts overlapped a bit in time. ;-)

> In my case, it allows all the difference to be in just one
> of the color channels.
> (BTW: 192 for Delta is a lot that i allowed as "similar")
Yes - that can work very "tolerant" this way, but
in some cases maybe too tolerant.

> In your case, with only one channel with Delta difference,
> then the color is not similar.
That depends on how large you define (or pass) the
Delta-Param - you could also define a separate Delta
for each channel of course, but am sure you are already
aware of this.

> I think I'll set Delta in something like 64, and compute
> the three channels together as I did.
> I'd like to have your opinion.
What will work best, depends on your images of course -
simply experiment a bit with a larger image-set.

Olaf



Re: shape recognition by Peter

Peter
Mon Oct 13 05:45:50 CDT 2008

> Analyze the image in this way:
> Start at the middle of each edge, and see the color of the pixels, each
> one going towards the center.
> Then go one pixel each time to one of the vertex and see if the same
> pattern repeats, but more inward than when i looked in the middle.
>
> I'm also thinking of making a function "ColorIsSimilar", because the color
> may be not exactly the same, but similar.

When you say "similar" do you mean in terms of numerical RGB or "visually".
Point being, the eye does not perceive much separation with some colours, eg
greens, but very small differences in say cyan are very noticeable.

If by similar you mean "visually" it might be worth looking into the 3D
"colour shape" or "colour space" (search w/out the "u"). There are numerous
algorithms out there of varying complexity to define a colour shape. Having
defined your space, fix your RGB's at points in the 3D space, return their
xyz coordinates form some arbitrary origin.

The colour difference is the distance between the colours in the 3D space.

If you are only looking for extremely small differences, eg up to about 5 in
each RGB 0-255 scale (within range of say typical jpg representation of same
colour), it's probably OK to ignore the above for your purposes and
concentrate on what you are already doing.

Regards,
Peter T



Re: shape recognition by Eduardo

Eduardo
Mon Oct 13 06:00:02 CDT 2008

"Schmidt" <sss@online.de> escribió en el mensaje
news:%236nnnDSLJHA.2348@TK2MSFTNGP05.phx.gbl...

>> I think I'll set Delta in something like 64, and compute
>> the three channels together as I did.
>> I'd like to have your opinion.

> What will work best, depends on your images of course -
> simply experiment a bit with a larger image-set.

My question was directed to: if to compute the difference for the three
channels as a whole (as i did), or to compute the Delta separately for each
channel.

I've been thinking about that, and I believe that to compute the three
together to see the global difference may be the better.

And about the value of the "global" Delta, i'm experimenting.

Thanks Schmidt.



Re: shape recognition by expvb

expvb
Mon Oct 13 05:57:42 CDT 2008

Here is a link to VB6 code that calculates a circle's center and radius
based on 3 points if you need it:

http://groups.google.com/group/microsoft.public.vb.general.discussion/msg/77a3a16eeaa8b68d



Re: shape recognition by Eduardo

Eduardo
Mon Oct 13 06:05:30 CDT 2008

What i mean is:

what's the better?:

1)

If Abs(iR1 - iR2) + Abs(iG1 - iG2) + Abs(iB1 - iB2) < 96 Then
ColorsAreSimilar = True
End If

or 2)

If Abs(iR1 - iR2) >= 32 Then Exit Function
If Abs(iG1 - iG2) >= 32 Then Exit Function
If Abs(iB1 - iB2) >= 32 Then Exit Function
ColorsAreSimilar = True


They are not the same.

"Eduardo" <mm@mm.com> escribió en el mensaje news:gcv9nt$vmn$1@aioe.org...
> "Schmidt" <sss@online.de> escribió en el mensaje
> news:%236nnnDSLJHA.2348@TK2MSFTNGP05.phx.gbl...



Re: shape recognition by Larry

Larry
Mon Oct 13 06:49:16 CDT 2008


"Eduardo" <mm@mm.com> wrote

> No, it's not working.
>
> What i'm trying to do, is to eliminate the "steps" that this operation
> generates.

I guess I assumed you were only looking for the outline of a
circle that would be easily distinguished from the rest of the image.

If the circle is shaded, then perhaps finding similar colors is more
subtle than I had proposed.

And just for the record, instead of ANDing each pixel as you
showed, I was thinking more of using BitBlt to paint the image
with a raster op that would AND a source and destination image.
You'd do the whole image at once, and then start looking at the
pixels...

LFS



Re: shape recognition by Schmidt

Schmidt
Mon Oct 13 14:20:11 CDT 2008


"Eduardo" <mm@mm.com> schrieb im Newsbeitrag news:gcva24$1jh$1@aioe.org...
> What i mean is:
>
> what's the better?:
>
> 1)
>
> If Abs(iR1 - iR2) + Abs(iG1 - iG2) + Abs(iB1 - iB2) < 96 Then
> ColorsAreSimilar = True
> End If
>
> or 2)
>
> If Abs(iR1 - iR2) >= 32 Then Exit Function
> If Abs(iG1 - iG2) >= 32 Then Exit Function
> If Abs(iB1 - iB2) >= 32 Then Exit Function
> ColorsAreSimilar = True
>
>
> They are not the same.
I am (was) well aware of this (also in my previous post) -
and I can only tell again - that it depends on your concrete
images - on how they possibly differ, where they come from,
what the dynamic-range of the camera is/was (and on
some cams the dynamic-range or -sensibility is different for
each color-channel).

Your Nr. 1 is the most tolerant approach for images which
can have very different tones in their "base background"
(over all three color-channels) as I see it.

If the "color-tone" of your images is instead more
constant (always "greenish" or "reddish" for example),
then you should probably focus a bit more at the luminance-
values, and in this case IMO the approach with the separate
Delta-Values per channel makes more sense - and you don't
have to use always the same compare-delta for each channel
then - maybe it behaves better if you put a "human weighting"
into the three separate Delta-Values (as Peter already suggested).
The human eye is most sensitive for green regarding the luminance -
blue comes last.

Olaf



Re: shape recognition by Eduardo

Eduardo
Mon Oct 13 16:14:11 CDT 2008

"Larry Serflaten" <serflaten@usinternet.com> escribió en el mensaje
news:%23vsAnmSLJHA.4452@TK2MSFTNGP05.phx.gbl...
>
> "Eduardo" <mm@mm.com> wrote
>
>> No, it's not working.
>>
>> What i'm trying to do, is to eliminate the "steps" that this operation
>> generates.
>
> I guess I assumed you were only looking for the outline of a
> circle that would be easily distinguished from the rest of the image.

It is easily distinguished by the eye.
But it can have different contrast ratio one image from another one.

> If the circle is shaded, then perhaps finding similar colors is more
> subtle than I had proposed.

They may have a shade, but mostly inwards.

>
> And just for the record, instead of ANDing each pixel as you
> showed, I was thinking more of using BitBlt to paint the image
> with a raster op that would AND a source and destination image.
> You'd do the whole image at once, and then start looking at the
> pixels...

I think you say to convert the image to black and white. In that case I'll
have only one level to distinguis from black to white (or False to True).
As the images are small, I think the other function will be fast enough, but
thanks for the idea.

>
> LFS
>
>



Re: shape recognition by Eduardo

Eduardo
Mon Oct 13 16:15:56 CDT 2008

"expvb" <nobody@cox.net> escribió en el mensaje
news:ufG6bKSLJHA.5660@TK2MSFTNGP03.phx.gbl...
> Here is a link to VB6 code that calculates a circle's center and radius
> based on 3 points if you need it:
>
> http://groups.google.com/group/microsoft.public.vb.general.discussion/msg/77a3a16eeaa8b68d

Thanks expvb, i still don't know if i can use it, but thanks.



Re: shape recognition by Eduardo

Eduardo
Mon Oct 13 16:30:40 CDT 2008

"Peter T" <peter_t@discussions> escribió en el mensaje
news:umkBeDSLJHA.6000@TK2MSFTNGP04.phx.gbl...
>> Analyze the image in this way:
>> Start at the middle of each edge, and see the color of the pixels, each
>> one going towards the center.
>> Then go one pixel each time to one of the vertex and see if the same
>> pattern repeats, but more inward than when i looked in the middle.
>>
>> I'm also thinking of making a function "ColorIsSimilar", because the
>> color may be not exactly the same, but similar.
>
> When you say "similar" do you mean in terms of numerical RGB or
> "visually".

Good point.
And of course, as they are images, they are for the human eye.

> Point being, the eye does not perceive much separation with some colours,
> eg greens, but very small differences in say cyan are very noticeable.
>
> If by similar you mean "visually" it might be worth looking into the 3D
> "colour shape" or "colour space" (search w/out the "u"). There are
> numerous algorithms out there of varying complexity to define a colour
> shape. Having defined your space, fix your RGB's at points in the 3D
> space, return their xyz coordinates form some arbitrary origin.
>
> The colour difference is the distance between the colours in the 3D space.

Well, the images can have a shadow, but they are just 2D (i think, though, i
don't know when an image pass from 2D to be considered as 3D).

>
> If you are only looking for extremely small differences, eg up to about 5
> in each RGB 0-255 scale (within range of say typical jpg representation of
> same colour), it's probably OK to ignore the above for your purposes and
> concentrate on what you are already doing.

I'm looking for much bigger differences. For the kind of differences that
the eye perceive as the outline of a shape (in a small bitmap).

You made a good point here about the difference of sensitivity of the eye to
different colors. I ignored that until now. I'll see what I'll do.
I think for the time being i'll keep ignoring that, and when i have the
recognition algorithm done, then i'll tweak the ColorsAreSimilar function.

Thanks.

>
> Regards,
> Peter T
>
>



Re: shape recognition by Eduardo

Eduardo
Mon Oct 13 16:41:32 CDT 2008

"Schmidt" <sss@online.de> escribió en el mensaje
news:uIdjEjWLJHA.1500@TK2MSFTNGP06.phx.gbl...
>
> "Eduardo" <mm@mm.com> schrieb im Newsbeitrag news:gcva24$1jh$1@aioe.org...
>> What i mean is:
>>
>> what's the better?:
>>
>> 1)
>>
>> If Abs(iR1 - iR2) + Abs(iG1 - iG2) + Abs(iB1 - iB2) < 96 Then
>> ColorsAreSimilar = True
>> End If
>>
>> or 2)
>>
>> If Abs(iR1 - iR2) >= 32 Then Exit Function
>> If Abs(iG1 - iG2) >= 32 Then Exit Function
>> If Abs(iB1 - iB2) >= 32 Then Exit Function
>> ColorsAreSimilar = True
>>
>>
>> They are not the same.
> I am (was) well aware of this (also in my previous post) -
> and I can only tell again - that it depends on your concrete
> images - on how they possibly differ, where they come from,
> what the dynamic-range of the camera is/was (and on
> some cams the dynamic-range or -sensibility is different for
> each color-channel).

Well, I don't agree with you here.
I think it's more a matter of logic.

> Your Nr. 1 is the most tolerant approach for images which
> can have very different tones in their "base background"
> (over all three color-channels) as I see it.

Whether it's more tolerant or not depends on the Delta value. I put 96 in
this sample, but what if it was 8 (keeping the other alternative in 32),
it's not more tolerant then. Even if i set it to 32 it's not more tolerant.

>
> If the "color-tone" of your images is instead more
> constant (always "greenish" or "reddish" for example),
> then you should probably focus a bit more at the luminance-
> values,

I think you mean to convert it to greyscale first.
In that case i have only to compare one channel (all the three will have the
same information).

>and in this case IMO the approach with the separate
> Delta-Values per channel makes more sense - and you don't
> have to use always the same compare-delta for each channel

?? i get lost. I thought i already converted it to greyscale.

> then - maybe it behaves better if you put a "human weighting"
> into the three separate Delta-Values (as Peter already suggested).
> The human eye is most sensitive for green regarding the luminance -
> blue comes last.
>
> Olaf
>
>



Re: shape recognition by Schmidt

Schmidt
Mon Oct 13 20:02:39 CDT 2008


"Eduardo" <mm@mm.com> schrieb im Newsbeitrag news:gd0fcb$9d2$4@aioe.org...

> >> 1)
> >>
> >> If Abs(iR1 - iR2) + Abs(iG1 - iG2) + Abs(iB1 - iB2) < 96 Then
> >> ColorsAreSimilar = True
> >> End If
> >>
> >> or 2)
> >>
> >> If Abs(iR1 - iR2) >= 32 Then Exit Function
> >> If Abs(iG1 - iG2) >= 32 Then Exit Function
> >> If Abs(iB1 - iB2) >= 32 Then Exit Function
> >> ColorsAreSimilar = True
> >>
> >>
> >> They are not the same.
> > I am (was) well aware of this (also in my previous post) -
> > and I can only tell again - that it depends on your concrete
> > images - on how they possibly differ, where they come from,
> > what the dynamic-range of the camera is/was (and on
> > some cams the dynamic-range or -sensibility is different for
> > each color-channel).
>
> Well, I don't agree with you here.
> I think it's more a matter of logic.
If you say so.

> > Your Nr. 1 is the most tolerant approach for images which
> > can have very different tones in their "base background"
> > (over all three color-channels) as I see it.
>
> Whether it's more tolerant or not depends on the Delta
> value. I put 96 in this sample, but what if it was 8 (keeping
> the other alternative in 32), it's not more tolerant then.
> Even if i set it to 32 it's not more tolerant.
That's trivial - so you don't need to mention that explicitely.
I was referring to the logic which you too were following
in your Code-Lines above, setting your "cumulated-delta"
three times the size of the "single-channel-delta".

> > If the "color-tone" of your images is instead more
> > constant (always "greenish" or "reddish" for example),
> > then you should probably focus a bit more at the luminance-
> > values,
>
> I think you mean to convert it to greyscale first.
No.

> In that case i have only to compare one channel (all the three
> will have the same information).
If you want to convert to greyscale, then yes, but that's not what I
meant.

> >and in this case IMO the approach with the separate
> > Delta-Values per channel makes more sense - and you don't
> > have to use always the same compare-delta for each channel
>
> ?? i get lost. I thought i already converted it to greyscale.
Did you? Why do you compare three channels then in your loop?

Think this will be my last reply in this thread - seems
I cannot keep-up with your logic.

Olaf



Re: shape recognition by Eduardo

Eduardo
Mon Oct 13 20:40:00 CDT 2008

> Think this will be my last reply in this thread - seems
> I cannot keep-up with your logic.

That's OK for me.

>> ?? i get lost. I thought i already converted it to greyscale.
> Did you? Why do you compare three channels then in your loop?

Change "i converted" to "you converted"
You are the one who mentioned luminance.

>> I think you mean to convert it to greyscale first.
> No.

What is luminance? It's the brightness that the human eye perceive
independently of the color.

>> Even if i set it to 32 it's not more tolerant.
> That's trivial - so you don't need to mention that explicitely.

Of course it's trivial.

The simple thing is that to compare the three channels separately is not the
same that to compare them all together.
And i think only one option is the right one (and it doesn't depend on the
image features).



Re: shape recognition by Peter

Peter
Tue Oct 14 04:36:47 CDT 2008

"Eduardo" <mm@mm.com> wrote in message news:gd0fc9$9d2$3@aioe.org...
> "Peter T" <peter_t@discussions> escribió en el mensaje
> news:umkBeDSLJHA.6000@TK2MSFTNGP04.phx.gbl...
>>> Analyze the image in this way:
>>> Start at the middle of each edge, and see the color of the pixels, each
>>> one going towards the center.
>>> Then go one pixel each time to one of the vertex and see if the same
>>> pattern repeats, but more inward than when i looked in the middle.
>>>
>>> I'm also thinking of making a function "ColorIsSimilar", because the
>>> color may be not exactly the same, but similar.
>>
>> When you say "similar" do you mean in terms of numerical RGB or
>> "visually".
>
> Good point.
> And of course, as they are images, they are for the human eye.
>
>> Point being, the eye does not perceive much separation with some colours,
>> eg greens, but very small differences in say cyan are very noticeable.
>>
>> If by similar you mean "visually" it might be worth looking into the 3D
>> "colour shape" or "colour space" (search w/out the "u"). There are
>> numerous algorithms out there of varying complexity to define a colour
>> shape. Having defined your space, fix your RGB's at points in the 3D
>> space, return their xyz coordinates form some arbitrary origin.
>>
>> The colour difference is the distance between the colours in the 3D
>> space.
>
> Well, the images can have a shadow, but they are just 2D (i think, though,
> i don't know when an image pass from 2D to be considered as 3D).
>
>>
>> If you are only looking for extremely small differences, eg up to about 5
>> in each RGB 0-255 scale (within range of say typical jpg representation
>> of same colour), it's probably OK to ignore the above for your purposes
>> and concentrate on what you are already doing.
>
> I'm looking for much bigger differences. For the kind of differences that
> the eye perceive as the outline of a shape (in a small bitmap).
>
> You made a good point here about the difference of sensitivity of the eye
> to different colors. I ignored that until now. I'll see what I'll do.
> I think for the time being i'll keep ignoring that, and when i have the
> recognition algorithm done, then i'll tweak the ColorsAreSimilar function.
>
> Thanks.
>

I think you have completely misunderstood what I meant by "3D colour shape",
it does not refer to your 2d image! It's merely one way to visualise and
compare individual colours.

This is probably not the right place to go into detail about colour, so just
a few things for you to look up elsewhere. There are many ways to define a
colour and most are definitions are multidimensional.

Here is just one way. First read up on the terms Hue, Saturation and
Luminance (HSL), colour-tone, colour intensity (mixture of pure colour with
grey of similar lightness) and luminosity (between absolute dark or black
and maximum brightness or white). An RGB colour can be redefined as HSL and
I assume functions have been posted in this group to convert RGB to HSL.

Now imagine two cones joined together, a bit like a spinning top. This is
our 3D colour shape. The vertical line between the points is the scale of
luminance. Any point on the circular faces where the cones join is 50% Lum,
the points are zero & 100% Lum respectively.

Take any horizontal circle through the double cone. Degrees around it
represent Hue. Rather than scaled at 0-360, Hue is normally measured as a
decimal 0-1 or a %. However I find it easiest to imagine a scale of 0-60
minutes of a clock. This places R, G & B at 0, 20 & 40 min, with yellow
(RG), cyan (GB) & magenta (BR) at 10, 30 & 50 minutes.

Saturation (grey to pure colour) is between zero on the vertical line
between the points, to 100% on the outer circumference.

So, convert your two RGB colours to HSL and place in the double cone, ie the
3d colour space. With a bit of geometry work out the xyz coordinates from an
arbitrary origin, eg the cone point that represents black. The colour
difference is the distance between the colours in the 3d space (square root
of the sum of the squares).

Unfortunately the human eye does not distinguish colour linearly in two
significant respects, our double cone 3d shape has limited use. The first is
the way eye separates colours, eg green wide banded vs cyan narrow banded
There is no one simple formula. The second is luminosity or lightness which
Olaf touched on. Green appears much brighter than blue of similar intensity.
This aspect is easy to compensate for with simple weighting, eg
LumA = 0.299 x Red + 0.587 x Green + 0.114 x Blue
ref. Rec 601 CIE
Notice how much more weight is given to green than blue.

As I mentioned previously there are plenty of 3d colour space definitions
out there. They are all subjective, based on how people on average perceive
colours, with greater or lesser complexity/simplification, depending on
needs.

End of colour intro !

I have no idea if you actually need to look further into the above, I guess
it really depends on what colours you have and how you need to differentiate
them.


You original question is interesting, in effect, pattern recognition. This
is probably bread and butter stuff to the "AI" guys, it might be worth
asking in one of their groups for a general approach (if you do - post a
link back here). Perhaps though as this task is relatively simple a brute
force approach is all that's required.

It's a shame you rubbed Olaf up the wrong way. You might consider re-reading
his suggestions and revising your comments, but that's up to you.

Regards,
Peter T




Re: shape recognition by Eduardo

Eduardo
Tue Oct 14 06:45:27 CDT 2008


"Peter T" <peter_t@discussions> escribió en el mensaje
news:uTJasBeLJHA.3744@TK2MSFTNGP06.phx.gbl...

> End of colour intro !

OK, I understood what you meant with 3D.

> I have no idea if you actually need to look further into the above, I
> guess it really depends on what colours you have and how you need to
> differentiate them.

It's very interesting, but in this case i don't need to do something so
elaborated.

>
> You original question is interesting, in effect, pattern recognition. This
> is probably bread and butter stuff to the "AI" guys, it might be worth
> asking in one of their groups for a general approach (if you do - post a
> link back here). Perhaps though as this task is relatively simple a brute
> force approach is all that's required.

Yes... my situation is much, much simpler.
I have almost done the routine i needed. It's just brute force.

>
> It's a shame you rubbed Olaf up the wrong way. You might consider
> re-reading his suggestions and revising your comments, but that's up to
> you.

Why you say that?
I pointed that comparing the three channels separately wasn't the same that
comparing them as a whole.

note: in HLS, i think the L means "lightness" and not "luminance".

Regards.

>
> Regards,
> Peter T
>
>
>





Re: shape recognition by Larry

Larry
Tue Oct 14 07:15:49 CDT 2008


"Eduardo" <mm@mm.com> wrote

> note: in HLS, i think the L means "lightness" and not "luminance".

Those two are synonym words, but luninance is the correct term.
Open MSPaint, select Edit Colors under the Colors menu then
click on the Define Custom Colors button. Note whats to the left
of the Red, Green, and Blue section.

LFS



Re: shape recognition by Eduardo

Eduardo
Tue Oct 14 07:26:29 CDT 2008

"Larry Serflaten" <serflaten@usinternet.com> escribió en el mensaje
news:OQrEGafLJHA.5648@TK2MSFTNGP05.phx.gbl...
>
> "Eduardo" <mm@mm.com> wrote
>
>> note: in HLS, i think the L means "lightness" and not "luminance".
>
> Those two are synonym words, but luninance is the correct term.
> Open MSPaint, select Edit Colors under the Colors menu then
> click on the Define Custom Colors button. Note whats to the left
> of the Red, Green, and Blue section.

Ah, OK.

> LFS
>
>



Re: shape recognition by Peter

Peter
Tue Oct 14 07:54:08 CDT 2008

"Eduardo" <mm@mm.com> wrote in message news:gd20pa$k9e$1@aioe.org...
>
>
> note: in HLS, i think the L means "lightness" and not "luminance".


There are various definitions of "lightness", "brightness", "luminance",
"luminosity" and other closely related terms. They can have the same or
different meanings depending on context, source, opinion, and the weather.

Luminance is normally projected light, such as emitted from a monitor,
(maxRGB + minRGB)/2, it can also mean candle power. Luminosity is generally
taken to mean same, though strictly speaking it's not quite.

More generally "lightness" tends to refer to reflected light. "Lightness"
may be calculated linearly or weighted according to colour to compensate for
the human eye perception, eg the LumA formula I mentioned.

For the purposes of the that little colour intro the exact definition really
doesn't matter.

Regards,
Peter T