System and method for merging separated pixel blocks into an integral image of an object

A method for merging separated pixel blocks into an integral image of an object is provided. The method performs binary image processing on an obtained image to obtain a binary image, finds pixel blocks in the binary image whose area is greater than a first preset value, and stores a position and a size of each found pixel block in a data structure. The method further merges two pixel blocks in the data structure if a distance between the two pixel blocks is less than a second preset value, so as to generate the integral image of the object.

BACKGROUND

1. Technical Field

Embodiments of the present disclosure relate to image processing technology, and particularly to a system and method for merging separated pixel blocks into an integral image of an object.

2. Description of Related Art

Noise may be filtered from an image using a number of known methods. One method filters pixels in the image whose difference value of red, green, and blue (RGB) is less than a preset value. Another method sharpens the image firstly, then, filters the pixels in the sharpened image whose difference value of RGB is less than the preset value. However, the above-mentioned two methods may divide an object in the image into a plurality of separated pixel blocks. Therefore, prompt and accurate method of merging the separated pixel blocks into an integral image is desired.

DETAILED DESCRIPTION

All of the processes described below may be embodied in, and fully automated via, functional code modules executed by one or more general purpose computers or processors. The code modules may be stored in any type of readable medium or other storage device. Some or all of the methods may alternatively be embodied in specialized hardware. Depending on the embodiment, the readable medium may be a hard disk drive, a compact disc, a digital video disc, or a tape drive.

FIG. 1is a block diagram of one embodiment of a computer2comprising an image merging system21. In one embodiment, the image merging system21may be used to merge separated pixel blocks into an integral image of an object. A detailed description will be given in the following paragraphs.

In one embodiment, the computer2is electronically connected to a display device1, an image obtaining device3, and an input device4. Depending on the embodiment, the display device1may be a liquid crystal display (LCD) or a cathode ray tube (CRT) display, for example.

The computer2further includes a storage device20for storing information, such as image data22captured by the image obtaining device3. In one embodiment, the image obtaining device3may be an Internet Protocol (IP) camera.

The input device4is provided for manually editing an image displayed on the display device1. In one embodiment, the input device4may be a keyboard.

In one embodiment, the image merging system21includes an obtaining module210, a processing module211, a searching module212, a recording module213, and a merging module214. In one embodiment, the modules210-214comprise one or more computerized instructions that are stored in the storage device20. A processor23of the computer2executes the computerized instructions to implement one or more operations of the computer2.

The obtaining module210obtains an image from the storage device20.

The processing module211performs binary image processing on the obtained image to obtain a binary image. It may be understood that the binary image has only two possible values for each pixel in the binary image. Usually, two colors used for the binary image are black and white, although any two colors can be used. In one embodiment, the color used for the object in the image is the foreground color (such as black), while the rest of the image is the background color (such as white).

The searching module212finds each pixel block in the binary image whose area is greater than a first preset value. In one embodiment, the pixel block refers to an array of one or more pixels connected together, and the first preset value is one hundred pixels. For example, if the background color of the binary image is white, the searching module212finds each black pixel block in the binary image whose area is greater than the first preset value. If the background color of the binary image is black, the searching module212finds each white pixel block in the binary image whose area is greater than the first preset value.

The searching module212determines if such a pixel block whose area is greater than the first preset value has been found.

The recording module213records a position and a size of each found pixel block, and stores the position and the size of each found pixel block in a data structure (e.g., an array). In one embodiment, a position of each found pixel block refers to coordinates of a center point of the found pixel block.

The merging module214calculates a distance between every two pixel blocks in the data structure in sequence, and merges the two pixel blocks if the distance between the two pixel blocks is less than a second preset value, so as to generate the integral image of the object. In one embodiment, the second preset value is a length of ten pixels. An example of merging two separated pixel blocks to generate an integral image of an object is shown inFIGS. 3A-3C.FIG. 3Arepresents a binary image,FIG. 3Brepresent two separated pixel blocks (i.e., blocks “B1” and “B2”) of a character “b” inFIG. 3A, andFIG. 3Crepresents a merged integral character “b” (i.e., a block “B”).

For the purpose of illustration, supposing the positions of the found pixel blocks are stored in an array P having elements of P[0], P[1], P[2], P[3], P[4], . . . P[n], the merging module214calculates a distance between P[0] and each other element in sequence. That is to say, the merging module214calculates distances between P[0] and P[1], P[0] and P[3], . . . , P[0] and P[n], so as to find two pixel blocks whose distance is less than the second preset value. For example, if a distance between P[0] and P[1] is greater than or equal to the second preset value, the merging module214further calculates a distance between P[0] and P[2]. If the distance between P[0] and P[2] is less than the second preset value, the merging module214merges the two pixels blocks corresponding to P[0] and P[2], and further finds another two pixel blocks whose distance is less than the second preset value, and performs the merging operation till all the elements are determined.

In other embodiment, the obtaining module210further sharpens the obtained image when the image is obtained from the storage device20.

FIG. 2is a flowchart of one embodiment of a method for merging separated pixel blocks into an integral image of an object. Depending on the embodiment, additional blocks may be added, others removed, and the ordering of the blocks may be changed.

In block S1, the obtaining module210obtains an image from the storage device20.

In block S2, the processing module211performs binary image processing on the obtained image to obtain a binary image.

In block S3, the searching module212finds each pixel block in the binary image whose area is greater than a first preset value. In one embodiment, the pixel block refers to an array of one or more pixels connected together.

In block S4, the searching module212determines if such a pixel block whose area is greater than the first preset value has been found, and the procedure goes to block S5if such a pixel block has been found in block S3, or the procedure ends if any one pixel block has not found in block S3.

In block S5, the recording module213records a position and a size of each found pixel block, and stores the position and the size of each found pixel block in a data structure. In one embodiment, a position of each found pixel block refers to coordinates of a center point of the found pixel block.

In block S6, the merging module214calculates a distance between every two pixel blocks in the data structure in sequence, and merges the two pixel blocks if the distance between the two pixel blocks is less than a second preset value, so as to generate the integral image of the object.

In other embodiment, the method further includes a followed block: the obtaining module210sharpens the obtained image when the image is obtained from the storage device20.