View Single Post
Old 03-29-2008, 04:24 AM   #7 (permalink)
DeMo
The Contributor
 
DeMo's Avatar
 
Join Date: Jan 2008
Location: Brazil
Posts: 77
Thanks: 14
DeMo is on a distinguished road
Default

It's not perfect because the image has different yellow tones near the edges and these pixels are not passing the colormatch function.

To make it better you'll need to implement a tolerance system.
The tolerance can be a value from 0 to 255 and it defines a range in which the pixels pass or not the colormatch function.

In your code you were trying to match the FCFF00 (252, 255, 0) pixels.
You have some pixels that are clearer and some that are darker than this color. To match them let's say you set a tolerance of 30.

First you calculate the color ranges.
RED
lower range: 252 - 30 = 222
upper range: 252 + 30 = 255 (because 255 is the maximum value for RGB colors)

GREEN
lower: 255 - 30 = 225
upper: 255 + 30 = 255 (same reason as red)

BLUE
lower 0 - 30 = 0 (because you can't have a negative value for RGB colors)
upper: 0 + 30 = 30

FINAL COLOR
lower: (222, 225, 0) = #DEE100 (reference)
upper: (255, 255, 30) = #FFFF1E (reference)

Now for each pixel in the image your colormatch function is going to check if the pixel color is between those two tones, if it is.. you change it's color.

One thing to note is that different tones are used in the image edges to achieve a smoothing effect. Using a tolerance system you can match those pixels, but if you change all of them to the same color you're still going to miss some quality at the edges.
Send a message via ICQ to DeMo Send a message via MSN to DeMo Send a message via Skype™ to DeMo
DeMo is offline  
Reply With Quote