简体   繁体   中英

Removing black areas from a scanned image with C#

I have a bunch of images, that look like 这个 .

After processing, I want them to be like 这个 .
I know that I can easily make those black areas white using the Flood Fill algorithm. But first of all I need to make sure that the black area is not part of the text. How can I do that? Those areas are huge, comparing to letters. So maybe I can just find out the size of each black area, and make the areas which are bigger than n white?

That's all about machinevision. You could write your own code for something like "Connected-Component-Labeling" This is just one possible approach. Therefore you could start at the top left corner and gather all pixel that have almost the same grey value. save the coordinates and fill this area if the array contains more pixel than a certain threshold.

But i think you ll have some probs with the black "line" in the middle.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM