How can I count handwritten spots from an image??

1 次查看(过去 30 天)
I took an A4 paper which has blank small rectangles on it and filled some of them with my pen. I then scanned the document and saved the image as .tiff. I converted the image in grayscale and in binary form because I thought it might be useful.
My Question is: Is there a way to count how many small rectangles I filled?
Thanks!!

回答(2 个)

Walter Roberson
Walter Roberson 2012-10-27
编辑:Walter Roberson 2012-10-27
Threshold the image. Label it. The number of labels is the number of rectangles.
If necessary, you can use regionprops() on the labeled image and change the Area measure in order to eliminate stray marks.
  2 个评论
Vic
Vic 2012-10-27
wouldn't this count the all rectangles in the image? I want to count how many rectangles are filled(handwritten filled and then scanned)
Thanx
Walter Roberson
Walter Roberson 2012-10-27
The regionprops Area will be different between filled rectangles and ones that are not filled.

请先登录,再进行评论。


Image Analyst
Image Analyst 2012-10-28
Like Walter said, threshold and label:
binaryImage = grayImage < 128; % or whatever intensity works.
[labeledImage numberOfRectangles] = bwlabel(binaryImage);
measurements = regionprops(labeledImage, 'Area');
allAreas = [measurements.Area];
You might find my image segmentation tutorial useful. It does conversion of grayscale into binary, then labeling and calling regionprops() to get the area. The Euler number (a count related to how many holes are in the region) would also be different for the filled vs. hollow rectangles.
Then it uses ismember to pick out the regions with area above a certain number of pixels (just what you need). Check it out for more info.
  3 个评论
Walter Roberson
Walter Roberson 2012-10-29
blobs = regionprops(BW,'Area');
now examine [blobs.Area] and notice there will be differences between the filled areas and the unfilled.
(Note: the people who answer questions here are volunteers, not staff.)
Image Analyst
Image Analyst 2012-10-29
I can tell you never tried out my tutorial because it goes over that. It finds and labels the nickels and dimes.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Image Segmentation and Analysis 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by