osger
osger

Reputation: 11

Matlab - using ROI impoly and how to paint specific pixels

i try to select specific area in image and change the color inside this area. i write this code:

img = imread('trees.jpeg');
x = []
imshow(img)
h = impoly()
x=h.getPosition()

i get matrix of h.getPosition and i try to fill this area with help of this coordinates. what is the best way to fill this area?

thank's

Upvotes: 1

Views: 178

Answers (1)

Alex Taylor
Alex Taylor

Reputation: 1412

Two things:

1) The newer ROI tools are nicer. For example:

https://www.mathworks.com/help/images/ref/drawpolygon.html

2) In either case, the easiest thing to do would be to use the createMask method of the ROI to obtain a logical mask that you can then use to index into your matrix to define a new color assignment.

https://www.mathworks.com/help/images/ref/createmask.html

Upvotes: 1

Related Questions