Cut a .JPG image

조회 수: 1 (최근 30일)
Riccardo Rossi
Riccardo Rossi 2019년 2월 19일
편집: KSSV 2019년 2월 19일
Hi everybody,
i would like to cut a .JPG image. To do this i used that script but it does not run:
X=imread('C:\Users\Utente\Desktop\DSC_0183.JPG');
[columns,rows,colors]=size(X);
X2 = imcrop(X,[400, 1, rows-400, columns]);
imshow(X2)
With X=my image and X2=new image
and 400, 1=coordinates of the upper left corner of the specified rectangle
and rows-400, columns= coordinates of the bottom right corner of the specified rectangle.
In particular the image (X2) is correctly cut to the left but not to the right. How can i resolve it?
Thank you!!

답변 (1개)

KSSV
KSSV 2019년 2월 19일
Select your region manually.
X=imread('C:\Users\Utente\Desktop\DSC_0183.JPG');
[columns,rows,colors]=size(X);
X2 = imcrop(X);
imshow(X2)
  댓글 수: 4
Riccardo Rossi
Riccardo Rossi 2019년 2월 19일
I cut it manually and the X,Y rectangle coordinates are:
400, 1 (upper left corner);
2592, 1 (upper right corner);
400,2000 (bottom left corner);
2592, 2000 (bottom right corner)
How can i write the script to do this automatically?
KSSV
KSSV 2019년 2월 19일
편집: KSSV 2019년 2월 19일
X=imread('C:\Users\Utente\Desktop\DSC_0183.JPG');
[columns,rows,colors]=size(X);
[X2,R] = imcrop(X);
imshow(X2)
X3 = imcrop(X,R);
imshow(X3)

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by