MATLAB Answers

Extracting part of an image

14 views (last 30 days)
Jaeyong Oh
Jaeyong Oh on 8 Aug 2019
Edited: Matt J on 9 Aug 2019
Hi, I am trying to extract a part of an image to get average pixel intensity of that part.
Attached image '1.jpg' is the original image and '1.. line.jpg' shows the part that I want to extract.
I cannot use the imcrop command since the part I want is not rectangular.
I tried using the drawpolygon command and got the vertices of the polygon, but I couldn't take it any further.
Can anybody help me?
Thank you in advance.

  0 Comments

Sign in to comment.

Answers (1)

Matt J
Matt J on 9 Aug 2019
Edited: Matt J on 9 Aug 2019
Use impoly instead of drawpolygon. Use the createMask() method of the impoly object h to extract the ROI pixels
pixelvalues = yourImage(h.creatMask)

  0 Comments

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!

Translated by