How to choose a ROI in an image and mask the other data in a colored image?

4 views (last 30 days)
Ali Hariri
Ali Hariri on 13 Jan 2022
I have images in differet time steps (sample is attached) , I transfered them into M by N by T matrix. Now, I would like to Only have ROI (yellowish color whith all the information in this region) for all sequences. Then I need to have pixel data of a constant distance from border line i.e. to have data of radious in x direction.

Answers (1)

Prahlad Gowtham Katte
Prahlad Gowtham Katte on 15 Mar 2022
As per my understanding of your query you wish to mask the region other than the yellow-colored part of the image. You can convert the color image to binary and the white pixels represent the yellow-colored part acting as a mask. When you multiply the binary image with colored one. You get only the yellow-colored part and rest will be black. The following code will help to visualize the above.
clear all;
i=rgb2gray(img); %rgb to gray conversion
bin=imbinarize(i);%gray to binary conversion
z=immultiply(img,bin2);%Applying bin2 as a mask
For more information, please refer to the following links:
Hope it helps!




Community Treasure Hunt

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

Start Hunting!