Sum the pixel value of this rectangular ROI.

4 views (last 30 days)
Adni Ahyani
Adni Ahyani on 9 Jun 2022
Commented: Adni Ahyani on 10 Jun 2022
I need a code to sum pixel value of this ROI. I've tried to code like this, total = sum(roi)(:)) and the program says "invalid data type. First argument must be numeric or logical."

Accepted Answer

DGM on 9 Jun 2022
I can only assume that roi is an images.roi.rectangle object and not a logical array. If it is, you can convert it to a logical array by using
roimask = createMask(roi);
at which point you can use bwarea() or nnz() to find the mask area

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!