CN104240243A - Adhered piglet automatic counting method based on ellipse fitting - Google Patents

Adhered piglet automatic counting method based on ellipse fitting Download PDF

Info

Publication number
CN104240243A
CN104240243A CN201410455253.8A CN201410455253A CN104240243A CN 104240243 A CN104240243 A CN 104240243A CN 201410455253 A CN201410455253 A CN 201410455253A CN 104240243 A CN104240243 A CN 104240243A
Authority
CN
China
Prior art keywords
piglet
oval
ellipse
concave point
image
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.)
Granted
Application number
CN201410455253.8A
Other languages
Chinese (zh)
Other versions
CN104240243B (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.)
Nanjing Agricultural University
Original Assignee
Nanjing Agricultural University
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 Nanjing Agricultural University filed Critical Nanjing Agricultural University
Priority to CN201410455253.8A priority Critical patent/CN104240243B/en
Publication of CN104240243A publication Critical patent/CN104240243A/en
Application granted granted Critical
Publication of CN104240243B publication Critical patent/CN104240243B/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Image Analysis (AREA)
  • Image Processing (AREA)

Abstract

The invention discloses an adhered piglet automatic counting method based on ellipse fitting, and belongs to the field of image processing. The problem of adhered piglet automatic counting is solved. The method comprises the implementation steps that (1) an adhered piglet gray level image is opened and preprocessed; (2) the edges of the communicated areas of the piglet image are extracted, and ellipse fitting is executed; (3) the communicated areas which are not processed are extracted in an area descending order, if ellipses corresponding to the communicated areas which are not processed meet the parameter requirement of a single piglet image fitting ellipse, the communicated areas are marked to be processed, otherwise, the contour line of the communicated areas is segmented based on concave points, ellipse fitting is carried out on each segment, a plurality of ellipses belonging to the same piglet are combined according to a proposed combination rule, and the communicated areas are marked to be processed after combination is finished; (4) if the communicated areas which are not processed still exist, the step (3) is executed, and otherwise, counting is finished, and the number of the ellipses is the number of the piglets. According to the method, the number of the piglets in the adhered piglet gray level image can be recognized automatically and accurately, and the ellipses can reflect the rest behavior characteristics of the piglets.

Description

