ImageTrans provides two ways to erase text: one is to cover the text area with background color, and the other is to use image inpainting methods. ImageTrans removes text based on the rectangular area where the text is located.
For the case where the background is solid color as shown in the image below, we can cover the text with background color.
However, simply covering with a rectangular box will overwrite non-text elements.
In addition, the background of many images is not solid color, as shown in the following image.
In such cases, we need to use image inpainting.
Image inpainting needs to generate a mask of the object to remove. The image below is a text mask generated by ImageTrans.
With the text mask, we can generate the text-removed image.
Image inpainting can be used to repair old photos and remove objects in photos, such as the UFO in the image below. It is used in ImageTrans to remove text.
For images with a solid background color, the generated mask can also be used to cover text directly, and the result will be better than the default image inpainting method’s.
Default image inpainting result:
Covering with mask:
By default, ImageTrans uses binarization and contours detection to generate text mask, and Telea image inpainting algorithm. In addition, it also allows users to write plug-ins to access third-party methods to adapt to different kinds of images.
Currently, a PatchMatch image inpainting method and Sickzil-Machine’s text mask generation method and image inpainting method are provided.
Take the mask-generation of the following image as an example: Non-text content will be included by using the binarization method, while Sickzil-Machine can give an accurate result.
The following is the result of the default image inpainting method based on the mask generated by the Sickzil-Machine.
The result of Sickzil-Machine’s inpainting is not ideal, either.
Switch to PatchMatch. We can see it has a better restoration of the background, which is suitable for images whose background is gradual color or screen tones. But this method will take a long time to process.
Some Special Cases
Text with Shadow or Stroke
In this case, we need to set the mask dilation size larger, or manually edit the mask so that the mask completely covers the text.
Set the dilation kernel size to 10 and use PatchMatch.
Handwritten Text which is Connected with Edges
The default binarization text mask generation method will remove outer contours, so if the text is connected to the edge, it will not be generated. Sickzil-Machine cannot give an accurate result as well since its lack of such training data.
In this case, you need to uncheck the Remove Outer Contours checkbox in Mask Editor, regenerate the mask, and manually remove non-text parts.
You can check the Translucent checkbox to make the mask semi-transparent, which is convenient for manual modification.
When the mask is ready, choose a suitable image inpainting method to remove text.
The edited mask and inpainting result using Sickzil-Machine:
Image with Complex Background
Text is above graphics and is often stroked. The following is the default mask and removal results.
For this image, we have to manually edit the mask and choose a suitable inpainting method.
We can try to cover the text with stroked target text and focus on parts not being covered.
The following is the mask and removal results generated by Sickzil-Machine with a slight editing. Sickzil-Machine has a good result for Japanese manga. It can accurately generate text mask and restore lines.