Remove lines and noise in the image #667
-
I want to use MAGICK.NET to delete the lines and noises in the image |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 10 replies
-
The links to your images appear to be broken. |
Beta Was this translation helpful? Give feedback.
-
I think we need the expert @fmw42 to help us with this. If he can tell us how to do it on the command line I can help you translate it to c#. |
Beta Was this translation helpful? Give feedback.
-
The best way would be to use connected components to remove very small and very large regions. This leaves only a couple of small black spots:
The removes those spots, but fills in white holes in some letters such as "e"
|
Beta Was this translation helpful? Give feedback.
-
You currently cannot set a range for the area threshold but you will be able to do this when version using (var image = new MagickImage(@"sample-0005 - 副本 (2).jpg"))
{
image.Threshold(new Percentage(0)); // -threshold 0
image.ColorType = ColorType.Bilevel; // -type bilevel
var settings = new ConnectedComponentsSettings()
{
AreaThreshold = new Threshold(3.05, 1000), // -define connected-components:area-threshold=3.05-1000
MeanColor = true, // -define connected-components:mean-color=true
Connectivity = 8, // -connected-components 8
};
image.ConnectedComponents(settings); // -connected-components 8
image.Write("sample-0005-result.jpg");
} I used |
Beta Was this translation helpful? Give feedback.
-
Text images like the one above have lots of characters and thus lots of isolated regions. If there are more than 255 characters (including dots on i), then connected components will limit out for Q8. That is the trade you will have to assess vs using Q16. Your processing will likely also slow down if you are using HDRI compile. |
Beta Was this translation helpful? Give feedback.
Text images like the one above have lots of characters and thus lots of isolated regions. If there are more than 255 characters (including dots on i), then connected components will limit out for Q8. That is the trade you will have to assess vs using Q16. Your processing will likely also slow down if you are using HDRI compile.