A kind of adhesion piglet automatic counting method based on ellipse fitting
Technical field
The invention belongs to image procossing and technical field of machine vision.Be specifically related to the adhesion piglet gray level image segmentation based on ellipse fitting and piglet automatic counting method.
Background technology
Healthy nursery-age pig speed of weight increment has stable pattern, and the sudden change of weightening finish pattern is the important indicator that nursery-age pig health anomalies judges.In addition, the speed of nursery-age pig speed of weight increment is also the important Judging index of sow production performance, milk performance quality, is the important evidence of the preferred replacement gilt of breeding enterprise.Therefore, nursery-age pig speed of weight increment is the important indicator that aquaculture is paid close attention to.But up to the present, China's livestock breeding industry remains the mode by manually weighing in piglet birth and wean two time points, record weight gain of piglets speed.Due to the frequent activities of piglet on weighing-appliance, weighing results and the weight gain of piglets speed data that obtains thus out of true.
Current radio communication, sensor technology are used widely at agricultural production.Arrangement LOAD CELLS and cmos image sensor in piglet insulation box, under the support of wireless communication technology, can the general assembly (TW) of rest piglet and piglet rest image in remote collection insulation can, utilize image processing techniques automatically to identify and piglet quantity in piglet rest image can realize the target of the equal weight automatic monitoring of piglet nest in insulation can in conjunction with piglet general assembly (TW).
Enter the piglet quantity of having a rest in insulation can not fix, therefore, the piglet Auto-counting based on piglet image is the basis realizing nursery-age pig nest counterpoise monitoring objective at every turn.But, there are two features by the piglet rest image of transmission of radio links: one is gray level image, and greyscale image data amount is less, be suitable for transmitting on the wireless communication link of low bandwidth; Two is there is adhesion phenomenon between piglet, and piglet rest attitude in insulation can is various, may exist each other and partly overlap, image show as the adhesion between piglet.The segmentation of adhesion piglet gray level image and Auto-counting are the difficult point places realizing the equal weight automatic monitoring of nursery-age pig nest.Research at present for adhesion object segmentation counting is divided into two classes: a class proposes Iamge Segmentation and adhesion object count method for having regular shape feature (as positive circle, rectangle etc.) adhesion object, and Equations of The Second Kind is the dividing method proposing adhesion subject image based on color information.But piglet gray level image does not possess abundant color information and piglet body characteristics is also irregular, apply existing adhesion subject image automatic Segmentation piglet image, the accurate counting of adhesion piglet can not be realized, and then will the piglet nest counterpoise monitoring result of mistake be produced.
Summary of the invention
(1) technical matters that will solve
The technical problem to be solved in the present invention how to split the adhesion piglet gray level image in the equal weight automatic monitoring application of piglet nest and to complete piglet Auto-counting accurately.
(2) technical scheme of the present invention is
For solving the problem, the invention provides a kind of adhesion piglet automatic counting method based on ellipse fitting, it comprises the following steps (S1 to S7):
S1, read in and open the adhesion piglet gray level image that size is P (320 pixel × 240 pixel);
S2, perform gaussian filtering and binary conversion treatment for this adhesion piglet gray level image;
S3, for after binary conversion treatment piglet image perform Morphological scale-space;
S4, perform Canny edge extraction operation for the piglet image after Morphological scale-space;
S5, perform the ellipse fitting based on least square method for each connected region edge extracted;
S6, extract connected region successively by area order from big to small, if fitted ellipse corresponding to the current pending connected region extracted meets single piglet image fitted ellipse parameter request, be then processed by this connected component labeling, otherwise, extract this connected region outline line and perform following operation (S6a to S6f):
S6a, outline line smooth operation;
S6b, extract concave point for the outline line after level and smooth;
S6c, the concave point obtained for step S6b extract and represent concave point;
S6d, based on representing concave point for the outline line segmentation after level and smooth in step S6a;
S6e, each outline line segmentation obtained for step S6d perform the ellipse fitting based on least square method;
S6f, each ellipse obtained for step S6e, judge oval merging condition according to the order of rule 1 to rule 4 and complete corresponding oval union operation, after completing a subelliptic merging according to a certain rule, still merging condition is judged according to the order of rule 1, rule 2, rule 3, rule 4, until all ellipses corresponding to current connected region all meet when single piglet image fitted ellipse parameter area requires terminate oval union operation, be processed by current connected component labeling:
Rule 1, extract oval i by area descending order, if oval i and other oval j area Duplication exceed threshold value over_com_th, then merge outline line segmentation corresponding to oval i, j and with merging after outline line segmentation fitted ellipse again;
If rule 2 oval i, j meet following 4 conditions (condition 6f-2-a is to condition 6f-2-d), then merge these two oval corresponding outline line segmentations and by the outline line segmentation fitted ellipse again after merging:
The minor axis length Mi_i of condition 6f-2-a: oval i and the minor axis length Mi_j of oval j is all less than 0.5 times of corresponding age in days section single piglet image fitted ellipse minor axis length minimum M i_min;
The orientation angle θ of condition 6f-2-b: oval i iwith the orientation angle θ of oval j jthe absolute value of difference be less than threshold value diff_ θ _ th;
The central point of condition 6f-2-c: oval i is to the vertical range d (ellipse of the major axis place straight line of oval j i_ center, line_ma j) be greater than 0.8 times of corresponding age in days section single piglet image fitted ellipse minor axis length minimum M i_min and be less than corresponding age in days section single piglet image fitted ellipse minor axis length maximal value Mi_max;
The central point of condition 6f-2-d: oval i is to the vertical range d (ellipse of oval j minor axis place straight line i_ center, line_mi j) be less than 0.5 times of corresponding age in days section single piglet image fitted ellipse long axis length maximal value Ma_max;
If rule 3 oval i, j meet following 3 conditions (condition 6f-3-a is to condition 6f-3-c), then merge outline line segmentation corresponding to oval i, j and with merging after outline line segmentation fitted ellipse again:
The minor axis length Mi_i of condition 6f-3-a: oval i and the minor axis length Mi_j of oval j is all less than corresponding age in days section single piglet image fitted ellipse minor axis length minimum M i_min;
Condition 6f-3-b: the outline line segmentation S that oval i, j are corresponding i, S jnon-conterminous;
Condition 6f-3-c: the outline line segmentation S that oval i, j are corresponding i, S jadjacent outline line segmentation fitted ellipse and ellipse meets the requirement of single piglet image fitted ellipse parameter area all;
Rule 4, extract oval i by area descending order, if the region of oval i long axis direction line process exists other oval j to be combined, and the central point of oval i is to the vertical range d (ellipse of oval j minor axis place straight line i_ center, line_mi j) be less than 0.5 times of corresponding age in days section single piglet image fitted ellipse long axis length maximal value Ma_max, then merge outline line segmentation corresponding to oval i, j and by the outline line segmentation fitted ellipse again after merging;
S7, judge whether that all connected regions are disposed, if still have connected region to need segmentation, extract the corresponding outline line of the maximum connected region of untreated area to perform from S6a, if connected region is all disposed, then adhesion piglet Auto-counting completes, oval quantity is the piglet quantity in image, and each ellipse can reflect the rest behavioural characteristic such as the sleeping direction of lying prone of corresponding piglet, the tightness degree of piglet.
Preferably, single piglet image fitted ellipse parameter area in step S6 is by transverse length maximal value (Ma_max), long axis length minimum value (Ma_min), minor axis length maximal value (Mi_max), minor axis length minimum value (Mi_min), short long axis length is determined than minimum value (MMAR_max) than maximal value (MMAR_max) and short long axis length, these six parameters are determined according to following three steps: (i) reads in 1 ~ 3 age that size is P, 4 ~ 6 ages in days, 7 ~ 9 ages in days, 10 ~ 12 ages in days, 13 ~ 15 ages in days, 16 ~ 18 ages in days, each ten width of 19 ~ 21 age in days single piglet gray level image, P=320 pixel × 240 pixel, (ii) open each piglet image perform gaussian filtering, binaryzation, Morphological scale-space (adopt radius be 5 disc-shaped structure unit the piglet image after binaryzation is performed once open operation and a closed operation), Canny edge extracting, to operate based on the ellipse fitting of least square method, extract transverse length value and minor axis length value, calculate the major axis of corresponding fitted ellipse, the average of minor axis length, be designated as Ma_aver and Mi_aver respectively, (iii) formula (1) is utilized to determine Ma_max, Ma_min, Mi_max, Mi_min, MMAR_max and MMAR_max of each age in days section single piglet image fitted ellipse to formula (6):
Ma_min=Ma_aver×(1-0.25) (1)
Ma_max=Ma_aver×(1+0.25) (2)
Mi_min=Mi_aver×(1-0.25) (3)
Mi_max=Mi_aver×(1+0.25) (4)
MMAR_max=Mi_min/Ma_max (5)
MMAR_min=Mi_max/Ma_min (6)
Preferably, Morphological scale-space in step S3 adopt radius be 5 disc-shaped structure unit the piglet image after binaryzation performed once open operation and a closed operation.
Preferably, the method that in step S6a, outline line is level and smooth is approximate polygon method, the method that in step S6b, concave point extracts is outline line chain code difference method, when utilizing chain code difference method to extract concave point, pixel on outline line is all according to counterclockwise numbering, and Base Serial Number 1 gives the pixel (if having multiple, therefrom select pixel near image coboundary) of current outline line near image left edge.
Preferably, there is the feature of local clustering in the concave point extracted in step S6b, in step S6c, point two class situations represent concave point for the concave point extraction of local clustering: first kind clustering concave point, concave point in such clustering concave point is continuous, select the point representatively concave point of chain code difference maximum absolute value, if the candidate that there is multiple chain code difference maximum absolute value represents concave point, then therefrom select near clustering concave point center and number less representatively concave point; Equations of The Second Kind clustering concave point, concave point in such clustering concave point is discontinuous, there is non-concave point pixel between concave point, and between concave point, non-concave point pixel quantity is less than threshold value cTh, cTh is set to 10, and the system of selection of representative concave point and the first kind clustering concave point of Equations of The Second Kind clustering concave point select the method representing concave point identical.
Preferably, in step S6f, the ellipse area Duplication threshold value over_com_th of rule 1 is set to 40%, and ellipse area Duplication computing formula is wherein, area (ellipse_i^ellipse_j) is the overlapping region area of oval i and oval j, area_i, area_j are respectively the area of oval i, j, and min (area_i, area_j) is the less ellipse area of area in oval i and oval j.
Preferably, in step S6f, the threshold value diff_ θ _ th of rule 2 is set to 15 degree.
(3) beneficial effect
Technique scheme tool of the present invention has the following advantages: catch piglet trunk body to be similar to oval feature, first ellipse fitting operation is performed for a large amount of different days section lactation single piglet image, extract corresponding elliptic parameter scope, then for the concave point on many piglets image zooming-out outline line and based on concave point to outline line segmentation, all perform ellipse fitting for each outline line segmentation, distinguish the ellipse needing to merge further and the ellipse that can represent single piglet according to single piglet image fitted ellipse parameter area.For the ellipse needing to merge further, propose four and merge rule, the multiple ellipses belonging to same piglet are merged, until all ellipses all meet the requirement of single piglet image fitted ellipse parameter area, now, oval quantity is the piglet quantity in image, and each ellipse can reflect the rest behavioural characteristic such as the sleeping direction of lying prone of corresponding piglet, the tightness degree of piglet.This invention institute extracting method can identify the piglet quantity in adhesion piglet gray level image exactly automatically, provides basis for design realizes nursery-age pig nest counterpoise automatic monitoring system.
Accompanying drawing explanation
Fig. 1 is nursery-age pig nest counterpoise automatic monitoring system structural drawing of the present invention.
Fig. 2 is cmos image sensor node structure figure of the present invention.
Fig. 3 is LOAD CELLS node structure figure of the present invention.
Fig. 4 is gateway node structural drawing of the present invention.
Fig. 5 is adhesion piglet Auto-counting process flow diagram of the present invention.
Fig. 6 is pending adhesion piglet image (only there to be the piglet image of a connected region that the present invention is described, but not being used for limiting the scope of the invention).
Fig. 7 is that adhesion piglet outline line extracts result figure.
Fig. 8 is adhesion piglet outline line sharpening result figure.
Fig. 9 is that adhesion piglet outline line concave point extracts result figure (in figure, asterisk point is the concave point extracted).
Figure 10 is that adhesion piglet outline line represents concave point extraction result figure.
Figure 11 is the result figure performing ellipse fitting for each outline line segmentation.
Figure 12 merges oval process flow diagram according to four rules (in figure, flag2, flag3, flag4 is all initialized as 0, and the ellipse meeting regular 2 conditions if having merges, then flag2 is set to 1; The ellipse meeting regular 3 conditions if having merges, then flag3 is set to 1, and the ellipse meeting regular 4 conditions if having merges, then flag4 is set to 1).
Figure 13 is by Figure 11 No. 3 ellipse, No. 4 oval result figure merged according to rule 1.
Figure 14 is by Figure 13 No. 2 ellipse, No. 3 oval result figure merged according to rule 1.
Figure 15 is by Figure 14 No. 1 ellipse, No. 3 oval result figure merged according to rule 2.
Figure 16 is by Figure 15 No. 1 ellipse, No. 6 oval result figure merged according to rule 1.
Figure 17 is by Figure 16 No. 3 ellipse, No. 5 oval result figure merged according to rule 3.
Figure 18 is that single piglet image fitted ellipse parameter area of the present invention extracts process flow diagram.
Embodiment
Below in conjunction with drawings and Examples, the present invention is further illustrated.
As shown in Figure 1, a kind of nursery-age pig nest counterpoise automatic monitoring system.This system by being deployed in the cmos image sensor node on piglet insulation box top, the LOAD CELLS node be deployed under piglet heat-insulation box plate, cloth be deployed on Farrowing give up in gateway node and piglet nest counterpoise automatic monitoring system server form.Each piglet insulation box installs a cmos image sensor node, a LOAD CELLS node, each Farrowing house installation gateway node.
As shown in Figure 2, each cmos image sensor node of the present invention includes cmos image sensor (model can be: OV7620), FIFO cache chip (model can be: AL422B), imageing sensor node STM32 microcontroller, sensor node end ZigBee module (model can be: TI/CC1101) and power module.Described cmos image sensor is as the image of rest piglet in the signal input collection insulation can be monitored of imageing sensor node, the image signal output end of imageing sensor is connected with the signal input part of FIFO cache chip, the signal output part of FIFO cache chip is connected with the signal input part of imageing sensor node STM32 microcontroller, the signal output part of imageing sensor node STM32 microcontroller is connected with the signal input part of sensor node end ZigBee module, the ZigBee module signal input part wireless connections of sensor node end ZigBee module signal output part and gateway node.
The ZigBee module of cmos image sensor node of the present invention is connected by serial ports with between STM32 microcontroller, image acquisition STM32 microcontroller is connected by serial ports with FIFO cache chip, and FIFO cache chip is connected with cmos image sensor by its I/O mouth.
As shown in Figure 3, each LOAD CELLS node of the present invention includes LOAD CELLS, AD conversion module, LOAD CELLS node STM32 microcontroller and sensor node end ZigBee module, described LOAD CELLS gathers the general assembly (TW) of rest piglet in insulation can be monitored as the input of LOAD CELLS node signal, the signal output part of LOAD CELLS is connected with the signal input part of AD conversion module, the signal output part of AD conversion module is connected with the signal input part of LOAD CELLS node STM32 microcontroller, the signal output part of LOAD CELLS node STM32 microcontroller is connected with the signal input part of sensor node end ZigBee module, the ZigBee module signal input part wireless connections of sensor node end ZigBee module signal output part and gateway node.
The output signal of the LOAD CELLS of LOAD CELLS node of the present invention is connected to AD conversion module by the analog differential input channel of AD conversion module, AD conversion module is connected by serial ports with LOAD CELLS node STM32 microcontroller, and the ZigBee module of LOAD CELLS node is connected by serial ports with between LOAD CELLS node STM32 microcontroller.
As shown in Figure 4, gateway node of the present invention comprises gateway node STM32 microcontroller, gateway node end ZigBee module (model can be: TI/CC1101), RJ45 network interface module, ethernet controller (model can be: ENC28J60) and power module.Described gateway node ZigBee module is initiated to set up ZigBee-network, manage adding and exiting of all cmos image sensor nodes and LOAD CELLS node, keep wireless connections with the ZigBee module of all cmos image sensor nodes and LOAD CELLS node in single-hop mode; As the input of gateway node signal, gateway node ZigBee module signal input part collects the image information of imageing sensor node ZigBee module transmission and the weighing information of LOAD CELLS node ZigBee module transmission by ZigBee wireless communication protocol; Gateway node ZigBee module signal output part is connected with gateway node STM32 micro controller module signal input part, gateway node STM32 microcontroller signal output part is connected with RJ45 signal input part by ethernet controller, and RJ45 signal output part is connected with piglet nest counterpoise monitoring system server by LAN (Local Area Network).
Gateway node ZigBee module of the present invention is connected with gateway node STM32 microcontroller by serial ports, RX, TX of RJ45 network interface module and the exterior I of ethernet controller/O pin TPIN, TPOUT physical connection, ethernet controller is connected with gateway node STM32 microcontroller by SPI interface.
As shown in Figure 5, a kind of adhesion piglet automatic counting method based on ellipse fitting of the present invention, comprises the following steps:
S1, read in and open the adhesion piglet gray level image that size is P (320 pixel × 240 pixel), as shown in Figure 6;
S2, perform gaussian filtering and binary conversion treatment for this adhesion piglet gray level image;
S3, for after binary conversion treatment piglet image perform Morphological scale-space;
S4, perform Canny edge extraction operation for the piglet image after Morphological scale-space;
S5, perform the ellipse fitting based on least square method for each connected region edge extracted;
S6, extract connected region successively by area order from big to small, if fitted ellipse corresponding to the current pending connected region extracted meets single piglet image fitted ellipse parameter request, be then processed by this connected component labeling, otherwise, extract this connected region outline line (as shown in Figure 7) and perform following operation (S6a to S6f):
S6a, outline line smooth operation (performing the result of smooth operation as shown in Figure 8 for Fig. 7 outline line);
S6b, extract concave point (extracting the result of concave point as shown in Figure 9 for Fig. 8 outline line) for the outline line after level and smooth;
S6c, the concave point obtained for step S6b extract represent concave point (for Fig. 9 concave point extract represent concave point result as shown in Figure 10);
S6d, based on representing concave point for the outline line segmentation after level and smooth in step S6a;
S6e, each outline line segmentation obtained for step S6d perform the ellipse fitting based on least square method, and result as shown in figure 11;
S6f, as shown in figure 12, for each ellipse that step S6e obtains, judge oval merging condition according to the order of rule 1 to rule 4 and complete corresponding oval union operation, after completing a subelliptic merging according to a certain rule, still merging condition is judged according to the order of rule 1, rule 2, rule 3, rule 4, until all ellipses corresponding to current connected region all meet when single piglet image fitted ellipse parameter area requires terminate oval union operation, be processed by current connected component labeling:
Rule 1, extract oval i by area descending order, if oval i and other oval j area Duplication exceed threshold value over_com_th, then merge outline line segmentation corresponding to oval i, j and with the outline line segmentation after merging again fitted ellipse (as in Figure 11 No. 3, No. 4 ellipses, No. 2 in Figure 13, No. 3 ellipses, No. 1 in Figure 15, No. 6 ellipses);
If rule 2 oval i, j meet following 4 conditions (condition 6f-2-a is to condition 6f-2-d), then merge these two oval corresponding outline line segmentations and with the outline line segmentation after merging again fitted ellipse (as in Figure 14 No. 1, No. 3 ellipses);
The minor axis length Mi_i of condition 6f-2-a: oval i and the minor axis length Mi_j of oval j is all less than 0.5 times of corresponding age in days section single piglet image fitted ellipse minor axis length minimum M i_min;
The orientation angle θ of condition 6f-2-b: oval i iwith the orientation angle θ of oval j jthe absolute value of difference be less than threshold value diff_ θ _ th;
The central point of condition 6f-2-c: oval i is to the vertical range d (ellipse of the major axis place straight line of oval j i_ center, line_ma j) be greater than 0.8 times of corresponding age in days section single piglet image fitted ellipse minor axis length minimum M i_min and be less than corresponding age in days section single piglet image fitted ellipse minor axis length maximal value Mi_max;
The central point of condition 6f-2-d: oval i is to the vertical range d (ellipse of oval j minor axis place straight line i_ center, line_mi j) be less than 0.5 times of corresponding age in days section single piglet image fitted ellipse long axis length maximal value Ma_max;
If rule 3 oval i, j meet following 3 conditions (condition 6f-3-a is to condition 6f-3-c), then merge outline line segmentation corresponding to oval i, j and with the outline line segmentation after merging again fitted ellipse (as in Figure 16 No. 3, No. 5 ellipses);
The minor axis length Mi_i of condition 6f-3-a: oval i and the minor axis length Mi_j of oval j is all less than corresponding age in days section single piglet image fitted ellipse minor axis length minimum M i_min;
Condition 6f-3-b: the outline line segmentation S that oval i, j are corresponding i, S jnon-conterminous;
Condition 6f-3-c: the outline line segmentation S that oval i, j are corresponding i, S jadjacent outline line segmentation fitted ellipse and ellipse meets the requirement of single piglet image fitted ellipse parameter area all;
Rule 4, extract oval i by area descending order, if the region of oval i long axis direction line process exists other oval j to be combined, and the central point of oval i is to the vertical range d (ellipse of oval j minor axis place straight line i_ center, line_mi j) be less than 0.5 times of corresponding age in days section single piglet image fitted ellipse long axis length maximal value Ma_max, then merge outline line segmentation corresponding to oval i, j and by the outline line segmentation fitted ellipse again after merging;
S7, judge whether that all connected regions are disposed, if still have connected region to need segmentation, extract the corresponding outline line of the maximum connected region of untreated area to perform from S6a, if connected region is all disposed, then adhesion piglet Auto-counting completes, oval quantity is the piglet quantity in image, and each ellipse can reflect the rest behavioural characteristic (as shown in figure 17) such as the sleeping direction of lying prone of corresponding piglet, the tightness degree of piglet.
Morphological scale-space in the step S3 of a kind of adhesion piglet automatic counting method based on ellipse fitting of the present invention adopt radius be 5 disc-shaped structure unit the piglet image after binaryzation performed once open operation and a closed operation.
Single piglet image fitted ellipse parameter area in the step S6 of a kind of adhesion piglet automatic counting method based on ellipse fitting of the present invention is determined than minimum value (MMAR_max) than maximal value (MMAR_max) and short long axis length by transverse length maximal value (Ma_max), long axis length minimum value (Ma_min), minor axis length maximal value (Mi_max), minor axis length minimum value (Mi_min), short long axis length, as shown in figure 18, these 6 parameters are determined according to following 3 steps:
I () reads in 1 ~ 3 age in days, 4 ~ 6 ages in days, 7 ~ 9 ages in days, 10 ~ 12 ages in days, 13 ~ 15 ages in days, 16 ~ 18 ages in days, each ten width of 19 ~ 21 age in days single piglet gray level image that size is P, P=320 pixel × 240 pixel;
(ii) open each piglet image perform gaussian filtering, binaryzation, Morphological scale-space (adopt radius be 5 disc-shaped structure unit the piglet image after binaryzation is performed once open operation and a closed operation), Canny edge extracting, to operate based on the ellipse fitting of least square method, extract transverse length value and minor axis length value, calculate the major axis of corresponding fitted ellipse, the average of minor axis length, be designated as Ma_aver and Mi_aver respectively;
(iii) formula (1) is utilized to determine Ma_max, Ma_min, Mi_max, Mi_min, MMAR_max and MMAR_max of each age in days section single piglet image fitted ellipse to formula (6):
Ma_min=Ma_aver×(1-0.25) (1)
Ma_max=Ma_aver×(1+0.25) (2)
Mi_min=Mi_aver×(1-0.25) (3)
Mi_max=Mi_aver×(1+0.25) (4)
MMAR_max=Mi_min/Ma_max (5)
MMAR_min=Mi_max/Ma_min (6)
The method that in the step S6a of a kind of adhesion piglet automatic counting method based on ellipse fitting of the present invention, outline line is level and smooth is approximate polygon method, the method that in step S6b, concave point extracts is outline line chain code difference method, when utilizing chain code difference method to extract concave point, pixel on outline line is all according to counterclockwise numbering, and Base Serial Number 1 gives the pixel of current outline line near image left edge (if having multiple, therefrom select the pixel near image coboundary), Fig. 7 is level and smooth front outline line, Fig. 8 be level and smooth after outline line, perform concave point for the outline line in Fig. 8 and extract the result after operation as shown in Figure 9.
There is the feature of local clustering in the concave point extracted in the step S6b of a kind of adhesion piglet automatic counting method based on ellipse fitting of the present invention, as shown in Figure 9.
In the step S6c of a kind of adhesion piglet automatic counting method based on ellipse fitting of the present invention, point two class situations represent concave point for the concave point extraction of local clustering:
First kind clustering concave point, concave point in such clustering concave point is continuous, as the clustering concave point in thick lines Blocked portion in Fig. 9, for first kind clustering concave point, select the point representatively concave point of chain code difference maximum absolute value, if the candidate that there is multiple chain code difference maximum absolute value represents concave point, then therefrom select near clustering concave point center and number less representatively concave point;
Equations of The Second Kind clustering concave point, concave point in such clustering concave point is discontinuous, non-concave point pixel is there is between concave point, and non-concave point pixel quantity is less than threshold value cTh between concave point, cTh is set to 10, as the clustering concave point in hachure Blocked portion in Fig. 9, the system of selection of representative concave point and the first kind clustering concave point of Equations of The Second Kind clustering concave point select the method representing concave point identical.
Extract operation to Fig. 9 Executive Agent concave point and perform outline line segmentation based on the representative concave point extracted, result as shown in Figure 10.
The ellipse of the step S6f of a kind of adhesion piglet automatic counting method based on ellipse fitting of the present invention merges regular 1 ellipse area Duplication threshold value over_com_th and is set to 40%, and ellipse area Duplication computing formula is wherein, area (ellipse_i^ellipse_j) is the overlapping region area of oval i and oval j, area_i, area_j are respectively the area of oval i, j, and min (area_i, area_j) is the less ellipse area of area in oval i and oval j.
The threshold value of the ellipse merging rule 2 of the step S6f of a kind of adhesion piglet automatic counting method based on ellipse fitting of the present invention sets diff_ θ _ th as 15 degree.

