How can i get the percent of pixel for a certain color in C# ?
-
Tuesday, May 15, 2012 2:46 PMMy extended question is, how can you, count how much x-color has an image? I mean, i have a real-time image from an infrared camera,and when the temperature passes a certain value,the pixels in that area become red for example. How can i find out,how much (in percent) does the red area is,from the entire image (384x288)?
All Replies
-
Tuesday, May 15, 2012 3:04 PMYou can divide the image in squares, then calculate the dominant color for each one, for example http://chironexsoftware.com/blog/?p=60.
Don't do it directly on the Bitmap/Image class if you want to have acceptable perfomances.Matteo Migliore
Bloghttp://blogs.ugidotnet.org/matteomigliore
Twitterhttp://twitter.com/matteomigliore
CodePlex -
Tuesday, May 15, 2012 6:13 PMYour example is good but can't help me. Let me tell you more... My Infrared Camera image is broadcasted directly into a panel, in my code i dont have any bitmap, image, because they were used in an other library class. I just call that class and get the image in the panel. I now know if in some point of the image there is high temperature, and at that point an alarm will start. i just want to control the alarm meaning : i want the alarm to start only when there's a considerable number of pixels with that high temperature , i don't want to start the alarm when (absurdly speaking) there's a 50 degrees fly entering the room, only when there is a big object, or a person. For that i need to know in percentual how much of the image does the high temperature pixels ocupy ?
-
Tuesday, May 15, 2012 6:29 PM
It's quite clear, on which object do you want to work?
If you haven't a Bitmap, which is the object that you can analyze?Matteo Migliore
Bloghttp://blogs.ugidotnet.org/matteomigliore
Twitterhttp://twitter.com/matteomigliore
CodePlex -
Tuesday, May 15, 2012 6:47 PM
I have a function like this : if( currentEngine.Name=="Infrared") IR_Video.Handle.ToString(); IR_Video is a panel .
-
Thursday, May 17, 2012 2:54 PMModerator
Hi Alexandlu,
Frankly speaking, I am not sure how the Type store image. Could you please let me know some details about this type?
Have a nice day.
Alexander Sun [MSFT]
MSDN Community Support | Feedback to us
-
Thursday, May 17, 2012 3:48 PM
I solved it with a little help, in Visual C++. What do i have to do to close the topic? Thank you for the interest given, at least at this topic some1 answered me.- Marked As Answer by Alexander SunModerator Tuesday, June 05, 2012 8:54 AM
-
Friday, May 18, 2012 8:51 AMModerator
Hi Alexandlu,
I am glad to know your problem is resolved. You can post some core code here or describe the solution, which will be appreciated.
Have a nice day.
Alexander Sun [MSFT]
MSDN Community Support | Feedback to us

