get a cropped image using mouse click
8 次查看(过去 30 天)
显示 更早的评论
Hello,
I want to crop an image using coordinates of mouse click. I find a solution with handler function, but the problem is that I can't get results from the function. I used the following code:
function demoOnImageClick (I)
clc;clear;
imObj = imread(I);
disp(size(imObj));
figure;
hAxes = axes();
imageHandle = imshow(imObj);
set(imageHandle,'ButtonDownFcn',@ImageClickCallback);
function coordinates = ImageClickCallback ( objectHandle , eventData )
axesHandle = get(objectHandle,'Parent');
coordinates = get(axesHandle,'CurrentPoint');
coordinates = coordinates(1,1:2);
end
end
Using this code, I can't get coordinates at each click to use them in the imcrop function. What can I do?
1 个评论
回答(1 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!