The content of the invention
It is an object of the present invention to provide the new solution of a kind of determination method of image detection region.
According to the first aspect of the invention, there is provided a kind of determination method of image detection region, including:
From detection image corresponding to examined object, the pixel in image corresponding to the examined object is obtained;
Pixel in image corresponding to the examined object is handled, obtains the examined object at least
Pixel corresponding to one profile;
Each pixel is calculated in each pixel corresponding at least one profile of respectively described examined object
Corresponding gradient direction;
The gradient direction that edge is calculated for each pixel, obtain the pixel of at least one pixel unit;
By each pixel and at least one pixel obtained along the gradient direction being calculated for each pixel
Point is combined, and forms pixel combination zone, and using the pixel combination zone as image detection region.
Alternatively, the detection image is gray level image, and the detection image includes figure corresponding to examined object
Picture and background image,
From detection image corresponding to examined object, the pixel in image corresponding to the examined object is obtained,
Including:
Using Blob algorithms, dividing processing is carried out to each pixel of the detection image, obtains the examined object
The pixel in pixel and the background image in corresponding image.
Alternatively, the pixel in image corresponding to the examined object is handled, obtains the thing to be detected
Pixel corresponding at least one profile of body, including:
Using Blob algorithms, piecemeal processing is carried out to the pixel in image corresponding to the examined object, obtained multigroup
Pixel;
Using the outermost pixel in each group pixel as picture corresponding at least one profile of the examined object
Vegetarian refreshments.
Alternatively, at least one profile using the outermost pixel in each group pixel as the examined object
Before corresponding pixel, methods described also includes:
Calculate the area or girth in the region that the outermost pixel in multigroup pixel is formed;
Area or girth and the default contour area in the region that the outermost pixel in multigroup pixel is formed
Threshold value or default profile perimeter threshold are compared, and obtain comparison result;
According to the comparison result, at least one set of pixel for meeting user's request is determined;
Using the outermost pixel in each group pixel as picture corresponding at least one profile of the examined object
Vegetarian refreshments, including:
Using the outermost pixel at least one set of pixel for meeting user's request as the examined object
At least one profile corresponding to pixel.
Alternatively, each pixel corresponding at least one profile of respectively described examined object is calculated described each
Gradient direction corresponding to pixel, including:
Obtain the gray scale of 8 adjacent pixels of each pixel corresponding at least one profile of the examined object
Value;
According to the gray value of 8 adjacent pixels of each pixel, it is calculated terraced corresponding to each pixel
Spend direction.Alternatively, using the length direction of the detection image as X-direction, made with the width of the detection image
For Y direction,
According to the gray value of 8 adjacent pixels of each pixel, the gradient side of each pixel is calculated
To, including:
Based on following calculating formula, gradient magnitude Magnitude of each pixel along the X-direction is obtainedx, and edge
The gradient magnitude Magnitude of the Y directiony,
Magnitudex={ (P3-P1)+[2×(P5-P4)]+(P8-P6)}/4
Magnitudey={ (P6-P1)+[2×(P7-P2)]+(P8-P3)}/4
Wherein, P1, P2, P3, P4, P5, P6, P7, P8 represent positioned at the upper left corner of current pixel point, surface, the right side respectively
Upper angle, front-left, front-right, the lower left corner, underface and the lower right corner pixel gray value;
Based on following calculating formula, gradient angle [alpha] is obtained,
α=atan2 (Magnitudey,Magnitudex),
According to the gradient angle [alpha], the gradient direction of each pixel is obtained.
According to the second aspect of the invention, there is provided a kind of determining device of image detection region, including:
First acquisition module, it is corresponding for from detection image corresponding to examined object, obtaining the examined object
Image in pixel;
Processing module, for handling the pixel in image corresponding to the examined object, obtain described treat
Pixel corresponding at least one profile of detection object;
Setup module, for being respectively that each pixel corresponding at least one profile of the examined object is calculated
Gradient direction corresponding to each pixel;
Second acquisition module, for along the gradient direction being calculated for each pixel, obtaining at least one pixel
The pixel of unit;
Composite module, for what is obtained by each pixel and along the gradient direction being calculated for each pixel
At least one pixel is combined, and forms pixel combination zone, and using the pixel combination zone as image detection
Region.
Alternatively, the detection image is gray level image, and the detection image includes figure corresponding to examined object
Picture and background image,
First acquisition module is additionally operable to:Using Blob algorithms, each pixel of the detection image is split
Processing, obtains the pixel in the pixel and the background image in image corresponding to the examined object.
Alternatively, the processing module is additionally operable to:
Using Blob algorithms, piecemeal processing is carried out to the pixel in image corresponding to the examined object, obtained multigroup
Pixel;
Using the outermost pixel in each group pixel as picture corresponding at least one profile of the examined object
Vegetarian refreshments.
According to the third aspect of the invention we, there is provided a kind of determining device of image detection region, it is characterised in that bag
Include:Memory and processor, wherein, the memory storage executable instruction, the executable instruction controls the processor
Operated to perform the determination method of the image detection region described in any of the above described one.
The determination method and device of image detection region provided by the invention, suitable for the detection of object of different shapes,
Relative to prior art, it is no longer necessary to develop different detection programs, and then avoid because the diversity of detection program causes
Whole detection device maintenance workload it is big the problem of.
By referring to the drawings to the present invention exemplary embodiment detailed description, further feature of the invention and its
Advantage will be made apparent from.
Embodiment
The various exemplary embodiments of the present invention are described in detail now with reference to accompanying drawing.It should be noted that:Unless have in addition
Body illustrates that the unlimited system of part and the positioned opposite of step, numerical expression and the numerical value otherwise illustrated in these embodiments is originally
The scope of invention.
The description only actually at least one exemplary embodiment is illustrative to be never used as to the present invention below
And its application or any restrictions that use.
It may be not discussed in detail for technology, method and apparatus known to person of ordinary skill in the relevant, but suitable
In the case of, the technology, method and apparatus should be considered as part for specification.
In shown here and discussion all examples, any occurrence should be construed as merely exemplary, without
It is as limitation.Therefore, other examples of exemplary embodiment can have different values.
It should be noted that:Similar label and letter represents similar terms in following accompanying drawing, therefore, once a certain Xiang Yi
It is defined, then it need not be further discussed in subsequent accompanying drawing in individual accompanying drawing.
An embodiment provides a kind of determination method of image detection region.Fig. 1 is shown according to this hair
The process chart of the determination method of the image detection region of bright one embodiment.Referring to Fig. 1, this method comprises at least following step
Rapid S101 to step S105.
Step S101, from detection image corresponding to examined object, obtain the picture in image corresponding to examined object
Vegetarian refreshments;
Step S102, the pixel in image corresponding to examined object is handled, obtain examined object extremely
Pixel corresponding to a few profile;
Each pixel is calculated in each pixel corresponding to step S103, respectively examined object at least one profile
Corresponding gradient direction;
Step S104, edge are the gradient direction that each pixel is calculated, and obtain the pixel of at least one pixel unit;
Step S105, by each pixel and at least one pixel obtained along the gradient direction being calculated for each pixel
Point is combined, and forms pixel combination zone, and using pixel combination zone as image detection region.
Detection image of the present invention is the image for being shot to obtain to examined object using camera.The detection figure
As being gray level image.Gray level image is typically shown as, from most furvous to most bright white gray scale, can so there is 256 grades of ashes
Degree.
In one embodiment of the present of invention, detection image had both included image corresponding to examined object, included background again
Image.It should be noted that image corresponding to examined object and background image have high contrast, in order to follow-up point
Cut processing.
In one embodiment of the present of invention, using Blob algorithms, dividing processing is carried out to each pixel of detection image, obtained
To the pixel in the pixel and background image in image corresponding to examined object.Blob algorithms are to phase in detection image
Connected domain with pixel is analyzed, and the connected domain is referred to as Blob.Specifically, a gray threshold is preset, by detection image
The gray value of each pixel is compared with the gray threshold respectively, determines that the pixel is examined object according to comparison result
Pixel in corresponding image, or be the pixel in background image.For example, examined object is placed on a white
Shot on background board, obtain gray level image, wherein, examined object is not white object, using Blob algorithms to the ash
Each pixel spent in image carries out dividing processing, wherein, it is 254 to preset gray threshold, by each pixel in gray level image
Gray value be compared respectively with default gray threshold, when a certain pixel gray value be more than 254 when, determine the pixel
For the pixel in background image, when the gray value of a certain pixel is less than 254, it is examined object pair to determine the pixel
Pixel in the image answered.It should be noted that default gray threshold 254 is merely possible to an example, to the present invention simultaneously
Any restriction is not caused.Default gray threshold can be the arbitrary value between 0 to 255.In addition, default gray threshold can be according to be checked
The brightness of image and the brightness of background image corresponding to object is surveyed to be configured.
After the pixel in getting image corresponding to examined object, in one embodiment of the present of invention, utilize
Blob algorithms, piecemeal processing is carried out to the pixel in image corresponding to examined object, obtains multigroup pixel, wherein, often
The gray value of each pixel in one group of pixel is same or like, and the close gray value for each pixel herein being related to is each picture
The difference of the gray value of vegetarian refreshments is in the range of default gray scale difference value.Then, using the outermost pixel in each group pixel as
Pixel corresponding at least one profile of examined object.
In one embodiment of the present of invention, using Blob algorithms, the pixel in image corresponding to examined object is clicked through
After the processing of row piecemeal, multigroup pixel is obtained, each group of pixel can correspond to a region, and each region can correspond at least one
Individual profile, it so can obtain multiple profiles.According to the demand of user, it may not be necessary to carry out quality inspection to obtained all profiles
Survey, now, first, the area in the region that the outermost pixel in multigroup pixel is formed is calculated, then, by multigroup pixel
In the area in region that is formed of outermost pixel be compared respectively with default contour area threshold value, obtain comparison result,
From comparison result, the pixel group more than default contour area threshold value is screened.Or first, calculate multigroup pixel
The girth in the region that the outermost pixel in point is formed, then, the area that the outermost pixel in multigroup pixel is formed
The girth in domain is compared with default profile perimeter threshold respectively, obtains comparison result, from comparison result, will exceed default wheel
The pixel group of wide perimeter threshold screens.It can so obtain meeting at least one corresponding to user's request, examined object
Pixel corresponding to bar profile.
After pixel corresponding at least one profile of examined object is obtained, gradient corresponding to each pixel is calculated
Direction.In one embodiment of the present of invention, first, it is adjacent to obtain each pixel corresponding at least one profile of examined object
8 pixels gray value, then, according to the gray value of 8 adjacent pixels of each pixel, each pixel is calculated
Corresponding gradient direction.
Fig. 2 shows the schematic diagram of the pixel according to an embodiment of the invention on profile.Referring to Fig. 2, figure
In each grid for showing represent a pixel, the image with gray scale is parts of images corresponding to examined object.Fig. 2
The profile of the examined object shown is a curve, and pixel A is located on the profile of examined object.It is right by taking pixel A as an example
Determine that gradient direction corresponding to pixel A illustrates.First, based on calculating formula (1) and calculating formula (2), pixel A edges are obtained
The gradient magnitude Magnitude of X-directionxWith the gradient magnitude Magnitude along Y directiony,
Magnitudex={ (P3-P1)+[2×(P5-P4)]+(P8-P6)/4-calculating formula (1),
Magnitudey={ (P6-P1)+[2×(P7-P2)]+(P8-P3)/4-calculating formula (2),
Wherein, P1、P2、P3、P4、P5、P6、P7、P8Represent respectively positioned at the pixel A upper left corner, surface, the upper right corner, just
Left, front-right, the lower left corner, underface and the lower right corner pixel gray value.Then, based on calculating formula (3), gradient is obtained
Angle [alpha],
α=atan2 (Magnitudey,Magnitudex)-calculating formula (3).
Finally, according to gradient angle [alpha], pixel A gradient direction is obtained.Fig. 3 is shown according to one implementation of the present invention
The schematic diagram of the gradient direction of example.Referring to Fig. 3, gradient direction includes 8 directions altogether.The corresponding gradient of each gradient direction
Angular range.Gradient angular range corresponding to first gradient direction for (- 22.5 °, 22.5 °], ladder corresponding to the second gradient direction
Spend angular range for (22.5 °, 67.5 °], gradient angular range corresponding to 3rd gradient direction for (67.5 °, 112.5 °], the 4th
Gradient angular range corresponding to gradient direction for (112.5 °, 157.5 °], gradient angular range corresponding to the 5th gradient direction is
(157.5 °, 180 °] and (- 180 °, -157.5 °], gradient angular range corresponding to the 6th gradient direction for (- 157.5 °, -
112.5 °], gradient angular range corresponding to the 7th gradient direction for (- 112.5 °, -67.5 °], ladder corresponding to the 8th gradient direction
Spend angular range for (- 67.5 °, -22.5 °].The gradient angle [alpha] obtained according to calculating formula (3), determine that the gradient angle [alpha] is located at
In the range of which gradient angle, and then determine gradient direction corresponding to pixel A.Using pixel A as starting point, along pixel
Point A gradient direction obtains the pixel of at least one pixel unit.
Determination method of the specific embodiment to image detection region provided by the invention is further described below.
Fig. 4 shows the schematic diagram of detection image according to an embodiment of the invention.Referring to Fig. 4, the detection image bag
Image corresponding to image corresponding to black material and white background is included.Black material is a square material, and heart district wherein
Domain offers a square through hole.First, using Blob algorithms, each pixel of the detection image shown in Fig. 4 is split
Processing, obtains the pixel in the pixel and white background picture in image corresponding to black material.Then, calculated using Blob
Method carries out piecemeal processing to the pixel in image corresponding to black material, due to each pixel in image corresponding to black material
The gray value of point is 0, then obtains one group of pixel.Profile using the outermost pixel in this group of pixel as black material
Corresponding pixel.Referring to Fig. 4, two profiles, i.e. the first profile and the second profile can obtain by this group of pixel.Assuming that the
One profile and the second profile include 2000 and 1000 points, each pixel and the second profile respectively corresponding to the first profile respectively
Gradient direction is calculated in corresponding each pixel.Then, along the gradient direction of each pixel, obtain on 5 pixel units
Pixel.So, will obtain respectively for 5 × 2000 and 5 × 1000 pixels of the first profile and the second profile, by 5 ×
First boundary image of 2000 pixel compositions, and the second boundary image by 5 × 1000 pixel compositions.First side
Boundary's image and the second boundary image are as defects detection image.In the embodiment of the present invention, it is preferred to use histogram analysis or
The methods of spot detection, carries out quality testing to image detection region, for example, open defect detects.
Based on same inventive concept, the invention provides a kind of determining device of image detection region.Fig. 5 shows basis
The structural representation of the determining device of the image detection region of one embodiment of the invention.Referring to Fig. 5, the device comprises at least:
First acquisition module 510, for from detection image corresponding to examined object, obtaining in image corresponding to examined object
Pixel;Processing module 520, for handling the pixel in image corresponding to examined object, obtain thing to be detected
Pixel corresponding at least one profile of body;Setup module 530, for being respectively at least one profile pair of examined object
Gradient direction corresponding to each pixel is calculated in each pixel answered;Second acquisition module 540, by along for based on each pixel
Obtained gradient direction, obtain the pixel of at least one pixel unit;Composite module 550, for by each pixel and edge
At least one pixel obtained for the gradient direction that each pixel is calculated is combined, and forms pixel combination zone,
And using pixel combination zone as image detection region.
In one embodiment of the present of invention, detection image is gray level image, and detection image includes examined object pair
The image and background image answered,
In one embodiment of the present of invention, the first acquisition module 510 is additionally operable to:Using Blob algorithms, to detection image
Each pixel carries out dividing processing, obtains the pixel in the pixel and background image in image corresponding to examined object.
In one embodiment of the present of invention, processing module 520 is additionally operable to:It is corresponding to examined object using Blob algorithms
Image in pixel carry out piecemeal processing, obtain multigroup pixel;Using the outermost pixel in each group pixel as treating
Pixel corresponding at least one profile of detection object.
In one embodiment of the present of invention, processing module 520 is additionally operable to:Calculate the outermost pixel in multigroup pixel
The area or girth in the region of formation;By the area in the region of the outermost pixel formation in multigroup pixel or girth and in advance
If contour area threshold value or default profile perimeter threshold are compared, comparison result is obtained;According to comparison result, determine to meet
At least one set of pixel of user's request;Using the outermost pixel at least one set of pixel for meeting user's request as treating
Pixel corresponding at least one profile of detection object.
Fig. 6 shows another structural representation of the determining device of image detection region according to an embodiment of the invention
Figure.Referring to Fig. 6, the device comprises at least:Memory 620 and processor 610, wherein, memory 620 stores executable instruction,
Executable instruction control processor 610 operated with perform any of the above described one image detection region determination method.
The present invention can be system, method and/or computer program product.Computer program product can include computer
Readable storage medium storing program for executing, containing for making processor realize the computer-readable program instructions of various aspects of the invention.
Computer-readable recording medium can keep and store to perform the tangible of the instruction that uses of equipment by instruction
Equipment.Computer-readable recording medium for example can be-- but be not limited to-- storage device electric, magnetic storage apparatus, optical storage
Equipment, electromagnetism storage device, semiconductor memory apparatus or above-mentioned any appropriate combination.Computer-readable recording medium
More specifically example (non exhaustive list) includes:Portable computer diskette, hard disk, random access memory (RAM), read-only deposit
It is reservoir (ROM), erasable programmable read only memory (EPROM or flash memory), static RAM (SRAM), portable
Compact disk read-only storage (CD-ROM), digital versatile disc (DVD), memory stick, floppy disk, mechanical coding equipment, for example thereon
It is stored with punch card or groove internal projection structure and the above-mentioned any appropriate combination of instruction.Calculating used herein above
Machine readable storage medium storing program for executing is not construed as instantaneous signal in itself, the electromagnetic wave of such as radio wave or other Free propagations, leads to
Cross the electromagnetic wave (for example, the light pulse for passing through fiber optic cables) of waveguide or the propagation of other transmission mediums or transmitted by electric wire
Electric signal.
Computer-readable program instructions as described herein can be downloaded to from computer-readable recording medium it is each calculate/
Processing equipment, or outer computer or outer is downloaded to by network, such as internet, LAN, wide area network and/or wireless network
Portion's storage device.Network can include copper transmission cable, optical fiber is transmitted, is wirelessly transferred, router, fire wall, interchanger, gateway
Computer and/or Edge Server.Adapter or network interface in each calculating/processing equipment receive from network to be counted
Calculation machine readable program instructions, and the computer-readable program instructions are forwarded, for the meter being stored in each calculating/processing equipment
In calculation machine readable storage medium storing program for executing.
For perform the computer program instructions that operate of the present invention can be assembly instruction, instruction set architecture (ISA) instruction,
Machine instruction, machine-dependent instructions, microcode, firmware instructions, condition setup data or with one or more programming languages
The source code or object code that any combination is write, programming language-such as Smalltalk of the programming language including object-oriented,
C++ etc., and conventional procedural programming languages-such as " C " language or similar programming language.Computer-readable program refers to
Order fully can on the user computer be performed, partly performed on the user computer, the software kit independent as one
Perform, part performs or completely on remote computer or server on the remote computer on the user computer for part
Perform.In the situation of remote computer is related to, remote computer can be by the network of any kind-include LAN
Or wide area network (WAN) (LAN)-subscriber computer is connected to, or, it may be connected to outer computer (such as utilize internet
Service provider passes through Internet connection).In certain embodiments, believe by using the state of computer-readable program instructions
Breath comes personalized customization electronic circuit, such as PLD, field programmable gate array (FPGA) or FPGA
Array (PLA), the electronic circuit can perform computer-readable program instructions, so as to realize various aspects of the invention.
Referring herein to method, apparatus (system) and computer program product according to embodiments of the present invention flow chart and/
Or block diagram describes various aspects of the invention.It should be appreciated that each square frame and flow chart of flow chart and/or block diagram and/
Or in block diagram each square frame combination, can be realized by computer-readable program instructions.
These computer-readable program instructions can be supplied to all-purpose computer, special-purpose computer or other programmable datas
The processor of processing unit, so as to produce a kind of machine so that these instructions are passing through computer or other programmable datas
During the computing device of processing unit, work(specified in one or more of implementation process figure and/or block diagram square frame is generated
The device of energy/action.These computer-readable program instructions can also be stored in a computer-readable storage medium, these refer to
Order causes computer, programmable data processing unit and/or other equipment to work in a specific way, so as to be stored with instruction
Computer-readable medium then includes a manufacture, and it is included in one or more of implementation process figure and/or block diagram square frame
The instruction of the various aspects of defined function/action.
Computer-readable program instructions can also be loaded into computer, other programmable data processing units or other
In equipment so that series of operation steps is performed on computer, other programmable data processing units or miscellaneous equipment, with production
Raw computer implemented process, so that performed on computer, other programmable data processing units or miscellaneous equipment
Instruct function/action specified in one or more of implementation process figure and/or block diagram square frame.
Flow chart and block diagram in accompanying drawing show system, method and the computer journey of multiple embodiments according to the present invention
Architectural framework in the cards, function and the operation of sequence product.At this point, each square frame in flow chart or block diagram can generation
One module of table, program segment or a part for instruction, module, program segment or a part for instruction include one or more be used in fact
The executable instruction of logic function as defined in existing.At some as in the realization replaced, the function of being marked in square frame can also
To occur different from the order marked in accompanying drawing.For example, two continuous square frames can essentially perform substantially in parallel, it
Can also perform in the opposite order sometimes, this is depending on involved function.It is also noted that block diagram and/or flow
The combination of each square frame and block diagram in figure and/or the square frame in flow chart, function or action as defined in performing can be used
Special hardware based system is realized, or can be realized with the combination of specialized hardware and computer instruction.For this
It is well known that, realized for art personnel by hardware mode, realized by software mode and pass through software and hardware
With reference to mode realize it is all of equal value.
It is described above various embodiments of the present invention, described above is exemplary, and non-exclusive, and
It is not limited to disclosed each embodiment.In the case of without departing from the scope and spirit of illustrated each embodiment, for this skill
Many modifications and changes will be apparent from for the those of ordinary skill in art field.The selection of term used herein, purport
Best explaining the principle of each embodiment, practical application or to the technological improvement in market, or make the art its
Its those of ordinary skill is understood that each embodiment disclosed herein.The scope of the present invention is defined by the appended claims.