How to constrain imdistline to vertical drag constraint
Mostra commenti meno recenti
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
Risposta accettata
Più risposte (1)
Walter Roberson
il 14 Mag 2012
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.
Categorie
Scopri di più su Build Interactive Tools in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!