Thresholding and Binarising and doubling

4 visualizaciones (últimos 30 días)
Hege
Hege el 18 de Sept. de 2020
Comentada: Hege el 9 de Oct. de 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)

Respuesta aceptada

Gouri Chennuru
Gouri Chennuru el 25 de Sept. de 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!
  1 comentario
Hege
Hege el 9 de Oct. de 2020
Thank you so much Gouri.This helped a lot!

Iniciar sesión para comentar.

Más respuestas (0)

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by