Claims (7)

1., based on an adhesion piglet automatic counting method for ellipse fitting, it is characterized in that it comprises following 7 steps (S1 to S7):
S1, read in and open the adhesion piglet gray level image that size is P (320 pixel × 240 pixel);
S2, perform gaussian filtering and binary conversion treatment for this adhesion piglet gray level image;
S3, for after binary conversion treatment piglet image perform Morphological scale-space;
S4, perform Canny edge extraction operation for the piglet image after Morphological scale-space;
S5, perform the ellipse fitting based on least square method for each connected region edge extracted;
S6, extract connected region successively by area order from big to small, if fitted ellipse corresponding to the current pending connected region extracted meets single piglet image fitted ellipse parameter request, be then processed by this connected component labeling, otherwise, extract this connected region outline line and perform following operation (S6a to S6f):
S6a, outline line smooth operation;
S6b, extract concave point for the outline line after level and smooth;
S6c, the concave point obtained for step S6b extract and represent concave point;
S6d, based on representing concave point for the outline line segmentation after level and smooth in step S6a;
S6e, each outline line segmentation obtained for step S6d perform the ellipse fitting based on least square method;
S6f, each ellipse obtained for step S6e, judge oval merging condition according to the order of rule 1 to rule 4 and complete corresponding oval union operation, after completing a subelliptic merging according to a certain rule, still judge merging condition according to the order of rule 1, rule 2, rule 3, rule 4 and complete corresponding oval union operation, until all ellipses corresponding to current connected region all meet single piglet image fitted ellipse parameter area when requiring, terminating oval union operation, is processed by current connected component labeling:
Rule 1, extract oval i by area descending order, if oval i and other oval j area Duplication exceed threshold value over_com_th, then merge outline line segmentation corresponding to oval i, j and with merging after outline line segmentation fitted ellipse again;
If rule 2 oval i, j meet following four conditions (condition 6f-2-a is to condition 6f-2-d), then merge these two oval corresponding outline line segmentations and by the outline line segmentation fitted ellipse again after merging:
The minor axis length Mi_i of condition 6f-2-a: oval i and the minor axis length Mi_j of oval j is all less than 0.5 times of corresponding age in days section single piglet image fitted ellipse minor axis length minimum M i_min;
The orientation angle θ of condition 6f-2-b: condition 6f-2-b: oval i iwith the orientation angle θ of oval j jthe absolute value of difference be less than threshold value diff_ θ _ th;
The central point of condition 6f-2-c: oval i is to the vertical range d (ellipse of the major axis place straight line of oval j i_ center, line_ma j) be greater than 0.8 times of corresponding age in days section single piglet image fitted ellipse minor axis length minimum M i_min and be less than corresponding age in days section single piglet image fitted ellipse minor axis length maximal value Mi_max;
The central point of condition 6f-2-d: oval i is to the vertical range d (ellipse of oval j minor axis place straight line i_ center, line_mi j) be less than 0.5 times of corresponding age in days section single piglet image fitted ellipse long axis length maximal value Ma_max;
If rule 3 oval i, j meet following 3 conditions (condition 6f-3-a is to condition 6f-3-c), then merge outline line segmentation corresponding to oval i, j and with merging after outline line segmentation fitted ellipse again:
The minor axis length Mi_i of condition 6f-3-a: oval i and the minor axis length Mi_j of oval j is all less than corresponding age in days section single piglet image fitted ellipse minor axis length minimum M i_min;
Condition 6f-3-b: the outline line segmentation S that oval i, j are corresponding i, S jnon-conterminous;
Condition 6f-3-c: the outline line segmentation S that oval i, j are corresponding i, S jadjacent outline line segmentation fitted ellipse and ellipse meets the requirement of single piglet image fitted ellipse parameter area all;
Rule 4, extract oval i by area descending order, if the region of oval i long axis direction line process exists other oval j to be combined, and the central point of oval i is to the vertical range d (ellipse of oval j minor axis place straight line i_ center, line_mi j) be less than 0.5 times of corresponding age in days section single piglet image fitted ellipse long axis length maximal value Ma_max, then merge outline line segmentation corresponding to oval i, j and by the outline line segmentation fitted ellipse again after merging;
S7, judge whether that all connected regions are disposed, if still have connected region to need segmentation, extract the corresponding outline line of the maximum connected region of untreated area to perform from S6a, if connected region is all disposed, then adhesion piglet Auto-counting completes, oval quantity is the piglet quantity in image, and each ellipse can reflect the rest behavioural characteristic such as the sleeping direction of lying prone of corresponding piglet, the tightness degree of piglet.
2. a kind of adhesion piglet automatic counting method based on ellipse fitting according to claim 1, it is characterized in that single piglet image fitted ellipse parameter area in step S6 is determined than minimum value (MMAR_max) than maximal value (MMAR_max) and short long axis length by transverse length maximal value (Ma_max), long axis length minimum value (Ma_min), minor axis length maximal value (Mi_max), minor axis length minimum value (Mi_min), short long axis length, these six parameters are determined according to following three steps:
I () reads in 1 ~ 3 age in days, 4 ~ 6 ages in days, 7 ~ 9 ages in days, 10 ~ 12 ages in days, 13 ~ 15 ages in days, 16 ~ 18 ages in days, each ten width of 19 ~ 21 age in days single piglet gray level image that size is P, P=320 pixel × 240 pixel;
(ii) open each piglet image perform gaussian filtering, binaryzation, Morphological scale-space (adopt radius be 5 disc-shaped structure unit the piglet image after binaryzation is performed once open operation and a closed operation), Canny edge extracting, to operate based on the ellipse fitting of least square method, extract transverse length value and minor axis length value, calculate the major axis of corresponding fitted ellipse, the average of minor axis length, be designated as Ma_aver and Mi_aver respectively;
(iii) formula (1) is utilized to determine Ma_max, Ma_min, Mi_max, Mi_min, MMAR_max and MMAR_max of each age in days section single piglet image fitted ellipse to formula (6):
Ma_min=Ma_aver×(1-0.25) (1)
Ma_max=Ma_aver×(1+0.25) (2)
Mi_min=Mi_aver×(1-0.25) (3)
Mi_max=Mi_aver×(1+0.25) (4)
MMAR_max=Mi_min/Ma_max (5)
MMAR_min=Mi_max/Ma_min (6) 。
3. a kind of adhesion piglet automatic counting method based on ellipse fitting according to claim 1, it is characterized in that Morphological scale-space in step S3 adopt radius be 5 disc-shaped structure unit the piglet image after binaryzation performed once open operation and a closed operation.
4. a kind of adhesion piglet automatic counting method based on ellipse fitting according to claim 1, it is characterized in that the method that in step S6a, outline line is level and smooth is approximate polygon method, the method that in step S6b, concave point extracts is outline line chain code difference method, when utilizing chain code difference method to extract concave point, pixel on outline line is all according to counterclockwise numbering, and Base Serial Number 1 gives the pixel (if having multiple, therefrom select pixel near image coboundary) of current outline line near image left edge.
5. a kind of adhesion piglet automatic counting method based on ellipse fitting according to claim 1, it is characterized in that the concave point extracted in step S6b exists the feature of local clustering, in step S6c, point two class situations represent concave point for the concave point extraction of local clustering: first kind clustering concave point, concave point in such clustering concave point is continuous, select the point representatively concave point of chain code difference maximum absolute value, if the candidate that there is multiple chain code difference maximum absolute value represents concave point, then therefrom select near clustering concave point center and number less representatively concave point; Equations of The Second Kind clustering concave point, concave point in such clustering concave point is discontinuous, there is non-concave point pixel between concave point, and between concave point, non-concave point pixel quantity is less than threshold value cTh, cTh is set to 10, and the system of selection of representative concave point and the first kind clustering concave point of Equations of The Second Kind clustering concave point select the method representing concave point identical.
6. a kind of adhesion piglet automatic counting method based on ellipse fitting according to claim 1, it is characterized in that the ellipse area Duplication threshold value over_com_th of rule 1 in step S6f is set to 40%, ellipse area Duplication computing formula is wherein, area (ellipse_i^ellipse_j) is the overlapping region area of oval i and oval j, area_i, area_j are respectively the area of oval i, j, and min (area_i, area_j) is the less ellipse area of area in oval i and oval j.
7. a kind of adhesion piglet automatic counting method based on ellipse fitting according to claim 1, is characterized in that the threshold value diff_ θ _ th of rule 2 in step S6f is set to 15 degree.
CN201410455253.8A 2014-09-05 2014-09-05 Adhered piglet automatic counting method based on ellipse fitting Expired - Fee Related CN104240243B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201410455253.8A CN104240243B (en) 2014-09-05 2014-09-05 Adhered piglet automatic counting method based on ellipse fitting

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201410455253.8A CN104240243B (en) 2014-09-05 2014-09-05 Adhered piglet automatic counting method based on ellipse fitting

