how to resize an object in binary image ?

i try to resize (minimize) an object in binary image, but I get the whole picture is to be small. even though I just wanted to minimize only its object. please help me. thanks

 Respuesta aceptada

Image Analyst
Image Analyst el 20 de Mzo. de 2016

0 votos

If you want to shrink a binary image in place, without cropping out, then you can use imerode() to eat away outer layers of the binary blob(s).

4 comentarios

ElizabethR
ElizabethR el 20 de Mzo. de 2016
Editada: Walter Roberson el 20 de Mzo. de 2016
hi Image Analysis, no.. i don't meant to shirk object.
i have image like this. i want to resize object, so it becomes like the image on the right.
how to make it ? thanks
You can use padarray() to add black all around the image. This will enlarge the array. Then, to make it smaller, to any size, even the original size, you can use imresize():
binaryImage = padarray(binaryImage, 100);
binaryImage = imresize(binaryImage, [300, 300]); % Whatever size you want.
If you want it the same size as the original, do this:
[rows, columns] = size(binaryImage); % Save original size.
binaryImage = padarray(binaryImage, 100);
binaryImage = imresize(binaryImage, [rows, columns]); % Same size as original.
ElizabethR
ElizabethR el 20 de Mzo. de 2016
thank you very much Image Analyst, it working perfectly.. :D may i ask one question again ? i want to convert image into polar coordinate(unit circle) with the object is on the center of the circle. i try to convert this image using cart2pol, but i can get image like this. So, how to make this image ? :D thank you so much
You can create a circle mask as shown in the FAQ: http://matlab.wikia.com/wiki/FAQ#How_do_I_create_a_circle.3F
So if the mask is true in the circle and false outside, do
binaryImage(~mask) = true;
For what it's worth, I've also attached a circle masking demo.

Iniciar sesión para comentar.

Más respuestas (1)

Walter Roberson
Walter Roberson el 20 de Mzo. de 2016

0 votos

You need to extract the object first and imresize() on the extracted part. Consider using regionprops with the Image property to get the extracted object.

3 comentarios

ElizabethR
ElizabethR el 20 de Mzo. de 2016
hi Wlater, thanks for answare my question. but, How to extracted the object ?
props = regionprops(YourBinaryImage, 'Image');
extracted_image = props.Image;
smaller_extracted = imresize(extracted_image, [64 64]); %example output size
ElizabethR
ElizabethR el 21 de Mzo. de 2016
hi Walter, thanks you so much.. it's working perfectly, now i can extract the object .. but, i want the background ( black ) still there.

Iniciar sesión para comentar.

Categorías

Más información sobre Convert Image Type en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 20 de Mzo. de 2016

Comentada:

el 21 de Mzo. de 2016

Community Treasure Hunt

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

Start Hunting!

Translated by