フィルターのクリア

i have found this code over internet.But i need its output coordinates in x and y variables. How i can do that ?

2 ビュー (過去 30 日間)
function [ x1,y1,x2,y2 ] = image_Coordinates
clc;clear;
imObj = imread('Finalized_Lhr_maps_Half.jpg');
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)
message = sprintf('x: %.1f , y: %.1f',coordinates (1) ,coordinates (2));
helpdlg(message);
end
% ah = get( imageHandle, 'Parent' );
% p = get( ah, 'CurrentPoint' )
end

回答 (2 件)

Walter Roberson
Walter Roberson 2016 年 4 月 28 日
[x(1), y(1), x(2), y(2)] = image_Coordinates();
  4 件のコメント
Haroon Younas
Haroon Younas 2016 年 4 月 29 日
it is giving this error again and again. Am i doing it wrong ?
Stephen23
Stephen23 2016 年 4 月 29 日
編集済み: Stephen23 2016 年 4 月 29 日
You need to allocate values to x1,y1,x2,y2 inside the function. MATLAB does not just invent some values for these: if you do not define inside the function what value x1 has, then what value do you expect the x1 output variable to have?
function out = myFun()
out = 4; % define the output variable
end

サインインしてコメントする。


Image Analyst
Image Analyst 2016 年 4 月 29 日
I suggest you just learn how to use impixelinfo(). It's better because it gives you a "live" readout as you move the cursor over the image. No clicking even needed at all.
If you need to get the values into variables for use in your code, then I suggest you have a mode where the user does that, like a button where the button callback calls ginput(1). But if it's just for visual inspection, then I recommend impixelinfo().

カテゴリ

Help Center および File ExchangeComputer Vision with Simulink についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by