Thresholding and Binarising and doubling

1 回表示 (過去 30 日間)
Hege
Hege 2020 年 9 月 18 日
コメント済み: Hege 2020 年 10 月 9 日
Actually, I have very simple doubt. what is the difference between following commands and its output, what is the difference between b,c and d? please explain clearly. I know this is very simple thing. but I was bit confuse in a something in an online course. if we want to threshold a grey scale array, do we need to definetely convert it to binary image and do the thresholding like b?
a=imshow('cameraman.tif'); % a is a 256x256 uint8 greyscale image
b=im2bw(a,155/255); % imbinarize can be used alternatively
c=a>155
d=double(a)

採用された回答

Gouri Chennuru
Gouri Chennuru 2020 年 9 月 25 日
Hi Yasasween,
In the statement b,
b=im2bw(a,155/255);
b = im2bw(I,level) im2bw” produces binary images from indexed, intensity, or RGB images. To do this, it converts the input image to grayscale format (if it is not already an intensity image), and then uses thresholding to convert this grayscale image to binary. The output binary image has values of 1 (white) for all pixels in the input image with luminance greater than level and 0 (black) for all other pixels.
im2bw is not recommended. Use imbinarize instead. The default luminance threshold of im2bw is not optimal for most images.
You can use the imbinarize, do the thresolding convert it to a binary image.
In the statement c,
c=a>155
It just returns a logical array with elements set to logical 1 (true) where A is greater than B; otherwise, the element is logical 0 (false). The test compares only the real part of numeric arrays. gt returns logical 0 (false) where A or B have NaN or undefined categorical elements.
In the statement d,
d=double(a)
double converts symbolic values to MATLAB double precision, so here it converts from uint8 to double type.
Hope this Helps!
  1 件のコメント
Hege
Hege 2020 年 10 月 9 日
Thank you so much Gouri.This helped a lot!

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

その他の回答 (0 件)

製品

Community Treasure Hunt

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

Start Hunting!

Translated by