Effacer les filtres
Effacer les filtres

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

10 vues (au cours des 30 derniers jours)
Dayangku Nur Faizah Pengiran Mohamad
Commenté : Rik le 2 Juil 2024 à 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 commentaire
Rik
Rik le 2 Juil 2024 à 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?

Connectez-vous pour commenter.

Réponses (0)

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by