How to count the number of pixels in an hsv image

2 views (last 30 days)
I have converted a RGB image into a HSV image and segmented the HSV image into three horizontal regions.How to count the no of pixels in each segment

Answers (1)

Vidip
Vidip on 24 Dec 2024
Edited: Vidip on 24 Dec 2024
To count the number of pixels in each of the three horizontal segments of an already segmented HSV image in MATLAB, you can directly use the dimensions of the image and the segmentation logic. Assuming the image has been divided into three horizontal regions, the pixel count for each segment can be determined by calculating the number of elements in any channel of that segment.
For each segment which you have created, you can use the 'numel' function to count the number of pixels. For more information, please refer to the following MATLAB Answers post, where 'numel' is used to compute pixel counts in specific regions: https://in.mathworks.com/matlabcentral/answers/350623-how-to-compute-number-of-pixels-in-images.

Community Treasure Hunt

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

Start Hunting!