Publications (2)

Publication Number Publication Date
CN104240243A true CN104240243A (en) 2014-12-24
CN104240243B CN104240243B (en) 2017-05-10

Family

ID=52228249

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201410455253.8A Expired - Fee Related CN104240243B (en) 2014-09-05 2014-09-05 Adhered piglet automatic counting method based on ellipse fitting

Country Status (1)

Country Link
CN (1) CN104240243B (en)

Cited By (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106203238A (en) * 2015-05-05 2016-12-07 北京建筑大学 Well lid component identification method in mobile mapping system streetscape image
CN106203456A (en) * 2016-07-20 2016-12-07 西安科技大学 Coal dust Algorithm for Overlapping Granule separation method based on improved differential evolution particle cluster algorithm
CN106295789A (en) * 2015-06-10 2017-01-04 浙江托普云农科技股份有限公司 A kind of crop seed method of counting based on image procossing
CN107563384A (en) * 2017-08-31 2018-01-09 江苏大学 The recognition methods end to end of adhesion pig based on broad sense Hough clusters
CN108496203A (en) * 2017-07-17 2018-09-04 深圳市大疆创新科技有限公司 A kind of processing method and processing device to image, intelligent terminal
CN109658414A (en) * 2018-12-13 2019-04-19 北京小龙潜行科技有限公司 A kind of intelligent checking method and device of pig
CN110246174A (en) * 2019-07-08 2019-09-17 北京派克盛宏电子科技有限公司 A kind of farm live pig method of counting
CN110264463A (en) * 2019-06-25 2019-09-20 北京实验工厂有限责任公司 A kind of material counting method based on matlab image procossing
CN110598643A (en) * 2019-09-16 2019-12-20 上海秒针网络科技有限公司 Method and device for monitoring piglet compression
CN110954063A (en) * 2018-09-27 2020-04-03 北京自动化控制设备研究所 Optical relative measurement method for unmanned aerial vehicle landing recovery
CN111340801A (en) * 2020-03-24 2020-06-26 新希望六和股份有限公司 Livestock checking method, device, equipment and storage medium
CN113378663A (en) * 2021-05-25 2021-09-10 武汉理工大学 Inspection pointer type circular instrument identification method and device

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103679181A (en) * 2013-11-25 2014-03-26 浙江大学 Machine vision based in-pigsty pig mark recognition method

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103679181A (en) * 2013-11-25 2014-03-26 浙江大学 Machine vision based in-pigsty pig mark recognition method

Non-Patent Citations (4)

* Cited by examiner, † Cited by third party
Title
GONG ZHANG等: "《Separation of Touching Grain Kernels in an Image by Ellipse Fitting Algorithm》", 《BIOSYSTEMS ENGINEERING》 *
LEI YAN等: "《New separation algorithm for touching grain kernels based on contour segments and ellipse fitting》", 《JOURNAL OF ZHEJIANG UNIVERSITY SCIENCE C》 *
吕丹凤等: "《基于图像的酵母菌出芽率分析方法》", 《计算机系统应用》 *
王志彬等: "《基于K-means聚类和椭圆拟合方法的白粉虱计数算法》", 《农业工程学报》 *

Cited By (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106203238A (en) * 2015-05-05 2016-12-07 北京建筑大学 Well lid component identification method in mobile mapping system streetscape image
CN106295789A (en) * 2015-06-10 2017-01-04 浙江托普云农科技股份有限公司 A kind of crop seed method of counting based on image procossing
CN106203456A (en) * 2016-07-20 2016-12-07 西安科技大学 Coal dust Algorithm for Overlapping Granule separation method based on improved differential evolution particle cluster algorithm
CN108496203A (en) * 2017-07-17 2018-09-04 深圳市大疆创新科技有限公司 A kind of processing method and processing device to image, intelligent terminal
CN107563384A (en) * 2017-08-31 2018-01-09 江苏大学 The recognition methods end to end of adhesion pig based on broad sense Hough clusters
CN110954063A (en) * 2018-09-27 2020-04-03 北京自动化控制设备研究所 Optical relative measurement method for unmanned aerial vehicle landing recovery
CN109658414A (en) * 2018-12-13 2019-04-19 北京小龙潜行科技有限公司 A kind of intelligent checking method and device of pig
CN110264463A (en) * 2019-06-25 2019-09-20 北京实验工厂有限责任公司 A kind of material counting method based on matlab image procossing
CN110246174A (en) * 2019-07-08 2019-09-17 北京派克盛宏电子科技有限公司 A kind of farm live pig method of counting
CN110598643A (en) * 2019-09-16 2019-12-20 上海秒针网络科技有限公司 Method and device for monitoring piglet compression
CN110598643B (en) * 2019-09-16 2022-04-26 上海秒针网络科技有限公司 Method and device for monitoring piglet compression
CN111340801A (en) * 2020-03-24 2020-06-26 新希望六和股份有限公司 Livestock checking method, device, equipment and storage medium
CN113378663A (en) * 2021-05-25 2021-09-10 武汉理工大学 Inspection pointer type circular instrument identification method and device

Also Published As

Publication number Publication date
CN104240243B (en) 2017-05-10

Similar Documents

Publication Publication Date Title
CN104240243A (en) Adhered piglet automatic counting method based on ellipse fitting
WO2020221177A1 (en) Method and device for recognizing image, storage medium and electronic device
AU2019101786A4 (en) Intelligent pig group rearing weighing method and apparatus, electronic device and storage medium
JP6935377B2 (en) Systems and methods for automatic inference of changes in spatiotemporal images
CN110570400B (en) Information processing method and device for chip 3D packaging detection
CN111243005A (en) Livestock weight estimation method, device, equipment and computer readable storage medium
WO2020007363A1 (en) Method and apparatus for identifying number of targets, and computer-readable storage medium
CN111476713A (en) Intelligent weather image identification method and system based on multi-depth convolution neural network fusion
Xu et al. Automatic scoring of postures in grouped pigs using depth image and CNN-SVM
CN111339850B (en) Dairy cow lameness detection method and system based on supporting time phase
CN116778430B (en) Disease monitoring system and method for beef cattle cultivation
CN109101891A (en) A kind of rice pest detection system and its detection method merging artificial intelligence
CN107578408B (en) A kind of simulated measurement apparatus and method of milk cattle cultivating Ground urine area
Lu et al. An automatic splitting method for the adhesive piglets’ gray scale image based on the ellipse shape feature
CN106778784A (en) Pig individual identification and drinking behavior analysis method based on machine vision
CN104007733B (en) It is a kind of that the system and method being monitored is produced to intensive agriculture
CN109242183B (en) Crowd simulation evacuation method and device based on artificial fish-swarm algorithm and target detection
CN104573701B (en) A kind of automatic testing method of Tassel of Corn
CN109297978A (en) The inspection of power circuit unmanned plane and fault intelligence diagnosis system based on binocular imaging
CN117115754B (en) Intelligent duck shed monitoring method based on computer vision
CN109688540A (en) Ad Hoc network physical topology non-cooperative inference system
CN110399782A (en) Children look after scene reply device and method automatically
CN114627505A (en) Automatic milk cow cleanliness scoring method and system, storage medium and equipment
CN115565168A (en) Sugarcane disease identification method based on attention system residual error capsule network
CN114600793A (en) Method, system, storage medium and equipment for automatically detecting cow mastitis

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
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20170510

Termination date: 20200905

CF01 Termination of patent right due to non-payment of annual fee