- 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?
2 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
回答(1 个)
Prahlad Gowtham Katte
2022-3-15
Hello
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;
img=imread('SamplePicIR.png');
i=rgb2gray(img); %rgb to gray conversion
imshow(i);
bin=imbinarize(i);%gray to binary conversion
imshow(bin);
bin2(:,:,1)=bin;
bin2(:,:,2)=bin;
bin2(:,:,3)=bin;
z=immultiply(img,bin2);%Applying bin2 as a mask
imshow(z);
For more information, please refer to the following links:
Hope it helps!
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Processing Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!