How to constrain imdistline to vertical drag constraint
古いコメントを表示
I wonder if anyone can help, as i am new to MATLAB. I have a axis (pixelAxis) that contains an ultrasound image and I am using imdistline to meaure between two poins on the scale bar that is included in the image. I have set the line to be vertical when it appears but i can't seem to make constrain the drag to vertical only.
handles.distLine = imdistline (handles.pixelAxis, [850 850], [150 400]);
I have read the imdistline entry in the manual, but i'm not sure how to implement it.
Many Thnaks
Richard
採用された回答
その他の回答 (1 件)
Walter Roberson
2012 年 5 月 14 日
Follow example 1 of the imdistline documentation... including using the undocumented property.
Adapting it according to what you posted:
handles.distLine = imdistline (handles.pixelAxis, [850 850], [150 400]);
api = iptgetapi(handles.distLine);
fcn = @(pos) [pos(1,1) min(pos(:,2)); pos(2,1) min(pos(:,2))];
api.setDragConstraintFcn(fcn);
Here, I do the vertical constraint by forcing both y to be the same, arbitrarily choosing the lower of the two y as being the "right" vertical offset to constrain to.
カテゴリ
ヘルプ センター および File Exchange で Build Interactive Tools についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!