# How to determine areas of pixels of different colors or luminosities?

I want to create a program that determines all the areas of a given picture that have a different color, or the same color with different luminosities.

Are there known algorithms that do this job ? I would love to study such algorithms and implement them.

Thank you in advance for any help.

• It might be worth converting the image into YCrCb and discarding the Luma component Jan 19 '15 at 21:11
• This is a big topic with lots of kinds of answers. You can make a histogram of brightness for all the pixels. But to decompose the 2d structure of the image, terms like feature extraction, boundary detection, flood-fill, and posterization may provide some starting points... Jan 19 '15 at 21:22
• I think this is too broad. You can start by what @david suggested. Otherwise try to reduce the scope of the question, for example, why do you want to do this ? maybe this is not the solution you want. Maybe if you tell us more we can give you better answers, so far I suspect the answers to be generic. Jan 20 '15 at 10:15
• @concept3d Thank you for the advice. I thought my question is clear, but I will edit it in few hours. Regards
– user59526
Jan 20 '15 at 10:44

I've been researching Sobel Filters for edge detection. I then use that information to identify bounding information so I can crop out borders programmatically.

I also like OMGtechy's comment on converting to YCrCb or YUV and throwing out the Luma component. MSDN has an article on RGB to YUV Strangely enough, looks like it's HLSL (shader).

• I hadn't heard of those filters, interesting. Jan 20 '15 at 21:24

One possible approach is this:

1. Convert to the YCrCb colour space and discard the Luma (Y) component.
2. Compute a quality metric (see below),
3. See if the quality metric is above a threshold (see below),

Quality Metrics

• ASNR
• PSNR
• SSIM

Threshold

This will be largely trial and error; you'll just have to tweak it until you get the results you want. I'd start at about 50 for PSNR/ASNR, or 0.9 for SSIM and work from there.

• @Begueradj if you're happy with the answer, please accept it when you can. Otherwise, suggest improvements and I'll do my best to make them. Please note that problems with specific implementations are separate questions and should not be included in the answer to this one (although I may link them at a later date if people find this useful). Jan 19 '15 at 21:26