# Thread: change color in picture

1. ## change color in picture

I need help ASAP in changing color of a picture in jpeg format. I place image in picturebox and I want to edit the picture's certain part color. eg; I want to change a wall's color of a bedroom picture. how can I do dis????

2. ## Re: change color in picture

You need to scan through the image pixel by pixel and read the color. Assuming that you are not searching for an exact RGB value, you will have to use an algorithm to work out how different the pixel color is from the color you are searching for. If the color difference is withing a certain range, then you change it. Again, you might not want to change this to an exact color, if you change all blue-like colors to RGB(0,0,255) then it will look very artificial, so maybe you can use the difference from before to calculate the type of blue.
You want to work on a bitmap. Only use the picturebox to display the results.
To scan through an image one pixel at a time you use nested for loops

for y = 0 to height -1
for x = 0 to width - 1
next : next

To read a pixel you can use bitmap.readpixel. This can be optimised, but get working code first.
To calculate how different a testColor (R0,G0,B0) is from tarGetColor (R1, G1, B1)

colorDifference = _
Math.Sqrt(((R0 - R1) ^ 2) + ((G0 - G1) ^ 2) + ((B0 - B1) ^ 2))

(this is the distance between 2 points on a 3d scale - you can think of a color as being a point in 3d space with red, green, blue axes)

Then if the distance is > some threshold set the pixel to the target color.

See the color extraction filter in my conversion of C.Graus' Image processing articles

3. ## Re: change color in picture

can I hav code example for dat.....

4. ## Re: change color in picture

hallo.....
somebody help....
Im not so good in Vb.net so plez giv me coding for this problem.... I need it ASAP....

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•