Code covered by the BSD License  

Highlights from
SimpleColorDetection

4.6

4.6 | 5 ratings Rate this file 78 Downloads (last 30 days) File Size: 6.61 KB File ID: #26420
image thumbnail

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.
Comments and Ratings (9)
20 Jan 2010 Biplab  
20 Jan 2010 Image Analyst

The Mathworks has a LAB color space classifier demo at
http://www.mathworks.com/products/image/demos.html?file=/products/demos/shipping/images/ipexfabric.html
It's also worth looking at.

05 Feb 2010 Husam Aldahiyat  
05 Feb 2010 Ravish  
28 Jul 2010 Azy  
22 May 2011 German Espinal

Buenas noches

Soy German Espinal, un estudiante de semestre 8 de la Universidad de Cundinamarca.

Actualmente estoy desarrollando un proyecto para la materia de Inteligencia Artificial y me urge un codigo Matlab para terminarlo.

Yo he encontrado muchos buenos videos y material sobre Matlab y creo que gracias a ellos he aprendido mucho.

Basicamente lo que necesito es:

Poner una tarjeta o un carton pintado de un color (puede ser primario o no) frente a la webcam de mi computadora
Capturar esta imagen si es necesario
Decir que color es ese : rojo, amarillo, verde, azul, blanco, negro, etc.

Parece simple verdad ? He buscado mucho, pero no se si debo capturar la imagen, hacerle algun tratamiento, trabajar en RGB o en que codigo de color, como capturar ese codigo y compararlo para poder dar el resultado.

Mil gracias !

Germán Espinal germanespinal@hotmail.com

22 Oct 2011 divya

hello
i like your work
sir i want to detect two colors blue and red in the same image..i am not able two do that..please tell me how to do that..

05 Nov 2011 Image Analyst

If anyone wants to ask me a question, click my name above, then click the "Contact Author" link.

24 Jan 2012 Indika Kulatunga

Thank you Image Analyst for your help.

Please login to add a comment or rating.
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.

Tag Activity for this File
Tag Applied By Date/Time
color Image Analyst 20 Jan 2010 10:55:20
color classification Image Analyst 20 Jan 2010 10:55:20
color detection Image Analyst 20 Jan 2010 10:55:20
color detection Shane 08 Nov 2010 15:52:15
color detection ketan chaudhari 02 Apr 2011 00:50:06

Contact us at files@mathworks.com