필터 지우기
필터 지우기

Modifying impixelinfo to display 3d coordinates

조회 수: 2 (최근 30일)
bes
bes 2012년 7월 19일
I want to display real world image coordinates (imrealinfo function)when user move the mouse over the image.
I have to get the image pixel coordinates with impixelinfoval Then I know the real world coordinate of the left top position of the image (origin in image space) also the pixel width
My code is
X3d = realcor(1,1) + realcor(3,1)* X;
Y3d = realcor(2,1) + realcor(4,1)* Y;
Z3d = Zdata(X3d, Y3d);
% realcor contain real world coordinates of left top corner of the image, pixel width
% Zdata contain Z details
X, Y are the output of impixelinfoval function.
so my new function should get the output of impixelinfoval and then compute the 3d coordinates and when user move the mouse imrealinfo command should show the 3d real coordinates of that point.
Any suggestion please
  댓글 수: 1
bes
bes 2012년 7월 19일
My problems are 1. how assign impixelinfoval output to x and y to compute 3d coordinate 2. How to display 3d coordinate when cursor moves?
Is there any way to get the impixelinfoval outputs to [x y] array?

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

채택된 답변

Matt Kindig
Matt Kindig 2012년 7월 19일
I don't believe that impixelinfo or impixelinfoval allows you to specify a custom callback, which is what you would need to do what you are intending.
However, it should be relatively straightforward to essentially implement your own imrealinfo() function that does what you want to do. Are you familiar with writing your own custom callback functions? One way to structure your code is something like this (this is just the skeleton of the code-- this hasn't been tested and should probably be expanded to include error checking, etc.).
function imrealinfo( himg, ZData, realcor)
% hfig is handle to your image
% ZData and realcor are your "real-world" info
hax = get(himg, 'parent'); %handle to axes
hfig = get(hax, 'parent'); %handle to figure
hu = uicontrol('Style','edit', 'String', 'X3d=0, Y3d=0, Z3d=0')
set(hfig, 'WindowButtonMotionFcn', @motioncb)
function motioncb(src,evnt)
cp = get(hax, 'CurrentPoint');
X = cp(1,1);
Y = cp(1,2);
X3d = realcor(1,1) + realcor(3,1)* X;
Y3d = realcor(2,1) + realcor(4,1)* Y;
Z3d = Zdata(X3d, Y3d);
set(hu, 'String', sprintf('X3d=%0.2f, Y3d=%0.2f, Z3d=%0.2f', X3d, Y3d, Z3d));
end
end

추가 답변 (1개)

Walter Roberson
Walter Roberson 2012년 7월 19일
Perhaps you could do this with datacursormode . It allows custom callbacks for information display.

카테고리

Help CenterFile Exchange에서 Build Interactive Tools에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by