Method and system of generating binary image of a document image based on background color
Abstract
A method and system for generating binary image of a document image is disclosed. The method includes determining a negative map image, an inverse negative map image, an HSV image and a grayscale image of the document image. One or more cells corresponding to at least one table are detected based on detection of lines in the negative map image. For each of the cells, a foreground mean value, a background mean value, and a background mean HSV value is determined. Each of the cells are categorized as a dark cell or a light cell based on the foreground mean value and the background mean value. Contrast value of each cell is determined based on the foreground mean value and the background mean value. The binary image is determined based on the contrast value, a pre-defined threshold value, the background mean HSV value and the categorization of the corresponding cell.
Claims
exact text as granted — not AI-modifiedWhat is claimed is:
1 . A method of generating a binary image from a document image comprising at least one table structure, the method comprising:
determining, by a processor, a negative map image, an inverse negative map image, an HSV image and a grayscale image of the document image; detecting, by the processor, one or more cells corresponding to the at least one table based on detection of a plurality of lines in the negative map image; for each of the one or more cells:
computing, by the processor, a foreground mean value, a background mean value, and a background mean HSV value of a corresponding cell based on pixel color values of the corresponding cell from the negative map image, the inverse negative map image, the HSV image, and the grayscale image;
categorizing, by the processor, each of the one or more cells as a dark cell or a light cell based on the foreground mean value and the background mean value;
computing, by the processor, a contrast value based on the foreground mean value and the background mean value; and
determining, by the processor, the binary image for the corresponding cell based on the contrast value, a pre-defined threshold value, the background mean HSV value and the categorization of the corresponding cell.
2 . The method of claim 1 , wherein the at least one table is determined based on detection of a region of interest (ROI) in the negative map image based on detection of a plurality of lines, wherein the plurality of lines are extracted based on morphological operations.
3 . The method of claim 2 , wherein the one or more cells corresponding to the at least one table are determined by extending boundary lines of each of the one or more cells based on the extracted plurality of lines based on five neighbourhood connectivity of pixels, and
wherein the one or more cells are extracted using contour extraction based on the extended boundary lines of each of the one or more cells.
4 . The method of claim 1 , wherein the foreground mean value is determined based on determination of a mean of intensity value of a foreground masked grayscale image for the corresponding cell comprising non-zero pixels in the negative map image,
wherein the foreground masked grayscale image is generated by masking the grayscale image to remove background pixels equal to zero in the negative map image of the corresponding cell.
5 . The method of claim 1 , wherein the background mean value is determined based on determination of a mean intensity value of a background masked grayscale image for the corresponding cell comprising non-zero pixels in the inverse negative map image,
wherein the background masked grayscale image is generated by masking the grayscale image to remove background pixels equal to zero in the inverse negative map image of the corresponding cell.
6 . The method of claim 1 , wherein the background mean HSV value for each of the one or more cells is determined based on determination of a mean HSV value of the HSV image of the corresponding cell comprising non-zero pixels in the inverse negative map image of the corresponding cell.
7 . The method of claim 1 , wherein the one or more cells are categorized as a dark cell in case the foreground mean value of the corresponding cell is greater than the background mean value of the corresponding cell.
8 . The method of claim 1 , wherein the one or more cells are categorized as a light cell in case the background mean value of the corresponding cell is greater than the foreground mean value of the corresponding cell.
9 . The method of claim 1 , wherein the contrast value is computed based on determination of an absolute value of a ratio of a difference between the foreground mean value and the background mean value and a maximum of the foreground mean value and the background mean value for the corresponding cell.
10 . The method of claim 1 , wherein the binary image for the corresponding cell is determined by:
performing, by the processor, an inverse binary thresholding on the grayscale image in case the contrast value is greater than a predefined threshold value and in case the corresponding cell is categorized as a dark cell, or performing, by the processor, a binary thresholding on the grayscale image in case the contrast value is greater than the predefined threshold value and in case the corresponding cell is categorized as a light cell, or performing, by the processor, a binary thresholding on the HSV image based on a lower HSV threshold and an upper HSV threshold in case the contrast value is less than the predefined threshold value.
11 . A system of generating a binary image from a document image comprising at least one table structure, the system comprising:
a processor; and a memory communicably coupled to the processor, wherein the memory stores processor-executable instructions, which, on execution by the processor, cause the processor to:
determine a negative map image, an inverse negative map image, an HSV image and a grayscale image of the document image;
detect one or more cells corresponding to the at least one table based on detection of a plurality of lines in the negative map image;
for each of the one or more cells,
compute a foreground mean value, a background mean value, and a background mean HSV value of a corresponding cell based on pixel color values of the corresponding cell from the negative map image, the inverse negative map image, the HSV image, and the grayscale image;
categorize each of the one or more cells as a dark cell or a light cell based on the foreground mean value and the background mean value;
compute a contrast value based on the foreground mean value and the background mean value; and
determine the binary image for the corresponding cell based on the contrast value, a pre-defined threshold value, the background mean HSV value and the categorization of the corresponding cell.
12 . The system of claim 11 , wherein the at least one table is determined based on detection of a region of interest (ROI) in the negative map image based on detection of a plurality of lines, wherein the plurality of lines are extracted based on morphological operations.
13 . The system of claim 12 , wherein the one or more cells corresponding to the at least one table are determined by extending boundary lines of each of the one or more cells based on the extracted plurality of lines based on five neighbourhood connectivity of pixels, and
wherein the one or more cells are extracted using contour extraction based on the extended boundary lines of each of the one or more cells.
14 . The system of claim 11 , wherein the foreground mean value is determined based on determination of a mean of intensity value of a foreground masked grayscale image for the corresponding cell comprising non-zero pixels in the negative map image, wherein the foreground masked grayscale image is generated by masking the grayscale image to remove background pixels equal to zero in the negative map image of the corresponding cell.
15 . The system of claim 11 , wherein the background mean value is determined based on determination of a mean intensity value of a background masked grayscale image for the corresponding cell comprising non-zero pixels in the inverse negative map image, wherein the background masked grayscale image is generated by masking the grayscale image to remove background pixels equal to zero in the inverse negative map image of the corresponding cell.
16 . The system of claim 11 , wherein the background mean HSV value for each of the one or more cells is determined based on determination of a mean HSV value of the HSV image of the corresponding cell comprising non-zero pixels in the inverse negative map image of the corresponding cell.
17 . The system of claim 11 , wherein the one or more cells are categorized as a dark cell in case the foreground mean value of the corresponding cell is greater than the background mean value of the corresponding cell.
18 . The system of claim 11 , wherein the one or more cells are categorized as a light cell in case the background mean value of the corresponding cell is greater than the foreground mean value of the corresponding cell.
19 . The system of claim 11 , wherein the contrast value is computed based on determination of an absolute value of a ratio of a difference between the foreground mean value and the background mean value and a maximum of the foreground mean value and the background mean value for the corresponding cell.
20 . The system of claim 11 , wherein to determine the binary image for the corresponding cell, the processor-executable instructions cause the processor to:
perform an inverse binary thresholding on the grayscale image in case the contrast value is greater than a predefined threshold value and in case the corresponding cell is categorized as a dark cell, or perform a binary thresholding on the grayscale image in case the contrast value is greater than the predefined threshold value and in case the corresponding cell is categorized as a light cell, or perform a binary thresholding on the HSV image based on a lower HSV threshold and an upper HSV threshold in case the contrast value is less than the predefined threshold value.Cited by (0)
No later patents cite this yet.
References (0)
No backward citations on record.