CN105046260B - Image pre-processing method and device - Google Patents

Image pre-processing method and device Download PDF

Info

Publication number
CN105046260B
CN105046260B CN201510463446.2A CN201510463446A CN105046260B CN 105046260 B CN105046260 B CN 105046260B CN 201510463446 A CN201510463446 A CN 201510463446A CN 105046260 B CN105046260 B CN 105046260B
Authority
CN
China
Prior art keywords
image
pixel
boundary
value
line segment
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201510463446.2A
Other languages
Chinese (zh)
Other versions
CN105046260A (en
Inventor
龙飞
陈志军
张涛
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Xiaomi Inc
Original Assignee
Xiaomi Inc
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Xiaomi Inc filed Critical Xiaomi Inc
Priority to CN201510463446.2A priority Critical patent/CN105046260B/en
Publication of CN105046260A publication Critical patent/CN105046260A/en
Application granted granted Critical
Publication of CN105046260B publication Critical patent/CN105046260B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/20Image preprocessing

Abstract

The disclosure is directed to a kind of image pre-processing method and devices, belong to field of image processing.The described method includes: it is based on image to be processed, the bianry image of image-region where determining each boundary of card;For each boundary, from a plurality of line segment in the bianry image of image-region, is obtained where the boundary, a plurality of line segment is made of the pixel that multiple gray values are the first numerical value respectively;Based on a plurality of line segment, the bianry image of image-region where the boundary is pre-processed.The embodiment of the present disclosure is further processed the bianry image of image-region where each boundary, filters out some burrs on edges, more highlights the boundary of card clearly, improves the effect of image preprocessing.

Description

Image pre-processing method and device
Technical field
This disclosure relates to field of image processing more particularly to a kind of image pre-processing method and device.
Background technique
With the fast development of technology, there are more and more terminals with image processing function, and passes through these ends When end carries out image procossing, most important application is identified to the card in image, which can be credit card, electricity Words card, game card etc..However by including not only usually card, further comprising in the shooting obtained image of card Therefore background in order to identify the card in image, generally requires to pre-process the image, to determine the boundary of card, because This, needs a kind of image pre-processing method.
Summary of the invention
To overcome the problems in correlation technique, the disclosure provides a kind of image pre-processing method and device.
According to the first aspect of the embodiments of the present disclosure, a kind of image pre-processing method is provided, which comprises
Based on image to be processed, the bianry image of image-region where determining each boundary of card;
A plurality of line segment is obtained from the bianry image of boundary place image-region for each boundary, it is described A plurality of line segment is made of the pixel that multiple gray values are the first numerical value respectively;
Based on a plurality of line segment, the bianry image of image-region where the boundary is pre-processed.
With reference to first aspect, described to be based on figure to be processed in the first possible implementation of above-mentioned first aspect Picture, the bianry image of image-region where determining each boundary of card, comprising:
The image to be processed is converted into grayscale image;
From the grayscale image, the image-region where each boundary of the card is determined;
For each boundary, it is based on boundary institute pixel in the image area, by the figure where the boundary As region progress self-adaption binaryzation processing, the bianry image of image-region where obtaining the boundary.
The possible implementation of with reference to first aspect the first, in second of possible realization side of above-mentioned first aspect It is described to be based on boundary institute pixel in the image area in formula, the image-region where the boundary is carried out adaptive Binary conversion treatment, the bianry image of image-region where obtaining the boundary, comprising:
For boundary institute each pixel in the image area, the pixel neighborhood of a point is obtained;
Based on the gray value of pixel in the neighborhood, the first gray threshold is determined;
When the gray value of the pixel is greater than or equal to first gray threshold, by the gray value of the pixel It is set as the first numerical value;
When the gray value of the pixel is less than first gray threshold, set the gray value of the pixel to Second value.
The possible implementation of second with reference to first aspect, in the third possible realization side of above-mentioned first aspect In formula, after the acquisition pixel neighborhood of a point, further includes:
Determine that the first ratio and the second ratio, first ratio are that gray value is greater than the second gray threshold in the neighborhood Pixel number ratio shared in total number, second ratio is that gray value is less than third gray scale threshold in the neighborhood The pixel number of value ratio shared in the total number, the total number are of all pixels point in the neighborhood Number;
When first ratio and second ratio are respectively less than proportion threshold value, execute described based on picture in the neighborhood The gray value of vegetarian refreshments, the step of determining the first gray threshold.
The third possible implementation with reference to first aspect, in the 4th kind of possible realization side of above-mentioned first aspect In formula, after first ratio of determination and the second ratio, further includes:
When first ratio is greater than or equal to the proportion threshold value, set described for the gray value of the pixel First numerical value;
When second ratio is greater than or equal to the proportion threshold value, set described for the gray value of the pixel Second value.
With reference to first aspect, described from the boundary institute in the 5th kind of possible implementation of above-mentioned first aspect In the bianry image of image-region, a plurality of line segment is obtained, comprising:
The long side of the bianry image of image-region where judging the boundary whether with horizontal direction parallel;
When the long side and horizontal direction of the bianry image of image-region where the boundary are not parallel, to the boundary institute It is rotated in the bianry image of image-region, the long side and horizontal direction of the bianry image of image-region where making the boundary In parallel;
From every row pixel that postrotational bianry image includes, obtaining continuous multiple gray values respectively is described the The pixel of one numerical value;
The line segment that the multiple pixels obtained respectively from every row pixel are constituted is determined as a plurality of line segment.
With reference to first aspect, described based on described a plurality of in the 6th kind of possible implementation of above-mentioned first aspect Line segment pre-processes the bianry image of image-region where the boundary, comprising:
For every line segment in a plurality of line segment, the angle between the line segment and horizontal direction is determined;
When the angle is less than or equal to specified angle threshold value, the line segment length of the line segment is determined;
When the line segment length is less than designated length threshold value, the gray value for constituting multiple pixels of the line segment is set It is set to second value.
The 6th kind of possible implementation with reference to first aspect, in the 7th kind of possible realization side of above-mentioned first aspect It is described when the line segment length is less than designated length threshold value in formula, the gray value of multiple pixels of the line segment will be constituted It is set as after second value, further includes:
From the bianry image of boundary place image-region, multiple images connected domain, described image connected domain are determined The connected region being made of the pixel that gray value is first numerical value;
For image connectivity domain each in described multiple images connected domain, the statistical parameter of described image connected domain is determined, The statistical parameter is area or width;
When the statistical parameter is greater than or equal to the first parameter threshold or the statistical parameter less than or equal to the second ginseng When number threshold value, the second value, first parameter threshold are set by the gray value of pixel in described image connected domain Greater than second parameter threshold.
The 6th kind of possible implementation with reference to first aspect, in the 8th kind of possible realization side of above-mentioned first aspect In formula, the method also includes:
When the angle is greater than the specified angle threshold value, display reminding information, to prompt described in user's reacquisition Image to be processed.
According to the second aspect of an embodiment of the present disclosure, a kind of image preprocess apparatus is provided, described device includes:
Determining module, for being based on image to be processed, the bianry image of image-region where determining each boundary of card;
Module is obtained, for obtaining from the bianry image of boundary place image-region for each boundary A plurality of line segment, a plurality of line segment are made of the pixel that multiple gray values are the first numerical value respectively;
Preprocessing module carries out the bianry image of image-region where the boundary for being based on a plurality of line segment Pretreatment.
In conjunction with second aspect, in the first possible implementation of above-mentioned second aspect, the determining module includes:
Converting unit, for the image to be processed to be converted to grayscale image;
First determination unit, for determining the image-region where each boundary of the card from the grayscale image;
Binary conversion treatment unit, for being based on boundary institute pixel in the image area for each boundary, Image-region where the boundary is subjected to self-adaption binaryzation processing, the binary map of image-region where obtaining the boundary Picture.
In conjunction with the first possible implementation of second aspect, in second of possible realization side of above-mentioned second aspect In formula, the binary conversion treatment unit includes:
Subelement is obtained, for obtaining the pixel for boundary institute each pixel in the image area Neighborhood;
First determines that subelement determines the first gray threshold for the gray value based on pixel in the neighborhood;
First setting subelement, for when the gray value of the pixel be greater than or equal to first gray threshold when, The first numerical value is set by the gray value of the pixel;
Second setting subelement will be described for when the gray value of the pixel is less than first gray threshold The gray value of pixel is set as second value.
In conjunction with second of possible implementation of second aspect, in the third possible realization side of above-mentioned second aspect In formula, the binary conversion treatment unit further include:
Second determines subelement, for determining that the first ratio and the second ratio, first ratio are ash in the neighborhood The angle value ratio shared in total number greater than the pixel number of the second gray threshold, second ratio are in the neighborhood The gray value ratio shared in the total number less than the pixel number of third gray threshold, the total number are the neighbour The number of all pixels point in domain;
Subelement is executed, for when first ratio and second ratio are respectively less than proportion threshold value, described in execution Based on the gray value of pixel in the neighborhood, the step of determining the first gray threshold.
In conjunction with the third possible implementation of second aspect, in the 4th kind of possible realization side of above-mentioned second aspect In formula, the binary conversion treatment unit further include:
Subelement is arranged in third, is used for when first ratio is greater than or equal to the proportion threshold value, by the pixel The gray value of point is set as first numerical value;
4th setting subelement, is used for when second ratio is greater than or equal to the proportion threshold value, by the pixel The gray value of point is set as the second value.
In conjunction with second aspect, in the 5th kind of possible implementation of above-mentioned second aspect, the acquisition module includes:
Whether the long side of judging unit, the bianry image for image-region where judging the boundary is flat with horizontal direction Row;
Rotary unit, it is not parallel for the long side and horizontal direction of the bianry image of image-region where the boundary When, the bianry image of image-region where the boundary is rotated, the bianry image of image-region where making the boundary Long side and horizontal direction parallel;
Acquiring unit, it is continuous multiple for being obtained from every row pixel that postrotational bianry image includes respectively Gray value is the pixel of first numerical value;
Second determination unit, the line segment that multiple pixels for will obtain respectively from every row pixel are constituted are true It is set to a plurality of line segment.
In conjunction with second aspect, in the 6th kind of possible implementation of above-mentioned second aspect, the preprocessing module packet It includes:
Third determination unit, for for every line segment in a plurality of line segment, determine the line segment and horizontal direction it Between angle;
4th determination unit, for determining the line of the line segment when the angle is less than or equal to specified angle threshold value Segment length;
First setting unit, for the more of the line segment will to be constituted when the line segment length is less than designated length threshold value The gray value of a pixel is set as second value.
In conjunction with the 6th kind of possible implementation of second aspect, in the 7th kind of possible realization side of above-mentioned second aspect In formula, the preprocessing module further include:
5th determination unit, for determining that multiple images are connected to from the bianry image of boundary place image-region Domain, the connected region that described image connected domain is made of the pixel that gray value is first numerical value;
6th determination unit, for determining described image for image connectivity domain each in described multiple images connected domain The statistical parameter of connected domain, the statistical parameter are area or width;
Second setting unit, for being greater than or equal to the first parameter threshold or statistics ginseng when the statistical parameter When number is less than or equal to the second parameter threshold, second number is set by the gray value of pixel in described image connected domain Value, first parameter threshold are greater than second parameter threshold.
In conjunction with the 6th kind of possible implementation of second aspect, in the 8th kind of possible realization side of above-mentioned second aspect In formula, described device further include:
Display module is used for when the angle is greater than the specified angle threshold value, display reminding information, to prompt user Reacquire the image to be processed.
According to the third aspect of an embodiment of the present disclosure, a kind of image preprocess apparatus is provided, described device includes:
Processor;
Memory for storage processor executable instruction;
Wherein, the processor is configured to:
Based on image to be processed, the bianry image of image-region where determining each boundary of card;
A plurality of line segment is obtained from the bianry image of boundary place image-region for each boundary, it is described A plurality of line segment is made of the pixel that multiple gray values are the first numerical value respectively;
Based on a plurality of line segment, the bianry image of image-region where the boundary is pre-processed.
The technical scheme provided by this disclosed embodiment can include the following benefits: in the embodiments of the present disclosure, base In image to be processed, the bianry image of image-region where determining each boundary of card, due to picture in determining bianry image The gray value of vegetarian refreshments is the first numerical value or second value, and from the bianry image of each boundary place image-region, respectively Obtaining can be to each side by a plurality of line segment by a plurality of line segment that the pixel that multiple gray values are the first numerical value is constituted The bianry image of image-region is further processed where boundary, to filter out some burrs on edges on each boundary of card, more For the boundary for highlighting card clearly, the effect of image preprocessing is improved.
It should be understood that above general description and following detailed description be only it is exemplary and explanatory, not The disclosure can be limited.
Detailed description of the invention
The drawings herein are incorporated into the specification and forms part of this specification, and shows and meets implementation of the invention Example, and be used to explain the principle of the present invention together with specification.
Fig. 1 is a kind of flow chart of image pre-processing method shown according to an exemplary embodiment.
Fig. 2 is the flow chart of another image pre-processing method shown according to an exemplary embodiment.
Fig. 3 is image-region schematic diagram where a kind of each boundary of card shown according to an exemplary embodiment.
Fig. 4 is a kind of pixel neighborhood of a point schematic diagram shown according to an exemplary embodiment.
Fig. 5 is a kind of schematic diagram of bianry image shown according to an exemplary embodiment.
Fig. 6 is a kind of schematic diagram of pretreated bianry image shown according to an exemplary embodiment.
Fig. 7 is a kind of image preprocess apparatus block diagram shown according to an exemplary embodiment.
Fig. 8 is a kind of block diagram of determining module shown according to an exemplary embodiment.
Fig. 9 is a kind of block diagram of binary conversion treatment unit shown according to an exemplary embodiment.
Figure 10 is the block diagram of another binary conversion treatment unit shown according to an exemplary embodiment.
Figure 11 is the block diagram of another binary conversion treatment unit shown according to an exemplary embodiment.
Figure 12 is a kind of block diagram for obtaining module shown according to an exemplary embodiment.
Figure 13 is a kind of block diagram of preprocessing module shown according to an exemplary embodiment.
Figure 14 is the block diagram of another preprocessing module shown according to an exemplary embodiment.
Figure 15 is a kind of block diagram of image preprocess apparatus shown according to an exemplary embodiment.
Specific embodiment
Example embodiments are described in detail here, and the example is illustrated in the accompanying drawings.Following description is related to When attached drawing, unless otherwise indicated, the same numbers in different drawings indicate the same or similar elements.Following exemplary embodiment Described in embodiment do not represent all embodiments consistented with the present invention.On the contrary, they be only with it is such as appended The example of device and method being described in detail in claims, some aspects of the invention are consistent.
Fig. 1 is a kind of flow chart of image pre-processing method shown according to an exemplary embodiment, as shown in Figure 1, should Image pre-processing method is for including the following steps in terminal.
In a step 101, it is based on image to be processed, the bianry image of image-region where determining each boundary of card.
In a step 102, each boundary of the card is obtained where from the boundary in the bianry image of image-region A plurality of line segment is taken, which is made of the pixel that multiple gray values are the first numerical value respectively.
In step 103, it is based on a plurality of line segment, the bianry image of image-region where the boundary is pre-processed.
In the embodiments of the present disclosure, it is based on image to be processed, the two-value of image-region where determining each boundary of card Image, since the gray value of pixel in determining bianry image is the first numerical value or second value, and from each boundary institute In the bianry image of image-region, a plurality of line segment being made of the pixel that multiple gray values are the first numerical value is obtained respectively, By a plurality of line segment, the bianry image of image-region where each boundary can be further processed, to filter out card Some burrs on edges on each boundary of piece, more highlight the boundary of card clearly, improve the effect of image preprocessing.
In another embodiment of the present disclosure, it is based on image to be processed, determines image-region where each boundary of card Bianry image, comprising:
Image to be processed is converted into grayscale image;
From the grayscale image, the image-region where each boundary of the card is determined;
For each boundary of the card, it is based on boundary institute pixel in the image area, by the figure where the boundary As region progress self-adaption binaryzation processing, the bianry image of image-region where obtaining the boundary.
In another embodiment of the present disclosure, it is based on boundary institute pixel in the image area, it will be where the boundary Image-region carries out self-adaption binaryzation processing, the bianry image of image-region where obtaining the boundary, comprising:
For boundary institute each pixel in the image area, the pixel neighborhood of a point is obtained;
Based on the gray value of pixel in the neighborhood, the first gray threshold is determined;
When the gray value of the pixel is greater than or equal to the first gray threshold, the is set by the gray value of the pixel One numerical value;
When the gray value of the pixel is less than the first gray threshold, the second number is set by the gray value of the pixel Value.
In another embodiment of the present disclosure, after obtaining the pixel neighborhood of a point, further includes:
Determine that the first ratio and the second ratio, the first ratio are the pixel that gray value is greater than the second gray threshold in the neighborhood Point number ratio shared in total number, the second ratio are the pixel that gray value is less than third gray threshold in the neighborhood Number ratio shared in total number, the total number are the number of all pixels point in the neighborhood;
When the first ratio and the second ratio are respectively less than proportion threshold value, the gray value based on pixel in the neighborhood is executed, The step of determining the first gray threshold.
In another embodiment of the present disclosure, after determining the first ratio and the second ratio, further includes:
When the first ratio is greater than or equal to the proportion threshold value, the first numerical value is set by the gray value of the pixel;
When the second ratio is greater than or equal to the proportion threshold value, second value is set by the gray value of the pixel.
In another embodiment of the present disclosure, where from the boundary in the bianry image of image-region, a plurality of line segment is obtained, Include:
Judge the bianry image of image-region where the boundary long side whether with horizontal direction parallel;
When the long side and horizontal direction of the bianry image of image-region where the boundary are not parallel, scheme to where the boundary As the bianry image in region is rotated, the long side and horizontal direction parallel of the bianry image of image-region where making the boundary;
From every row pixel that postrotational bianry image includes, obtaining continuous multiple gray values respectively is the first number The pixel of value;
The line segment that the multiple pixels obtained respectively from every row pixel are constituted is determined as a plurality of line segment.
In another embodiment of the present disclosure, it is based on a plurality of line segment, to the bianry image of image-region where the boundary It is pre-processed, comprising:
For every line segment in a plurality of line segment, the angle between the line segment and horizontal direction is determined;
When the angle is less than or equal to specified angle threshold value, the line segment length of the line segment is determined;
When the line segment length is less than designated length threshold value, set the gray value for constituting multiple pixels of the line segment to Second value.
In another embodiment of the present disclosure, when the line segment length is less than designated length threshold value, the line segment will be constituted The gray value of multiple pixels is set as after second value, further includes:
Where from the boundary in the bianry image of image-region, multiple images connected domain is determined, image connectivity domain is by gray scale Value is the connected region that the pixel of the first numerical value is constituted;
For each image connectivity domain in multiple image connectivity domain, the statistical parameter in the image connectivity domain is determined, the system Counting parameter is area or width;
When the statistical parameter is greater than or equal to the first parameter threshold or the statistical parameter less than or equal to the second parameter threshold When value, second value is set by the gray value of pixel in the image connectivity domain, the first parameter threshold is greater than the second parameter threshold Value.
In another embodiment of the present disclosure, this method further include:
When the angle is greater than the specified angle threshold value, display reminding information, to prompt user to reacquire figure to be processed Picture.
All the above alternatives, can form the alternative embodiment of the disclosure according to any combination, and the disclosure is real It applies example and this is no longer repeated one by one.
Fig. 2 is a kind of flow chart of image pre-processing method shown according to an exemplary embodiment.Referring to fig. 2, the party Method includes the following steps.
In step 201, image to be processed is converted into grayscale image, from the grayscale image, determines each boundary of card The image-region at place.
Since the most important application of image procossing is to identify to the card in image, and the identification of card is mainly Each boundary of identification card, and in order to improve the recognition accuracy of card and recognition efficiency, it is obtained when by shooting card After image to be processed, which can be converted to image to be processed grayscale image, and from the grayscale image, determine the card Image-region where each boundary.
And the terminal is from the grayscale image, the operation of image-region where determining each boundary of the card can be with are as follows: should Terminal obtains the corresponding regional scope in each boundary of the card, and the regional scope based on acquisition, from the grayscale image, determining should Image-region where each boundary of card.
Wherein, the corresponding regional scope in each boundary of the card can be arranged in advance, and each boundary pair of the card The regional scope answered is regional scope of each boundary at a distance of each edge of image to be processed of the card, for example, for this The coboundary of card, the corresponding regional scope in the coboundary can be the region model with image top edge to be processed at a distance of 0~5cm Enclose, alternatively, between image top edge to be processed a quarter picture traverse regional scope, or, with image to be processed The regional scope etc. of a quarter image area between top edge, the embodiment of the present disclosure is not specifically limited in this embodiment.In addition, should The corresponding regional scope in each boundary of card can be equal, can also be unequal, and the embodiment of the present disclosure, which does not do this equally, to be had Body limits.
For example, the corresponding regional scope in each boundary of the card be with each border 0 of the image to be processed~ The regional scope of 5cm, as shown in figure 3, the corresponding range in coboundary based on the card, since the top edge of the grayscale image, The image-region A of 0~5cm is obtained, the length of image-region A is equal with length of upper edge, and the image-region A that will acquire is determined as Image-region where the coboundary of the card;Similarly, the corresponding range of lower boundary based on the card, under the grayscale image Edge starts, and obtains the image-region B of 0~5cm, the length and lower edge equal length of image-region B, the image district that will acquire Domain B is determined as the image-region where the lower boundary of the card;Similarly, the corresponding range of left margin based on the card, from this The left edge of grayscale image starts, and obtains the image-region C of 0~5cm, the length of image-region C and the equal length of left edge, will The image-region C of acquisition is determined as the image-region where the left margin of the card;Similarly, the right margin based on the card is corresponding Range obtain the image-region D of 0~5cm since the right hand edge of the grayscale image, the length of image-region D and right hand edge Equal length, the image-region D that will acquire are determined as the image-region where the right margin of the card.
It should be noted that the method that image to be processed is converted to grayscale image can be with reference to the relevant technologies, the disclosure is real It applies example and this is not set forth in detail.
In addition, the terminal may be used also when the terminal determines the image-region in the grayscale image where each boundary of card With the image district from the multiple images region divided in advance to target image, where each boundary of choice cards The corresponding grayscale image of the image-region of selection is determined as the image-region in the grayscale image where each boundary of card by domain.
In step 202, for each boundary of the card, it is based on boundary institute pixel in the image area, by this Image-region where boundary carries out self-adaption binaryzation processing, the bianry image of image-region where obtaining the boundary.
In order to improve the efficiency of binary conversion treatment, and the effect of promotion binary conversion treatment, in the embodiments of the present disclosure, this Terminal can carry out self-adaption binaryzation processing to the image-region where each boundary of the card, and for each of the card A boundary, the operation which carries out self-adaption binaryzation processing to the image-region where the boundary can be with are as follows: for the side Institute of boundary each pixel in the image area, obtains the pixel neighborhood of a point;Based on the gray value of pixel in the neighborhood, determine First gray threshold;When the gray value of the pixel is greater than or equal to the first gray threshold, the gray value of the pixel is set It is set to the first numerical value;When the gray value of the pixel is less than the first gray threshold, is set by the gray value of the pixel Two numerical value.
Wherein, the shape of neighborhood of pixel points can be rectangle, circle, ellipse etc., and the embodiment of the present disclosure does not do this It is specific to limit.And when the shape of neighborhood of pixel points is rectangle, the operation which obtains the pixel neighborhood of a point can be with are as follows: will Centered on the pixel, in the image area from boundary institute, the rectangular area of default long side and default short side is obtained, by this Rectangular area is determined as the pixel neighborhood of a point.When the shape of neighborhood of pixel points is round, which obtains the neighbour of pixel The operation in domain can be with are as follows: the terminal in the image area from boundary institute obtains pre-set radius using the pixel as the center of circle The border circular areas is determined as the pixel neighborhood of a point by border circular areas.And when the shape of neighborhood of pixel points is ellipse, the end The operation that end obtains pixel neighborhood of a point can be with are as follows: centered on the pixel, in the image area from boundary institute, obtains The elliptical region of default major axis radius and default minor axis radius, is determined as the pixel neighborhood of a point for the elliptical region.When So, the shape of the neighborhood of pixel points can also be other shapes, and the embodiment of the present disclosure will not enumerate herein.
It should be noted that default long side, default short side, pre-set radius, default major axis radius and default minor axis radius are equal It can preset, and default long side, default short side, pre-set radius, default major axis radius and default minor axis radius not only can be with It is described, can also be described using the quantity of pixel using length, for example, the default long side is not only for presetting major diameter It can be 0.5cm, can also be 5 pixels, the embodiment of the present disclosure is not specifically limited in this embodiment.
For example, the shape of neighborhood of pixel points is rectangle, and default long side and default short side be using the quantity of pixel come Description, if, default long side is 5 pixels, and default short side is 5 pixels, therefore, for where the coboundary of the card Pixel a in image-region, as shown in figure 4, the terminal from image-region A, obtains centered on pixel a default The rectangular area is determined as the neighborhood of pixel a by the rectangular area of long side and default short side.
Wherein, gray value of the terminal based on pixel in the neighborhood when determining the first gray threshold, can determine the neighbour The average value of all pixels point gray value, is determined as the first gray threshold for the average value in domain.In addition, the terminal can also incite somebody to action The average value is multiplied with designated ratio, and product is determined as the first gray threshold.Certainly, which can also pass through its other party Method determines the first gray threshold, for example, by being less than in the gray value and the neighborhood that are greater than the second gray threshold in the neighborhood The weighted average method of the gray value of third gray threshold, the embodiment of the present disclosure will not enumerate this.
Further, after the terminal obtains the pixel neighborhood of a point, which can also determine the first ratio and Two ratios, the first ratio are the ratio that gray value is shared in total number greater than the pixel number of the second gray threshold in the neighborhood , the gray value ratio shared in the total number less than the pixel number of third gray threshold in the second ratio neighborhood Example, the total number are the number of all pixels point in the neighborhood;It, should when the first ratio and the second ratio are respectively less than proportion threshold value The step of terminal can execute the above-mentioned gray value based on pixel in neighborhood, determine the first gray threshold.
And when the first ratio is greater than or equal to proportion threshold value, which can set the gray value of the pixel to the One numerical value;When the second ratio is greater than or equal to proportion threshold value, second value is set by the gray value of the pixel.
Wherein, which determines that the operation of the first ratio and the second ratio can be with are as follows: the terminal obtains the neighborhood and includes The gray value of pixel, the gray value based on acquisition determine that gray value is greater than the pixel number of the second gray threshold, and really Determine gray value be less than third gray threshold pixel number, by gray value be greater than the second gray threshold pixel number divided by The total number obtains the first ratio, and the pixel number that gray value is less than third gray threshold is obtained divided by the total number To the second ratio.
It should be noted that the first numerical value and second value can be arranged in advance, and the first numerical value is greater than second value, than Such as, the first numerical value can be 255,254,253 etc., and second value can be 0,1,2 etc., and in order to further increase card The recognition accuracy on each boundary, and the effect of image preprocessing is promoted, the first numerical value can be 255, and second value can be with It is 0, the embodiment of the present disclosure is not specifically limited in this embodiment.
In addition, the second gray threshold, third gray threshold and proportion threshold value can also be arranged in advance, and the second gray threshold Greater than third gray threshold, for example, the second gray threshold is 200, third gray threshold is 30, proportion threshold value 0.8, the disclosure Embodiment is equally not specifically limited this.
Based on above-mentioned example, when the terminal is from image-region A, after the neighborhood for determining pixel a, which determines should The number of all pixels point is 25 in neighborhood, be that is to say, total number 25.If the second gray threshold is 200, third gray scale Threshold value is 30, proportion threshold value 0.8, and the first numerical value is 255, and second value 0, the terminal determines gray value from the neighborhood Pixel number greater than 200 is 22, determines that pixel number of the gray value less than 30 is 3, by 22 divided by 25, obtains the first ratio Example is 0.88, and by 3 divided by 25, second ratio that obtains is 0.12, which determines that the first ratio is greater than proportion threshold value, at this point, should Terminal sets 255 for the gray value of the pixel.Image-region A progress self-adaption binaryzation is handled it based on this method Afterwards, available bianry image as shown in Figure 5, wherein replace black using striped lattice in Fig. 5.
In step 203, each boundary of the card is obtained where from the boundary in the bianry image of image-region A plurality of line segment is taken, which is made of the pixel that multiple gray values are the first numerical value respectively.
Since each boundary of card is substantially parallel with the long side of image-region where each boundary, for the ease of Where from the boundary in the bianry image of image-region, a plurality of line segment is obtained, which may determine that image district where the boundary The long side of the bianry image in domain whether with horizontal direction parallel;The long side and water of the bianry image of image-region where the boundary Square to it is not parallel when, the bianry image of image-region where the boundary is rotated, image-region where making the boundary The long side and horizontal direction parallel of bianry image;From every row pixel that postrotational bianry image includes, acquisition connects respectively Continuous multiple gray values are the pixel of the first numerical value;The line that the multiple pixels obtained respectively from every row pixel are constituted Section is determined as a plurality of line segment.
It should be noted that in the embodiments of the present disclosure, which can not only be handled by above-mentioned self-adaption binaryzation Method, binary conversion treatment is carried out to image-region where each boundary, certainly, in practical application, which can also pass through Other methods carry out binary conversion treatment to image-region where each boundary, for example, the terminal can be by each boundary institute The gray value of pixel is compared with the 4th gray threshold in the image area, when the gray value of pixel is greater than the 4th gray scale When threshold value, the first numerical value is set by the gray value of the pixel, it, will when the gray value of pixel is less than four gray thresholds The gray value of the pixel is set as second value.
Wherein, which needs to obtain the pixel that gray value is greater than the 4th gray threshold, and less than the 4th The pixel of gray threshold, therefore, the terminal can be obtained using filter, which can be sobel (Sobel) Filter, the embodiment of the present disclosure are not specifically limited in this embodiment.In addition, the 4th gray threshold can be arranged in advance, the disclosure is implemented Example is equally not specifically limited this.
In step 204, it is based on a plurality of line segment, the bianry image of image-region where the boundary is pre-processed.
In order to improve the accuracy of card recognition, which can be based on a plurality of line segment, to image district where the boundary The bianry image in domain is pre-processed, and is based on a plurality of line segment, is carried out to the bianry image of image-region where the boundary pre- The operation of processing can be with are as follows: for every line segment in a plurality of line segment, determines the angle between the line segment and horizontal direction;When this When angle is less than or equal to specified angle threshold value, the line segment length of the line segment is determined;When the line segment length is less than designated length threshold When value, second value is set by the gray value for constituting multiple pixels of the line segment.
Further, when the angle be greater than specified angle threshold value when, display reminding information, with prompt user reacquire to Handle image.In addition, retaining the multiple pixels for constituting the line segment when the line segment length is greater than or equal to designated length threshold value Point, that is to say, maintaining the gray value for constituting multiple pixels of the line segment is that the first numerical value is constant.
For example, a plurality of line segment in bianry image shown in fig. 5 is obtained, if, which is respectively line segment 1, line Section 2, line segment 3 ... line segment n, determine the angle of a plurality of line segment between horizontal direction, and determine line segment 1, line segment in turn 2, line segment 4, line segment 5, line segment 7, line segment 12, line segment 15, line segment 21, line segment 25, line segment 28, line segment 30, line segment 35 and line segment 44 The angle between horizontal direction is less than or equal to specified angle threshold value respectively.Later, which determines line segment 1, line segment 2, line Section 4, line segment 5, line segment 7, line segment 12, line segment 15, line segment 21, line segment 25, line segment 28, line segment 30, line segment 35 and line segment 44 line Segment length is respectively 10cm, 12cm, 3cm, 5cm, 2.5cm, 15cm, 14cm, 11cm, 12.2cm, 1cm, 7cm, 10cm, 4.5cm, If designated length threshold value is 10cm, which determines the line of line segment 4, line segment 5, line segment 7, line segment 28, line segment 33 and line segment 44 Segment length is less than designated length threshold value 10cm, and therefore, which will constitute line segment 4, line segment 5, line segment 7, line segment 28,33 and of line segment The gray value of multiple pixels of line segment 44 is set as 0, obtains image as shown in FIG. 6.
In order to which the bianry image further to image-region where the boundary pre-processes, when the line segment length is small When designated length threshold value, set the gray value for constituting multiple pixels of the line segment to after second value, further includes: from Where the boundary in the bianry image of image-region, multiple images connected domain is determined, which is first by gray value The connected region that the pixel of numerical value is constituted;For each image connectivity domain in multiple image connectivity domain, determine that the image connects The statistical parameter in logical domain, the statistical parameter are area or width;When the statistical parameter be greater than or equal to the first parameter threshold, or When person's statistical parameter is less than or equal to the second parameter threshold, second is set by the gray value of pixel in the image connectivity domain Numerical value, the first parameter threshold are greater than the second parameter threshold.
Further, when the statistical parameter is less than the first parameter threshold and is greater than the second parameter threshold, the image is maintained The gray value of pixel is that the first numerical value is constant in connected domain.
It should be noted that the first parameter threshold and the second parameter threshold can be arranged in advance, and when image connectivity domain When statistical parameter difference, the first parameter threshold and the second parameter threshold be can also be different, and the embodiment of the present disclosure is not done this specifically It limits.In addition, specified angle threshold value and designated length threshold value can also be arranged in advance, for example, specified angle threshold value can be 5 Degree, designated length threshold value can be the 80% of image long side, and the embodiment of the present disclosure is equally not specifically limited this.
In the embodiments of the present disclosure, each boundary institute pixel in the image area based on card, respectively by each side Image-region where boundary carries out self-adaption binaryzation processing, the bianry image of image-region where obtaining each boundary, and by It needs in self-adaption binaryzation processing in view of the pixel gray value in each neighborhood of pixel points, this improves binaryzations The accuracy rate of processing, and then improve the effect of binary conversion treatment.In addition, due to the gray scale of pixel in determining bianry image Value is the first numerical value or second value, and from the bianry image of each boundary place image-region, it is obtained respectively by multiple Gray value is a plurality of line segment that the pixel of the first numerical value is constituted, can be to image where each boundary by a plurality of line segment The bianry image in region is further processed, to filter out some burrs on edges on each boundary of card, is more dashed forward clearly The boundary for showing card improves the effect of image preprocessing.
Fig. 7 is a kind of image preprocess apparatus block diagram shown according to an exemplary embodiment.Referring to Fig. 7, the device packet Determining module 701 is included, module 702 and preprocessing module 703 are obtained.
Determining module 701, for being based on image to be processed, the binary map of image-region where determining each boundary of card Picture;
Module 702 is obtained, for each boundary for the card, the bianry image of image-region where from the boundary In, a plurality of line segment is obtained, which is made of the pixel that multiple gray values are the first numerical value respectively;
Preprocessing module 703 carries out the bianry image of image-region where the boundary pre- for being based on a plurality of line segment Processing.
Referring to Fig. 8, determining module 701 includes:
Converting unit 7011, for image to be processed to be converted to grayscale image;
First determination unit 7012, for determining the image-region where each boundary of the card from the grayscale image;
Binary conversion treatment unit 7013, for each boundary for the card, in the image area based on the boundary Image-region where the boundary is carried out self-adaption binaryzation processing by pixel, the two of image-region where obtaining the boundary It is worth image.
Referring to Fig. 9, binary conversion treatment unit 7013 includes:
Subelement 70131 is obtained, for obtaining the pixel for boundary institute each pixel in the image area Neighborhood;
First determines that subelement 70132 determines the first gray threshold for the gray value based on pixel in the neighborhood;
First setting subelement 70133, for inciting somebody to action when the gray value of the pixel is greater than or equal to the first gray threshold The gray value of the pixel is set as the first numerical value;
Second setting subelement 70134, for when the gray value of the pixel is less than the first gray threshold, by the pixel The gray value of point is set as second value.
Referring to Figure 10, binary conversion treatment unit 7013 further include:
Second determines subelement 70135, for determining that the first ratio and the second ratio, the first ratio are gray scale in the neighborhood The value ratio shared in total number greater than the pixel number of the second gray threshold, the second ratio are that gray value is small in the neighborhood In the pixel number of third gray threshold ratio shared in total number, total number is of all pixels point in the neighborhood Number;
Subelement 70136 is executed, for executing and being based on the neighbour when the first ratio and the second ratio are respectively less than proportion threshold value The gray value of pixel in domain, the step of determining the first gray threshold.
Referring to Figure 11, binary conversion treatment unit 7013 further include:
Subelement 70137 is arranged in third, is used for when the first ratio is greater than or equal to proportion threshold value, by the ash of the pixel Angle value is set as the first numerical value;
4th setting subelement 70138, is used for when the second ratio is greater than or equal to proportion threshold value, by the ash of the pixel Angle value is set as second value.
Referring to Figure 12, obtaining module 702 includes:
Judging unit 7021, for judge image-region where the boundary bianry image long side whether with horizontal direction In parallel;
Rotary unit 7022, it is not parallel for the long side and horizontal direction of the bianry image of image-region where the boundary When, the bianry image of image-region where the boundary is rotated, the length of the bianry image of image-region where making the boundary Side and horizontal direction parallel;
Acquiring unit 7023, for obtaining respectively continuous from every row pixel that postrotational bianry image includes Multiple gray values are the pixel of first numerical value;
Second determination unit 7024, the line segment that multiple pixels for will obtain respectively from every row pixel are constituted are true It is set to a plurality of line segment.
Referring to Figure 13, preprocessing module 703 includes:
Third determination unit 7031, for for every line segment in a plurality of line segment, determine the line segment and horizontal direction it Between angle;
4th determination unit 7032, for determining the line of the line segment when the angle is less than or equal to specified angle threshold value Segment length;
First setting unit 7033, for the more of the line segment will to be constituted when the line segment length is less than designated length threshold value The gray value of a pixel is set as second value.
Referring to Figure 14, preprocessing module 703 further include:
5th determination unit 7034, for from the bianry image of image-region where the boundary, determining that multiple images connect Logical domain, the connected region that multiple image connectivity domain is made of the pixel that gray value is the first numerical value respectively;
6th determination unit 7035, for determining the image for each image connectivity domain in multiple image connectivity domain The statistical parameter of connected domain, the statistical parameter are area or width;
Second setting unit 7036, for being greater than or equal to the first parameter threshold or statistics ginseng when the statistical parameter When number is less than or equal to the second parameter threshold, the second value is set by the gray value of pixel in the image connectivity domain, it should First parameter threshold is greater than the second parameter threshold.
In the embodiments of the present disclosure, it is based on image to be processed, the two-value of image-region where determining each boundary of card Image, since the gray value of pixel in determining bianry image is the first numerical value or second value, and from each boundary institute In the bianry image of image-region, a plurality of line segment being made of the pixel that multiple gray values are the first numerical value is obtained respectively, By a plurality of line segment, the bianry image of image-region where each boundary can be further processed, to filter out card Some burrs on edges on each boundary of piece, more highlight the boundary of card clearly, improve the effect of image preprocessing.
About the device in above-described embodiment, wherein modules execute the concrete mode of operation in related this method Embodiment in be described in detail, no detailed explanation will be given here.
Figure 15 is a kind of block diagram of device 1500 for image procossing shown according to an exemplary embodiment.For example, Device 1500 can be mobile phone, computer, digital broadcasting terminal, messaging device, game console, tablet device, Medical Devices, body-building equipment, personal digital assistant etc..
Referring to Fig.1 5, device 1500 may include following one or more components: processing component 1502, memory 1504, Power supply module 1506, multimedia component 1508, audio component 1510, the interface 1512 of input/output (I/O), sensor module 1514 and communication component 1516.
The integrated operation of the usual control device 1500 of processing component 1502, such as with display, telephone call, data communication, Camera operation and record operate associated operation.Processing element 1502 may include one or more processors 1520 to execute Instruction, to perform all or part of the steps of the methods described above.In addition, processing component 1502 may include one or more moulds Block, convenient for the interaction between processing component 1502 and other assemblies.For example, processing component 1502 may include multi-media module, To facilitate the interaction between multimedia component 1508 and processing component 1502.
Memory 1504 is configured as storing various types of data to support the operation in equipment 1500.These data Example includes the instruction of any application or method for operating on device 1500, contact data, telephone book data, Message, picture, video etc..Memory 1504 can by any kind of volatibility or non-volatile memory device or they Combination is realized, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), it is erasable can Program read-only memory (EPROM), programmable read only memory (PROM), read-only memory (ROM), magnetic memory, flash memory Reservoir, disk or CD.
Electric power assembly 1506 provides electric power for the various assemblies of device 1500.Electric power assembly 1506 may include power management System, one or more power supplys and other with for device 1500 generate, manage, and distribute the associated component of electric power.
Multimedia component 1508 includes the screen of one output interface of offer between described device 1500 and user.? In some embodiments, screen may include liquid crystal display (LCD) and touch panel (TP).If screen includes touch panel, Screen may be implemented as touch screen, to receive input signal from the user.Touch panel includes that one or more touch passes Sensor is to sense the gesture on touch, slide, and touch panel.The touch sensor can not only sense touch or sliding is dynamic The boundary of work, but also detect duration and pressure associated with the touch or slide operation.In some embodiments, more Media component 1508 includes a front camera and/or rear camera.When equipment 1500 is in operation mode, as shot mould When formula or video mode, front camera and/or rear camera can receive external multi-medium data.Each preposition camera shooting Head and rear camera can be a fixed optical lens system or have focusing and optical zoom capabilities.
Audio component 1510 is configured as output and/or input audio signal.For example, audio component 1510 includes a wheat Gram wind (MIC), when device 1500 is in operation mode, when such as call mode, recording mode, and voice recognition mode, microphone quilt It is configured to receive external audio signal.The received audio signal can be further stored in memory 1504 or via communication Component 1516 is sent.In some embodiments, audio component 1510 further includes a loudspeaker, is used for output audio signal.
I/O interface 1512 provides interface, above-mentioned peripheral interface module between processing component 1502 and peripheral interface module It can be keyboard, click wheel, button etc..These buttons may include, but are not limited to: home button, volume button, start button and Locking press button.
Sensor module 1514 includes one or more sensors, and the state for providing various aspects for device 1500 is commented Estimate.For example, sensor module 1514 can detecte the state that opens/closes of equipment 1500, the relative positioning of component, such as institute The display and keypad that component is device 1500 are stated, sensor module 1514 can be with detection device 1500 or device 1,500 1 The position change of a component, the existence or non-existence that user contacts with device 1500,1500 orientation of device or acceleration/deceleration and dress Set 1500 temperature change.Sensor module 1514 may include proximity sensor, be configured in not any physics It is detected the presence of nearby objects when contact.Sensor module 1514 can also include optical sensor, as CMOS or ccd image are sensed Device, for being used in imaging applications.In some embodiments, which can also include acceleration sensing Device, gyro sensor, Magnetic Sensor, pressure sensor or temperature sensor.
Communication component 1516 is configured to facilitate the communication of wired or wireless way between device 1500 and other equipment.Dress The wireless network based on communication standard, such as WiFi can be accessed by setting 1500,2G or 3G or their combination.It is exemplary at one In embodiment, communication component 1516 receives broadcast singal or broadcast correlation from external broadcasting management system via broadcast channel Information.In one exemplary embodiment, the communication component 1516 further includes near-field communication (NFC) module, to promote short distance Communication.For example, radio frequency identification (RFID) technology, Infrared Data Association (IrDA) technology, ultra wide band can be based in NFC module (UWB) technology, bluetooth (BT) technology and other technologies are realized.
In the exemplary embodiment, device 1500 can be by one or more application specific integrated circuit (ASIC), number Signal processor (DSP), digital signal processing appts (DSPD), programmable logic device (PLD), field programmable gate array (FPGA), controller, microcontroller, microprocessor or other electronic components are realized, for executing the above method.
In the exemplary embodiment, a kind of non-transitorycomputer readable storage medium including instruction, example are additionally provided It such as include the memory 1504 of instruction, above-metioned instruction can be executed by the processor 1520 of device 1500 to complete the above method.Example Such as, the non-transitorycomputer readable storage medium can be ROM, random access memory (RAM), CD-ROM, tape, soft Disk and optical data storage devices etc..
A kind of non-transitorycomputer readable storage medium, when the instruction in the storage medium is by the processing of mobile terminal When device executes, so that mobile terminal is able to carry out a kind of image pre-processing method, which comprises
Based on image to be processed, the bianry image of image-region where determining each boundary of card;
A plurality of line segment is obtained where from the boundary in the bianry image of image-region for each boundary of the card, it should A plurality of line segment is made of the pixel that multiple gray values are the first numerical value respectively;
Based on a plurality of line segment, the bianry image of image-region where the boundary is pre-processed.
In another embodiment of the present disclosure, it is based on image to be processed, determines image-region where each boundary of card Bianry image, comprising:
Image to be processed is converted into grayscale image;
From the grayscale image, the image-region where each boundary of the card is determined;
For each boundary of the card, it is based on boundary institute pixel in the image area, by the figure where the boundary As region progress self-adaption binaryzation processing, the bianry image of image-region where obtaining the boundary.
In another embodiment of the present disclosure, it is based on boundary institute pixel in the image area, it will be where the boundary Image-region carries out self-adaption binaryzation processing, the bianry image of image-region where obtaining the boundary, comprising:
For boundary institute each pixel in the image area, the pixel neighborhood of a point is obtained;
Based on the gray value of pixel in the neighborhood, the first gray threshold is determined;
When the gray value of the pixel is greater than or equal to the first gray threshold, the is set by the gray value of the pixel One numerical value;
When the gray value of the pixel is less than the first gray threshold, the second number is set by the gray value of the pixel Value.
In another embodiment of the present disclosure, after obtaining the pixel neighborhood of a point, further includes:
Determine that the first ratio and the second ratio, the first ratio are the pixel that gray value is greater than the second gray threshold in the neighborhood Point number ratio shared in total number, the second ratio are the pixel that gray value is less than third gray threshold in the neighborhood Number ratio shared in total number, the total number are the number of all pixels point in the neighborhood;
When the first ratio and the second ratio are respectively less than proportion threshold value, the gray value based on pixel in the neighborhood is executed, The step of determining the first gray threshold.
In another embodiment of the present disclosure, after determining the first ratio and the second ratio, further includes:
When the first ratio is greater than or equal to the proportion threshold value, the first numerical value is set by the gray value of the pixel;
When the second ratio is greater than or equal to the proportion threshold value, second value is set by the gray value of the pixel.
In another embodiment of the present disclosure, where from the boundary in the bianry image of image-region, a plurality of line segment is obtained, Include:
Judge the bianry image of image-region where the boundary long side whether with horizontal direction parallel;
When the long side and horizontal direction of the bianry image of image-region where the boundary are not parallel, scheme to where the boundary As the bianry image in region is rotated, the long side and horizontal direction parallel of the bianry image of image-region where making the boundary;
From every row pixel that postrotational bianry image includes, obtaining continuous multiple gray values respectively is the first number The pixel of value;
The line segment that the multiple pixels obtained respectively from every row pixel are constituted is determined as a plurality of line segment.
In another embodiment of the present disclosure, it is based on a plurality of line segment, to the bianry image of image-region where the boundary It is pre-processed, comprising:
For every line segment in a plurality of line segment, the angle between the line segment and horizontal direction is determined;
When the angle is less than or equal to specified angle threshold value, the line segment length of the line segment is determined;
When the line segment length is less than designated length threshold value, set the gray value for constituting multiple pixels of the line segment to Second value.
In another embodiment of the present disclosure, when the line segment length is less than designated length threshold value, the line segment will be constituted The gray value of multiple pixels is set as after second value, further includes:
Where from the boundary in the bianry image of image-region, multiple images connected domain is determined, image connectivity domain is by gray scale Value is the connected region that the pixel of the first numerical value is constituted;
For each image connectivity domain in multiple image connectivity domain, the statistical parameter in the image connectivity domain is determined, the system Counting parameter is area or width;
When the statistical parameter is greater than or equal to the first parameter threshold or the statistical parameter less than or equal to the second parameter threshold When value, second value is set by the gray value of pixel in the image connectivity domain, the first parameter threshold is greater than the second parameter threshold Value.
In another embodiment of the present disclosure, this method further include:
When the angle is greater than the specified angle threshold value, display reminding information, to prompt user to reacquire figure to be processed Picture.
In the embodiments of the present disclosure, it is based on image to be processed, the two-value of image-region where determining each boundary of card Image, since the gray value of pixel in determining bianry image is the first numerical value or second value, and from each boundary institute In the bianry image of image-region, a plurality of line segment being made of the pixel that multiple gray values are the first numerical value is obtained respectively, By a plurality of line segment, the bianry image of image-region where each boundary can be further processed, to filter out card Some burrs on edges on each boundary of piece, more highlight the boundary of card clearly, improve the effect of image preprocessing.
Those skilled in the art after considering the specification and implementing the invention disclosed here, will readily occur to of the invention its Its embodiment.This application is intended to cover any variations, uses, or adaptations of the invention, these modifications, purposes or Person's adaptive change follows general principle of the invention and including the undocumented common knowledge in the art of the disclosure Or conventional techniques.The description and examples are only to be considered as illustrative, and true scope and spirit of the invention are by following Claim is pointed out.
It should be understood that the present invention is not limited to the precise structure already described above and shown in the accompanying drawings, and And various modifications and changes may be made without departing from the scope thereof.The scope of the present invention is limited only by the attached claims.

