image - How to replace a color by another? -


this general question (between programming , math):

how replace color in bitmap?

i assume bitmap 2d-array
example : let's replace rgb color [234,211,23] rgb color [234,205,10].

how color replacement, such neighbour colors replaced ? i.e. smooth color replacement.

i assume there exists methods linear interpolation neighbour colors, etc.

what classical ways this?


here example of how detect color rgb 234,211,23 , neighbour colors in 500x500px image bitmap array x:

for in range(500):   j in range(500):     if abs(x[i,j][0] - 234) < tresh , abs(x[i,j][1] - 211) < tresh , abs(x[i,j][2] - 23) < tresh:         x[i,j] = ... # how set new color in smooth way? 

i think approach can use change whole image new color space, i'd rather use hsv color space instead of rgb, can find info here: hsv color space.

when wish search specific color, rgb model not best option principal reason large changes between brightness , darkness of color. thresholds on rgb color space not useful in case. in hsv color space have channel select color of interest , other 2 channels saturation , brightness of color. can accurate results using hue channel (the first). thing need take care in realize need work channel circular buffer because maximum , minimum value similar in color, both red color.

once have detected color can set new 1 , can keep saturation , brightness properties of old color, doing color changes smoother.


Comments

Popular posts from this blog

How to provide Authorization & Authentication using Asp.net, C#? -

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

How to use Authorization & Authentication in Asp.net, C#? -