imfreehand/impoly using different color other than blue

7 views (last 30 days)
while i'm using imfreehand or impoly I want to change the color of the line from the beginning (I know how to change it after that I have finished the creation of the line/polygon).

Answers (1)

Naga
Naga on 11 Feb 2025 at 10:20
Starting from MATLAB R2018b, the 'imfreehand' function is not recommended, and MATLAB introduced a new set of ROI (Region of Interest) objects that offer more functionality and flexibility, including the ability to set the color of the ROI from the beginning.
To create a freehand ROI with a specific color, you can use the 'drawfreehand function', which is part of the new ROI framework. Here’s an example of how you can create a freehand ROI with a red color:
% Display the image
imshow('image.png');
% Create a freehand ROI with a specified color
h = drawfreehand('Color', 'r'); % 'r' is for red, you can use other colors like 'g', 'b', etc.
Switching to these new ROI objects will allow you to take advantage of additional capabilities, such as face color transparency and event handling.
For more detailed information, you can refer to the official MATLAB documentation on the 'drawfreehand' function: https://www.mathworks.com/help/images/ref/drawfreehand.html

Community Treasure Hunt

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

Start Hunting!