This content has been marked as final. Show 5 replies
Yes, you're right - it is complicated!
The reason is that with a photo of a guy wearing a blue shirt, that blue shirt is actually made up of hundreds of different subtle shades of blue.
So to implement this, you'd need to perform a number steps, some of which are fairly complex:
1) allow the user to select a point in the image
2) read the colour at that point. You might find you need to take an average of a small area around that point to get a better approximation of the percieved colour at that point because the colour of pixels within a seemingly 'flat' area of colour can actually vary significantly. (this is why the photoshop inkdropper tool offers 3x3 and 5x5 average options).
3) gradually 'scan' outwards from the pixel coordinate clicked on, checking each adjacent pixel in the image and comparing the difference in colour value against the initial colour selected (using getPixel). If it is within a certain tolerance, you can include it in the selection. You'll need to create an array or another image object to store the results in. Repeat this process until there are no more adjacent pixels that fall within the colour tolerance range.
4) Use an RGB->HSB routine to convert the colour values to HSB, so that you can then adjust the 'Hue' value, and finally convert back to RGB. I have one here: http://robotduck.com/content/articles/director/imageManipulation/shiftHue.txt
And whether it has a name?..
well, the tool which selects an area within a certain colour range in photoshop is called the 'magic wand', so I guess that's a good way to refer to it - a magic wand function. And to change the colour by 'rotating' the colour values through the colour spectrum (which is what my example code does) is called 'shifting the hue' of the colours.
hope this helps!
I got the selection part working the way you mentioned...seems to be working ok...
thanks for the help
I think you should checkmark the post that gave the answer, as "the answer" instead of marking the post with the question as "the answer." Not that it would make a lot of difference on a thread this short, but as a general rule. On a longer thread, it would make more difference.