Use ginput to crop an image

8 次查看(过去 30 天)
k
  1 个评论
KSSV
KSSV 2020-6-19
Why ti pick points using ginput? You can use imcrop right?

请先登录,再进行评论。

采纳的回答

KSSV
KSSV 2020-6-19
编辑:KSSV 2020-6-19
You need to define Rect to use the ginput points.
I = imread("image.jpeg") ;
imshow(I) ;
[Px,Py] = ginput(2) ;
Px = round(Px) ; Py = round(Py) ;
R = [Px(1) Py(1) Px(2)-Px(1) Py(2)-Py(1)] ; %[ x y W H]
I1 = imcrop(I,R) ;
figure
imshow(I1)
Play around with creating R...I am not sure whether they are correct here.
NOTE: While using imcrop also you do the same, select left top first and then bottom right. You define a rectangle.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Data Exploration 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by