image thumbnail

Colour based segmentation

version 1.2.0.0 (101 KB) by Michala
Compute the area of the given color (color band) in the image

1.7K Downloads

Updated 28 Feb 2014

View License

The script computes how many [%] of the image the chosen colour (colour band) occupies.
Input: you have to know the RGB numbers (or bands) of the colour of interest.
The colour bands better capture the colour fluctuations.
Output: [%] of the image that are occupied by the given color(s). Images of Red, Blue, and Green masks of the original colour image, histograms of red, blue, and green parts of the image, distribution of the size of the blobs, mask excluding the small blobs, mask with the filled holes, comaprison of the original and final image, summary table: number of the blobs, their areas [pixel], and their colour. The resultant table is saved in *.xls file - blobs' area, colour, colour bands (user input), minimal size of the blobs (user input), [%] of the image covered by the chosen colour.

Notes:
1) you can decide whether you want to get rid of small blobs of the colour areas (area smaller than given "user-input" value will be excluded)
2) you are asked if you want to fill the holes in the blobs found.
3) use "imtool" to explore the RBG colors in the image

Image source: Rocks under the Microscope
www.earth.ox.ac.uk/~oesis/micro/

Literature:
1) rgb table: http://www.rapidtables.com/web/color/RGB_Color.htm
2) bwareaopen - http://www.mathworks.ch/ch/help/images/ref/bwareaopen.html
3) matlab webinar: http://www.mathworks.ch/videos/medical-imaging-workflows-with-matlab-81850.html?form_seq=conf924&confirmation_page&wfsid=5335062

Cite As

Michala (2021). Colour based segmentation (https://www.mathworks.com/matlabcentral/fileexchange/45679-colour-based-segmentation), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2011b
Compatible with any release
Platform Compatibility
Windows macOS Linux
Acknowledgements

Inspired by: sublabel, SimpleColorDetection()

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!