Borrar filtros
Borrar filtros

How to use looping method to crop image dynamically (auto-cropping)?

11 visualizaciones (últimos 30 días)
Dayangku Nur Faizah Pengiran Mohamad
Comentada: Rik el 2 de Jul. de 2024 a las 11:28
Hello. How to crop image using dynamic cropping method in matlab? Is there any example implementation codes?
Lets say, my original image have two different sizes which are 482 x 841 pixels and 608 x 865 pixels, so can I use loop step at first to extend the pixels which those that not enough pixels if I want to crop into 512 x 512 pixels? If the image size is enough to crop into 512 x512 pixels so no need to extend the pixels. I recently use this code:-
%To read input image
I=imread('1_776.jpg');
imfinfo('1_776.jpg')
First image, image size 482 x 841 px
Second image, image size 608 x 865 px
%To resize image
out = padarray(I, [10 10], 0, 'both');
imshow(out);
imwrite(out,'resize1.jpg');
but this is manual. Now I want it to automatically crop only specific area.
  1 comentario
Rik
Rik el 2 de Jul. de 2024 a las 11:28
So you want to crop images if they exceed 512 pixels in either height or width, and want to pad them with black if they are smaller than 512x512?

Iniciar sesión para comentar.

Respuestas (0)

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by