To remove page holes in an image, the BlobDetection method from the package OpenCV is used to detect round objects. Several adjustable parameters can be utilised to filter through the found objects. The filtering of minimum area, maximum area, circularity, convexity, and inertia are examples of parameters used to only remove the page holes. If the filtering is not performed correctly, objects with circular geometries such as the letter ”o” could be removed which is undesirable. Since the size and shape of the page holes are consistent, the same filtering parameters work in most cases. Once the page holes have been detected, the average colour around the hole is calculated and the hole is filled with this colour. Lastly, the area around the circle is blurred to prevent the circle to be picked up by edge detection methods. The image is also transformed from BGR to grayscale. An example of the output can be seen in Figure 6.
Figure 6: Before (left) and after (right) when applying the page hole removal algorithm on a document image.
Noise removal is performed to reduce the amount of static noise and to remove variance found in the background. Several steps are included in the pipeline to remove as much noise as possible without losing information about the actual text. The steps taken are listed in order with an explanation of each.
Grayscale: Converting the image colour space from BGR to grayscale to be able to apply different image analysis techniques.
Binarisation: Performing a binary threshold on the image. This step creates an image where the pixels of the image are divided into two parts. Either the pixel is classified as 0 (black pixel), or 255 (white pixel), which depends on a specifi- cally chosen threshold value in the range 0 to 255. This thresholding technique is effective at extracting text from the background.
Dilation: Dilation using kernel size = 1, and iterations = 1. Dilation increases the white regions of an image.
Erosion: Erosion using kernel size = 1, and iterations = 1. Erosion removes white pixels near boundaries, useful for removing small white noise. Erosion and dila- tion are often used in combination as erosion shrinks the objects, while dilation increases object size.
MorphologyEx: MorphologyEx using operation = MORPH CLOSE and kernel size = 1. The closing transformation is useful for closing small holes inside objects or removing small black regions within objects.
Median Blur: Applying a median blur filter with kernel size = 3. This last step removes any anomalies left after the above transformations.
Although the steps above remove most of the noise on the page, sometimes the edges of the page might contain ink spill or edge noise generated by page degeneration over time. This is removed by adding a one-pixel wide border around the image with a static colour and then using the floodFill method starting at pixel (0,0). Since the image is binary, the noise at the edge of the image will be at intensity=255. The floodFill will catch the noise at the edge and remove it by changing the intensity of the noise to 0. An example of the output after the noise removal can be seen in Figure 7.
Dostları ilə paylaş: |