Filter löschen
Filter löschen

Thresholding and Binarising and doubling

2 Ansichten (letzte 30 Tage)
Hege
Hege am 18 Sep. 2020
Kommentiert: Hege am 9 Okt. 2020
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)

Akzeptierte Antwort

Gouri Chennuru
Gouri Chennuru am 25 Sep. 2020
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!

Weitere Antworten (0)

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by