How to find sum of all pixel value of ROI in a grayscale image?

6 views (last 30 days)
I am trying to draw a ROI of a grayscale image using imfreehand. After drawing this, I want to count all the intensity levels contained in this ROI. How can I do this?

Accepted Answer

Walter Roberson
Walter Roberson on 4 Jul 2016
Use the createMask method of the imfreehand object to create a binary mask. Suppose we call that mask . Then,
selected_values = YourImage(mask);
sum_of_selected = sum(selected_values);
count_intensity_values = length( unique(selected_values) );
  3 Comments

Sign in to comment.

More Answers (1)

Image Analyst
Image Analyst on 4 Jul 2016
See attached demo to freehand mask an image and find the drawn region's mean and centroid.
  6 Comments
Fahad Alharbi
Fahad Alharbi on 22 Mar 2018
can I apply this demo on a folder of images insisted of one by one ? thanks again.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!