SimpleColorDetection
by Image Analyst
20 Jan 2010
(Updated 19 Aug 2010)
Script to do simple color detection in RGB color space. Finds red objects in the image.
|
Watch this File
|
| File Information |
| Description |
This script is a demo that shows you how to find objects of a certain color in an image. For this example I'm using the standard onion, peppers, or canoe image that ships with the Image Processing Toolbox. You can also select one of your own color images instead if you wish. Then I separate the image into its component red, green, and blue color bands. I compute thresholds, and ultimately find a mask for the red objects. Prompts will guide you through the demo step by step. I multiply this mask by the original image to show the image with only the red objects showing and everything else blacked out. This script can be adapted to find other colors (white, green, blue, yellow, etc.)
If you want to do any measurements of the red objects, I refer you to my blob measurement demo file at http://www.mathworks.com/matlabcentral/fileexchange/25157
Requires the Image Processing Toolbox. Tested with R2008b and R2010a. |
| Acknowledgements |
This submission has inspired the following:
Extract Red Objects from Aerial Image
|
| Required Products |
Image Processing Toolbox
|
| MATLAB release |
MATLAB 7.10 (2010a)
|
|
Tags for This File
|
| Everyone's Tags |
|
| Tags I've Applied |
|
| Add New Tags |
Please login to tag files.
|
| Updates |
| 10 May 2010 |
Added measurements of area, mean Red value, mean Green value, and mean Blue value for each red blob that was found. |
| 12 Aug 2010 |
Expanded screenshot, and fixed small bug that happened when you were using your own image instead of demo images. |
| 19 Aug 2010 |
Now allows non-indexed monochrome images (simple gray level images with no stored colormap), and gracefully handles cases where there are no red blobs at all. |
|
Contact us at files@mathworks.com