Count values on an image inside a rectangle

1 view (last 30 days)
Stefan Lang
Stefan Lang on 4 Nov 2020
Answered: KSSV on 4 Nov 2020
I have a picture with uint16 grayscale intensities. I want to define 4 points (as corner points of a rectangle) and put this rectangle somwhere on top of my picture. This shouldn't be a problem. But then i want to sum up all the grayscale intensity values of the underlying image inside this rectangle. How can i do this?

Answers (1)

KSSV
KSSV on 4 Nov 2020
  1. Read about inpolygon. You will get all the indices of the points lying inside this reactange. Then you can count them.
  2. Use interp2, you will get only those pixels....and then count.
  3. You already have the indcies of rectangel, so from the image extract this chunk using indexing and then you can count your pixels. (This method is easy, try out this)

Community Treasure Hunt

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

Start Hunting!