フィルターのクリア

Free hand cropping an image

1 回表示 (過去 30 日間)
Jane
Jane 2013 年 11 月 23 日
コメント済み: Image Analyst 2020 年 7 月 22 日
Hello all,
I saw this post recently on this forum by Sean de Wolski on 19 Jun 2013. This is to free hand crop an image and blackout the rest. However, I'm using a jpg and it's causing the rest of my image to have a blueish tint. Do you know how to fix this? Thanks in advance!!
I = imread('cameraman.tif');
imshow(I);
h = imfreehand; %draw something
M = ~h.createMask();
I(M) = 0;
imshow(I);
  2 件のコメント
green
green 2017 年 5 月 24 日
M = ~h.createMask(); could you please explain this for me?
Image Analyst
Image Analyst 2017 年 5 月 25 日
h.createMask() creates a binary image mask that is true/1/white inside the drawn area and false/0/black outside the drawn area. Using ~ inverts that mask so it's black inside the drawn area and white outside.

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

採用された回答

Image Analyst
Image Analyst 2013 年 11 月 23 日
Don't use jpg images. I never do. They are not suitable for doing image analysis. Use PNG format because it's lossless compression.
I used your code and did not get a bluish tint.
  3 件のコメント
Mathews Jabaraj Soloman
Mathews Jabaraj Soloman 2020 年 7 月 21 日
編集済み: Mathews Jabaraj Soloman 2020 年 7 月 21 日
I am using an ultrasound image with .png extension. While using the above code I am getting the bluish color other than the ROI drawn both using 'imfreehand' and 'drawfreehand'. And my image has the size of "899x1442x3". It has 3 channel, does it has to do something with the bluish color of the background.
looking forward for answers.
Image Analyst
Image Analyst 2020 年 7 月 22 日
I don't know what that means. Why would an ultrasound image, which is grayscale, have a bluish color. You forgot to post your image, and your code. Start a new thread with those and tell us there (not here) what region of the image you're outlining, and if "getting the bluish color" means that you are outlining the blue region, or somehow you get a bluish tint to the image after you do the outlining.

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

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by