How to crop images in Matlab based on Intensity Profiles?

6 ビュー (過去 30 日間)
Warid Islam
Warid Islam 2019 年 8 月 1 日
コメント済み: Warid Islam 2019 年 8 月 3 日
I have an image in Matlab which I want to crop based on the intensity profile. Below is my image.
I want to crop out the blue portion of the image based on the intensity profile. For example, based on the intensity profile, I want to crop the part of the image where the intensity of blue is higher than the other colors. Below is my sample code and example.
hFig = figure ;
subplot(1, 2, 1 );
rgbImage = imread('Intensity1.jpg ');
imshow(rgbImage )
subplot(1, 2, 2 );
croppedImage = rgbImage(200 : 400 , :, :);
imshow(croppedImage);
In the image above, it can be seen that the blue portions still remain in the image which I don't want. Any help would be very much appreciated. Thank you.
  13 件のコメント
Image Analyst
Image Analyst 2019 年 8 月 3 日
Looks like you've accepted the answer below. I am dealing with an OCT project in my company right now. I would not segment/threshold the RGB image like in the answer and like you've done it above. You have the original gray scale image and that's what you need to threshold. Do not do it on the RGB image.
brightStuff = grayImage > some Value;
Warid Islam
Warid Islam 2019 年 8 月 3 日
Hi Image Analyst,
Thank you for the suggestions. I would implement those in the final output.

サインインしてコメントする。

採用された回答

awezmm
awezmm 2019 年 8 月 3 日
Try this where img is your original image:
% get red, green, blue channels
redC = img(:,:,1);
greenC = img(:,:,2);
blueC = img(:,:,3);
% mask where red channel is greater than blue channel and green channel greater than blue channel
mask = redC > blueC & greenC > blueC;
% overlay mask into original image
finalimg = bsxfun(@times, img, cast(mask,class(img)));
%plotting
figure
subplot(1,2,1)
imshow(img)
subplot(1,2,2)
imshow(finalimg)
  2 件のコメント
Warid Islam
Warid Islam 2019 年 8 月 3 日
Hi Awezmm,
That works perfectly for me. Thank you very much for the help.
KALYAN ACHARJYA
KALYAN ACHARJYA 2019 年 8 月 3 日
+1 Great!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeImage Processing Toolbox についてさらに検索

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by