Claims (15)

1. a kind of image pre-processing method, which is characterized in that the described method includes:
Based on image to be processed, the bianry image of image-region where determining each boundary of card;
A plurality of line segment is obtained from the bianry image of boundary place image-region for each boundary, it is described a plurality of Line segment is made of the pixel that multiple gray values are the first numerical value respectively;
For every line segment in a plurality of line segment, the angle between the line segment and horizontal direction is determined;
When the angle is less than or equal to specified angle threshold value, the line segment length of the line segment is determined;
When the line segment length is less than designated length threshold value, set the gray value for constituting multiple pixels of the line segment to Second value;
From the bianry image of boundary place image-region, multiple images connected domain is determined, described image connected domain is by ash Angle value is the connected region that the pixel of first numerical value is constituted;
For image connectivity domain each in described multiple images connected domain, the statistical parameter of described image connected domain is determined, it is described Statistical parameter is area or width;
When the statistical parameter is greater than or equal to the first parameter threshold or the statistical parameter less than or equal to the second parameter threshold When value, the second value is set by the gray value of pixel in described image connected domain, first parameter threshold is greater than Second parameter threshold.
2. the method as described in claim 1, which is characterized in that it is described to be based on image to be processed, determine each boundary of card The bianry image of place image-region, comprising:
The image to be processed is converted into grayscale image;
From the grayscale image, the image-region where each boundary of the card is determined;
For each boundary, it is based on boundary institute pixel in the image area, by the image district where the boundary Domain carries out self-adaption binaryzation processing, the bianry image of image-region where obtaining the boundary.
3. method according to claim 2, which is characterized in that it is described to be based on boundary institute pixel in the image area, Image-region where the boundary is subjected to self-adaption binaryzation processing, the binary map of image-region where obtaining the boundary Picture, comprising:
For boundary institute each pixel in the image area, the pixel neighborhood of a point is obtained;
Based on the gray value of pixel in the neighborhood, the first gray threshold is determined;
When the gray value of the pixel is greater than or equal to first gray threshold, the gray value of the pixel is arranged For the first numerical value;
When the gray value of the pixel is less than first gray threshold, second is set by the gray value of the pixel Numerical value.
4. method as claimed in claim 3, which is characterized in that after the acquisition pixel neighborhood of a point, further includes:
Determine that the first ratio and the second ratio, first ratio are the picture that gray value is greater than the second gray threshold in the neighborhood Vegetarian refreshments number ratio shared in total number, second ratio are that gray value is less than third gray threshold in the neighborhood Pixel number ratio shared in the total number, the total number are the number of all pixels point in the neighborhood;
When first ratio and second ratio are respectively less than proportion threshold value, execute described based on pixel in the neighborhood Gray value, the step of determining the first gray threshold.
5. method as claimed in claim 4, which is characterized in that after first ratio of determination and the second ratio, further includes:
When first ratio is greater than or equal to the proportion threshold value, described first is set by the gray value of the pixel Numerical value;
When second ratio is greater than or equal to the proportion threshold value, described second is set by the gray value of the pixel Numerical value.
6. the method as described in claim 1, which is characterized in that the bianry image of the image-region where the boundary In, obtain a plurality of line segment, comprising:
The long side of the bianry image of image-region where judging the boundary whether with horizontal direction parallel;
When the long side and horizontal direction of the bianry image of image-region where the boundary are not parallel, to figure where the boundary As the bianry image in region is rotated, the long side and horizontal direction of the bianry image of image-region where making the boundary are flat Row;
From every row pixel that postrotational bianry image includes, obtaining continuous multiple gray values respectively is first number The pixel of value;
The line segment that the multiple pixels obtained respectively from every row pixel are constituted is determined as a plurality of line segment.
7. the method as described in claim 1, which is characterized in that the method also includes:
When the angle is greater than the specified angle threshold value, display reminding information is described wait locate to prompt user to reacquire Manage image.
8. a kind of image preprocess apparatus, which is characterized in that described device includes:
Determining module, for being based on image to be processed, the bianry image of image-region where determining each boundary of card;
Module is obtained, for obtaining a plurality of from the bianry image of boundary place image-region for each boundary Line segment, a plurality of line segment are made of the pixel that multiple gray values are the first numerical value respectively;
Preprocessing module locates the bianry image of image-region where the boundary for being based on a plurality of line segment in advance Reason;
The preprocessing module, comprising:
Third determination unit, for determining between the line segment and horizontal direction for every line segment in a plurality of line segment Angle;
4th determination unit, for determining the length along path of the line segment when the angle is less than or equal to specified angle threshold value Degree;
First setting unit, for multiple pictures of the line segment will to be constituted when the line segment length is less than designated length threshold value The gray value of vegetarian refreshments is set as second value;
5th determination unit, for determining multiple images connected domain, institute from the bianry image of boundary place image-region State the connected region that image connectivity domain is made of the pixel that gray value is first numerical value;
6th determination unit, for determining that described image is connected to for image connectivity domain each in described multiple images connected domain The statistical parameter in domain, the statistical parameter are area or width;
Second setting unit, for working as, the statistical parameter is greater than or equal to the first parameter threshold or the statistical parameter is small When the second parameter threshold, the second value, institute are set by the gray value of pixel in described image connected domain The first parameter threshold is stated greater than second parameter threshold.
9. device as claimed in claim 8, which is characterized in that the determining module includes:
Converting unit, for the image to be processed to be converted to grayscale image;
First determination unit, for determining the image-region where each boundary of the card from the grayscale image;
Binary conversion treatment unit, for boundary institute pixel in the image area being based on, by institute for each boundary Image-region where stating boundary carries out self-adaption binaryzation processing, the bianry image of image-region where obtaining the boundary.
10. device as claimed in claim 9, which is characterized in that the binary conversion treatment unit includes:
Subelement is obtained, for obtaining the pixel neighborhood of a point for boundary institute each pixel in the image area;
First determines that subelement determines the first gray threshold for the gray value based on pixel in the neighborhood;
First setting subelement, for when the gray value of the pixel be greater than or equal to first gray threshold when, by institute The gray value for stating pixel is set as the first numerical value;
Second setting subelement, for when the gray value of the pixel be less than first gray threshold when, by the pixel The gray value of point is set as second value.
11. device as claimed in claim 10, which is characterized in that the binary conversion treatment unit further include:
Second determines subelement, for determining that the first ratio and the second ratio, first ratio are gray value in the neighborhood The ratio shared in total number greater than the pixel number of the second gray threshold, second ratio are gray scale in the neighborhood The value ratio shared in the total number less than the pixel number of third gray threshold, the total number are in the neighborhood The number of all pixels point;
Subelement is executed, for being based on described in execution when first ratio and second ratio are respectively less than proportion threshold value The gray value of pixel in the neighborhood, the step of determining the first gray threshold.
12. device as claimed in claim 11, which is characterized in that the binary conversion treatment unit further include:
Subelement is arranged in third, is used for when first ratio is greater than or equal to the proportion threshold value, by the pixel Gray value is set as first numerical value;
4th setting subelement, is used for when second ratio is greater than or equal to the proportion threshold value, by the pixel Gray value is set as the second value.
13. device as claimed in claim 8, which is characterized in that the acquisition module includes:
Judging unit, the long side of the bianry image for image-region where judging the boundary whether with horizontal direction parallel;
Rotary unit, it is right when not parallel for the long side and horizontal direction of the bianry image of image-region where the boundary The bianry image of image-region is rotated where the boundary, the long side of the bianry image of image-region where making the boundary With horizontal direction parallel;
Acquiring unit, for obtaining continuous multiple gray scales respectively from every row pixel that postrotational bianry image includes Value is the pixel of first numerical value;
Second determination unit, the line segment for constituting the multiple pixels obtained respectively from every row pixel are determined as The a plurality of line segment.
14. device as claimed in claim 8, which is characterized in that described device further include:
Display module is used for when the angle is greater than the specified angle threshold value, display reminding information, to prompt user again Obtain the image to be processed.
15. a kind of image preprocess apparatus, which is characterized in that described device includes:
Processor;
Memory for storage processor executable instruction;
Wherein, the processor is configured to:
Based on image to be processed, the bianry image of image-region where determining each boundary of card;
A plurality of line segment is obtained from the bianry image of boundary place image-region for each boundary, it is described a plurality of Line segment is made of the pixel that multiple gray values are the first numerical value respectively;
For every line segment in a plurality of line segment, the angle between the line segment and horizontal direction is determined;
When the angle is less than or equal to specified angle threshold value, the line segment length of the line segment is determined;
When the line segment length is less than designated length threshold value, set the gray value for constituting multiple pixels of the line segment to Second value;
From the bianry image of boundary place image-region, multiple images connected domain is determined, described image connected domain is by ash Angle value is the connected region that the pixel of first numerical value is constituted;
For image connectivity domain each in described multiple images connected domain, the statistical parameter of described image connected domain is determined, it is described Statistical parameter is area or width;
When the statistical parameter is greater than or equal to the first parameter threshold or the statistical parameter less than or equal to the second parameter threshold When value, the second value is set by the gray value of pixel in described image connected domain, first parameter threshold is greater than Second parameter threshold.
CN201510463446.2A 2015-07-31 2015-07-31 Image pre-processing method and device Active CN105046260B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201510463446.2A CN105046260B (en) 2015-07-31 2015-07-31 Image pre-processing method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201510463446.2A CN105046260B (en) 2015-07-31 2015-07-31 Image pre-processing method and device

