0
我想在圖片上畫一條線,但它只能畫出45度角的線。 Line似乎只對x座標變化有反應。如何在Matlab中的圖像上畫一條線?
function demoOnImageClick
clc;clear;close all;
imObj = rand(500)
figure;
hAxes = axes();
imageHandle = imshow(imObj);
set(imageHandle,'ButtonDownFcn',@ImageClickCallback);
function ImageClickCallback (objectHandle , eventData)
axesHandle = get(objectHandle,'Parent');
coordinates = get(axesHandle,'CurrentPoint');
coordinates = coordinates(1,1:2);
line([0 coordinates (1)], [0 coordinates (2)]);
message = sprintf('x: %.1f , y: %.1f',coordinates (1) ,coordinates (2));
helpdlg(message);
end
end