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!