Are image morphological operations invalid for RGB images?

6 views (last 30 days)
Most (if not all) of the morphological operations (e.g. imdilate, imerode, imtophat, imbothat) specify that the input image should be grayscale or binary. However, using an RGB image does not yield an error. Why is this? Is it ill-advised to use these functions with RGB (or other 3D) images?

Accepted Answer

Image Analyst
Image Analyst on 10 Oct 2015
It treats it like a 3D volumetric image, like a CT or MRI image, not like a 2D color image. However, it can operate color plane - by - color plane like I think you want, if you give it a kernel that is flat (no extent in the Z direction). You just have to know what you're doing. Usually doing morphological operations on the RGB color channels does not make sense and can produce color artifacts, whereas for a volumetric image it does make sense.
  2 Comments
Matthew Eicholtz
Matthew Eicholtz on 10 Oct 2015
Thanks Image Analyst; that makes sense. To give some context, I am computing saliency maps from color images and wanted to reduce the effect of nonuniform illumination by running a bottom-hat filter first. The results looked good (i.e. the filter accomplished what I intended), but I wasn't sure if I did something ill-advised by leaving the image as RGB during filtering.
Image Analyst
Image Analyst on 10 Oct 2015
Well if it works and you're happy with the results, then fine. But you may find that how well objects "survive" that filtering very much depends on the relative size of your object and your filtering window width. You may also find some share artifacts and some extra noise than some other methods might give. The bottom hat filter is the morphological closing minus the original image. Basically it's assuming the local max will be the background image and this can be noisier than say, fitting a smoothed or regression function. But it's easy, and if it works, then use it.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!