Click here to Skip to main content
14,429,185 members
Rate this:
Please Sign up or sign in to vote.
See more:
hi all
how can i detect all red objects in an image?
Posted
Updated 28-Oct-11 0:11am
v2
Rate this:
Please Sign up or sign in to vote.

Solution 3

AForge.Net Framework[^] might be something you want to have a look at.
   
Comments
Mehdi Gholam 28-Oct-11 5:21am
   
Nice link, 5!
Rate this:
Please Sign up or sign in to vote.

Solution 1

Well the image is made of pixels (at it's most basic) and you can get at the pixel data using the GetPixel method if you load it into a Bitmap.
That would give you a Color structure of the pixel value, which has an "R" property, which is the Red info.
Bitmap b = (Bitmap) Image.FromFile(@"D:\Temp\myPic.jpg");
Color c = b.GetPixel(0, 0);
Console.WriteLine(c.R);



But be aware that many colours that have a Red component do not look red!
   
Comments
graduate student 28-Oct-11 5:12am
   
thnx, but i mean all red objects
OriginalGriff 28-Oct-11 5:33am
   
Then I would suggest you start with Google: That is way too big a subject to answer here!
http://www.google.co.uk/search?aq=f&gcx=c&sourceid=chrome&ie=UTF-8&q=object+detection+codeproject#pq=object+detection&hl=en&sugexp=kjrmc&cp=19&gs_id=h&xhr=t&q=object+detection+c&pf=p&sclient=psy-ab&source=hp&pbx=1&oq=object+detection+c%23&aq=0b&aqi=g-b1&aql=f&gs_sm=&gs_upl=&bav=on.2,or.r_gc.r_pw.,cf.osb&fp=c84f2dae6b7ee35c&biw=1387&bih=906
Rate this:
Please Sign up or sign in to vote.

Solution 2

1. Read pixel RGB colour values from your image. You don't indicate whether you are reading a displayed image or image from file so that's up to you.
2. Decide what range of RGB values you consider to be 'red'. e.g. is pink 'red' enough for you?
3. Filter all pixels for your range of 'red' RGB values.

Hint: you've put very little effort into framing this question. Consequently it's difficult to know what you're having trouble with. More effort might yield better answers.
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100