- Multiply two images or multiply image by constant - MATLAB immultiply (mathworks.com)
- Binarize 2-D grayscale image or 3-D volume by thresholding - MATLAB imbinarize (mathworks.com)
How to choose a ROI in an image and mask the other data in a colored image?
4 views (last 30 days)
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.
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.
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!