Click here to Skip to main content
15,885,244 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi all
how can i detect all red objects in an image?
Posted
Updated 27-Oct-11 23:11pm
v2

AForge.Net Framework[^] might be something you want to have a look at.
 
Share this answer
 
Comments
Mehdi Gholam 28-Oct-11 5:21am    
Nice link, 5!
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.
C#
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!
 
Share this answer
 
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
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.
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900