Since we are into masking processes, a valid question deriving from the previous section would be: since the mask we generated is two-dimensional, how can we use it to perform masking on a three-dimensional (color) image?
The answer to the question is rather straightforward; we will actually perform separate masking in each color channel, always using the same binary mask. The tricky part of this process is that after we perform separate masking in all three channels, we will have to join the results back together to acquire the final image. A very important MATLAB function, that allows us to join matrices, is cat
. This function normally takes N + 1 inputs, where N is the number of matrices we wish to join. In the case of a color image, cat
would be called with four inputs. The first one is the dimension along which we want the concatenation to occur and the next three inputs will be the R, G, and B color channels. Let's show this with an example:
>> img = imread...