Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: sf::Color check to see if image has a lot of red  (Read 1528 times)

0 Members and 1 Guest are viewing this topic.

korovyev

  • Newbie
  • *
  • Posts: 2
    • View Profile
sf::Color check to see if image has a lot of red
« on: November 18, 2011, 03:19:36 pm »
Hey I just recently started messing with SFML and it seems to be the answer to a problem my brother is having that he asked me for help with.

His problem is he has a folder on his machine with about 30,000 small images of envelopes. I havent seen these so i dont know what they look like but he has to get all the red ones out of the folder and into another folder (i think..).

It seems I should be able to create a program with sfml that loops through the pixels in these images using:
Code: [Select]
sf::Color Color = Image.GetPixel(r,c);
using the rgb values returned from that how would I be able to tell if the pixel is mostly red? I know red is 255,0,0  .. but for all shades of red is there a general rule in these rgb values that makes it red? e.g. in RGB does R>G && R>B make that pixel red?

also how do you think this would perform? is it too brute or is there a more elegant approach? maybe not sfml?

Tex Killer

  • Full Member
  • ***
  • Posts: 242
    • View Profile
sf::Color check to see if image has a lot of red
« Reply #1 on: November 18, 2011, 04:33:44 pm »
I don't know other aproaches, although I think there are many...

You have to check a few things:
• The red channel must be the bigger, as you suggested, but you must ensure it has a considerable gap between it and the other channels. The color 255, 254, 254, for instance, is mostly white, and not red.
• The other two channels must be balanced, as it will change the color if you have one of them bigger than the other. 255, 150, 0 is orange, and not red. 255, 150, 150 is light red.

korovyev

  • Newbie
  • *
  • Posts: 2
    • View Profile
sf::Color check to see if image has a lot of red
« Reply #2 on: November 18, 2011, 05:35:08 pm »
Thanks for that. I know there are probably alot of easier approaches but I just want to use this as a little programming exercise for myself :roll: , sfml looks like its worth learning for me aswell.

 

anything