Publications (2)

Publication Number Publication Date
CN105046260A CN105046260A (en) 2015-11-11
CN105046260B true CN105046260B (en) 2019-01-04

Family

ID=54452789

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201510463446.2A Active CN105046260B (en) 2015-07-31 2015-07-31 Image pre-processing method and device

Country Status (1)

Country Link
CN (1) CN105046260B (en)

Families Citing this family (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10795456B2 (en) * 2016-03-22 2020-10-06 Guangdong Virtual Reality Technology Co., Ltd. Method, device and terminal for determining effectiveness of stripe set
CN107111882B (en) * 2016-03-22 2021-01-05 广东虚拟现实科技有限公司 Stripe set searching method, device and system
CN107767538B (en) * 2017-11-07 2019-10-11 深圳怡化电脑股份有限公司 Acquire method, apparatus, ATM and the storage medium of bank note CIS image
CN109146970B (en) * 2018-08-03 2019-12-03 中国科学院力学研究所 The contact angle acquisition methods of gas-liquid two-phase dynamic displacement image in micron capillary column
CN108918348B (en) * 2018-08-03 2020-01-17 中国科学院力学研究所 Method for acquiring moving speed of gas-liquid phase interface in micron capillary channel
CN110872861A (en) * 2018-08-31 2020-03-10 魔水科技(北京)有限公司 Intelligent water spraying rod, intelligent toilet lid and flushing system integrated with visual function
CN109525882B (en) * 2018-11-30 2021-08-31 中国联合网络通信集团有限公司 Synchronous playing method, bridging equipment and sink equipment
CN110505459B (en) * 2019-08-16 2020-12-11 域鑫科技(惠州)有限公司 Image color correction method, device and storage medium suitable for endoscope
CN111986173B (en) * 2020-08-18 2023-06-02 创新奇智(合肥)科技有限公司 Method and device for acquiring straight-section graph

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101957995A (en) * 2010-10-14 2011-01-26 华中科技大学 Method for detecting and extracting correlation pixels in image and application thereof
CN103400150A (en) * 2013-08-14 2013-11-20 浙江大学 Method and device for road edge recognition based on mobile platform
CN103489254A (en) * 2012-06-11 2014-01-01 深圳信息职业技术学院 Lottery recognition method and lottery recognition system
CN104504684A (en) * 2014-12-03 2015-04-08 小米科技有限责任公司 Edge extraction method and device

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101957995A (en) * 2010-10-14 2011-01-26 华中科技大学 Method for detecting and extracting correlation pixels in image and application thereof
CN103489254A (en) * 2012-06-11 2014-01-01 深圳信息职业技术学院 Lottery recognition method and lottery recognition system
CN103400150A (en) * 2013-08-14 2013-11-20 浙江大学 Method and device for road edge recognition based on mobile platform
CN104504684A (en) * 2014-12-03 2015-04-08 小米科技有限责任公司 Edge extraction method and device

Also Published As

Publication number Publication date
CN105046260A (en) 2015-11-11

Similar Documents

Publication Publication Date Title
CN105046260B (en) Image pre-processing method and device
CN105069786B (en) Line detection method and device
CN106355573B (en) The localization method and device of object in picture
CN105488511B (en) The recognition methods of image and device
CN106951884B (en) Fingerprint acquisition method and device and electronic equipment
CN106454336B (en) The method and device and terminal that detection terminal camera is blocked
CN105095881B (en) Face recognition method, face recognition device and terminal
WO2017214793A1 (en) Fingerprint template generation method and apparatus
CN106934320B (en) Fingerprint identification method and device
CN105404863B (en) Character features recognition methods and system
CN106339695B (en) Face similarity detection method, device and terminal
CN105208284B (en) Shoot based reminding method and device
CN105760884B (en) The recognition methods of picture type and device
JP6391708B2 (en) Method and apparatus for acquiring iris image, and iris identification device
KR20180063246A (en) Fingerprint reader, method, program and recording medium
JP6392900B2 (en) Pressure detection method, apparatus, program, and recording medium
WO2018133387A1 (en) Fingerprint identification method and device
CN105100634B (en) Image capturing method and device
CN105117680B (en) A kind of method and apparatus of the information of ID card
CN105528078B (en) The method and device of controlling electronic devices
CN111695382A (en) Fingerprint collection area determining method and fingerprint collection area determining device
CN105975961B (en) The method, apparatus and terminal of recognition of face
CN105246068B (en) SIM card selection method and device
CN106210495A (en) Image capturing method and device
CN107426489A (en) Processing method, device and terminal during shooting image

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant