To achieve the functionality you described using "impoint" in MATLAB, you'll need to use the interactive capabilities provided by the Image Processing Toolbox. The "impoint" function allows users to place points on an image interactively and provides a way to retrieve and update the coordinates of these points. You can also set up listeners to automatically update the coordinates whenever the user moves the points. Below steps might help you in getting started.
- Ensure your image is displayed in the appropriate axes within your GUI.
- Use impoint to allow users to select and move points on the image.
% Create two interactive points on the image
hPoint1 = impoint(handles.ShowImage);
hPoint2 = impoint(handles.ShowImage);
- Use "addNewPositionCallback" to update the coordinates whenever a point is moved.
% Add listeners to update coordinates when points are moved
addNewPositionCallback(hPoint1, @(pos) updateCoordinates(handles, pos, 1));
addNewPositionCallback(hPoint2, @(pos) updateCoordinates(handles, pos, 2));
- Update the coordinates in your handles and use them to call your function.
% Function to update coordinates and run your custom function
function updateCoordinates(handles, pos, pointIndex)
% Update the coordinates in the handles structure
handles.X(pointIndex) = pos(1);
handles.Y(pointIndex) = pos(2);
guidata(handles.PixelSelectionButt, handles);
% Call your custom function with updated coordinates
[Xpath, Ypath] = catetherPathFast((1 - VessN) .* im2double(I), handles.Y, handles.X);
% Plot the path on the image
axes(handles.ShowImage);
hold on;
plot(Ypath, Xpath, 'b-');
hold off;
end
For better understanding of "impoint" and "addNewPositionCallback" refer to the following documentation:
- https://www.mathworks.com/help/images/ref/impoint.html
- https://www.mathworks.com/help/images/ref/imroi.addnewpositioncallback.html
Hope that helps!