Effacer les filtres
Effacer les filtres

how to use crop using coordinate?

2 vues (au cours des 30 derniers jours)
reza hamzeh
reza hamzeh le 24 Jan 2020
hi. i want to crop the red square from this pic using coordinate. lets suppose coordinate of the top-left point of the red square is w/2 and h/2
where w and h are width and hight of the pic respectively. and width and hight of the red square are 20 pixel. this is my code but it dosent work. plz help me.
pic=imread('b.jpg');
[w, h, numberOfColorChannels] = size(pic);
I=imcrop(pic,[w*0.5 h*0.5 20 20]);
imshow(I)
black.jpg
  2 commentaires
Spencer Chen
Spencer Chen le 24 Jan 2020
Would be great if you describe what did not work.
Rik
Rik le 24 Jan 2020
Also, it is probably a good idea to round your coordinates to integers.

Connectez-vous pour commenter.

Réponse acceptée

Walter Roberson
Walter Roberson le 24 Jan 2020
Modifié(e) : Walter Roberson le 24 Jan 2020
You need
[h, w, numberOfColorChannels] = size(pic);
not
[w, h, numberOfColorChannels] = size(pic);

Plus de réponses (0)

Catégories

En savoir plus sur Line Plots dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by