why does bwperim make the border WHITE?!!

1 visualización (últimos 30 días)
Steven
Steven el 25 de Dic. de 2013
Editada: Steven el 1 de En. de 2014
I want to use bwperim to calculate the perimeter of an object, but I got a strange thing!
I use bwperim in two different states: first to the original binary image and second to its inverse, i.e.,:
%%binaryImage
perim1 = bwperim (binaryImage);
perim2 = bwperim (~binaryImage);
The strange thing is that the first one (perim1) gives an image that is almost black (except the detected boundaries, of course), but:
Exactly, the borders of the whole image, I mean the FIRST row and column and the LAST row and column are white! I mean it has given the value of 1 to the pixels of the image border! Why?!!
For the second one (perim2), this is not the case and it is correct as the original image.
The binary image:
perim1 (with white border):
perim2:
Thanks so much!
Steven
  6 comentarios
Walter Roberson
Walter Roberson el 25 de Dic. de 2013
but be careful about the possibility that some of your image touches the border.
Steven
Steven el 25 de Dic. de 2013
for creating binary, I used:
binaryimage = im2bw(gray_scale_image,graythresh(gray_scale_image)

Iniciar sesión para comentar.

Respuesta aceptada

Image Analyst
Image Analyst el 25 de Dic. de 2013
I don't think perim1 should have the edges of the image as white. Can you post the binary image so I can check it out?
  4 comentarios
Steven
Steven el 25 de Dic. de 2013
Thanks.
How about using imclearborder? It does the same right?
Thanks.
Steven
Walter Roberson
Walter Roberson el 25 de Dic. de 2013
Erasing the borders yourself is safer if you might possibly have an object touching the edge. If you know you will not, then imclearborder() is more convenient.

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by