Image recognition method, device and system
By performing noise reduction processing and dark contrast screening on images of paper with complex textures, combined with morphological filtering and imaging system angle correction, the problem of difficulty in extracting spiral gluing trajectories in the existing technology is solved, and high-precision gluing lines are achieved. detection.
Patent Information
- Application Number
- CN202410036229.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-01-10
- Publication Date
- 2024-10-01
- Estimated Expiration
- 2044-01-10
AI Technical Summary
It is difficult to accurately extract the spiral and elongated sizing tracks on paper with complex textures and uneven light and shade using existing technology. It is easily affected by background stripes and other interferences, resulting in a high false detection rate.
By performing noise reduction processing and area screening on the original image, we use the grayscale characteristics of the dark contrast image to perform dark contrast screening and contrast screening, and isolate areas with a contrast greater than 1 as targets to avoid background interference, combined with morphological area filtering and imaging systems Angle correction to achieve accurate connected domain extraction.
It achieves accurate extraction of spiral gluing trajectories on paper with complex textures, reduces the false detection rate, improves the distinction between glue line areas and non-glue line areas, and enhances detection accuracy and anti-interference capabilities.
Smart Images

Figure CN117876320B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computers, and in particular to an image recognition method, device and system. Background Art
[0002] Cigarette paper is a special industrial paper. Its production process and quality requirements are much higher than those of ordinary writing paper. Cigarette paper has better air permeability and combustion performance than ordinary paper. Its main raw material is bleached hemp pulp, while the raw material of ordinary paper is mainly wood pulp. Cigarette paper includes cigarette paper, tipping paper, and forming paper;
[0003] Cigarette paper is used to wrap tobacco shreds. The width of cigarette paper for regular, medium and thin cigarettes is different. The length specifications of cigarette paper are generally: 4000m, 5000m, and 6000m. The width specifications are: (regular) 26.5mm-27.5mm, (medium) 20.5mm-22mm, (thin) 17.5mm-19mm. Generally, 1.5mm-2mm is reserved for adhesive, which is used for the closed pasting of the paper into a ring.
[0004] Tipping paper, also known as "tip paper", is mainly used to connect the filter and the cigarette together. Some tipping papers are made by coating with a certain characteristic on one side of the base paper using a patterned steel die coating method or a printing method, and then dried, rewound, slitting and other processes. The width of the tipping paper is determined by the length of the cigarette filter, usually with specifications such as 56mm, 58mm, 60mm, 64mm and 68mm, and can also be customized according to needs. The cigarette filter tipping is to put a double-length filter in the middle of two unfiltered cigarettes, first apply glue to the tipping paper through the glue wheel, and then use the glued tipping paper to connect the cigarette and the filter into a "combination cigarette" to form a connected filter cigarette. Then cut another knife in the middle, so that it can instantly become two cigarettes, so the tipping paper of the finished cigarette is only half the width of the original.
[0005] Forming paper is used to encapsulate filter materials. There are ordinary filter rod forming paper and high-permeability filter rod forming paper. Filter rod forming paper is a special paper used to wrap filter materials into filter rods when manufacturing filter rods. It is usually made of a mixture of cellulose and limestone. This kind of paper has been specially processed and has good plasticity and flame resistance, high air permeability and waterproofness. Its main function is to encapsulate filter materials.
[0006] High-transparency paper tape is a type of formed paper. Due to its complex surface texture and uneven light and dark, it is difficult to detect the glue coating quality of its surface spiral spray glue, and it is easily affected by the uneven texture of the paper tape itself, resulting in a high rate of false detection.
[0007] The following prior art is available for the detection of the track of paper tape gluing:
[0008] CN114782420A discloses a corrugated box gluing quality detection method based on an artificial intelligence system, which discloses the following steps:
[0009] Step 1: Collect the image of the glued surface of the corrugated cardboard;
[0010] Step 2: Perform connected domain analysis on the glue-coated surface image to obtain the glue-coated connected domains of the corrugated paper;
[0011] Step 3: Obtain the long axis direction of all glue-connected domains through each glue-connected domain of the corrugated paper;
[0012] The two principal component directions are obtained through the pixel coordinates of each glue-connected domain and the PCA algorithm;
[0013] The principal component direction with the largest eigenvalue is taken as the first principal component direction of each glue-applying connected domain;
[0014] The first principal component direction is the long axis direction of each glue-applied connected domain;
[0015] Step 4: The mode major axis direction of all glue-connected domains is taken as the major axis direction of all glue-connected domains.
[0016] In this method, it only uses the conventional connected domain analysis method to extract the gluing area, and the difficulty faced by this solution is not great, because the gluing of corrugated paper is generally a continuous, straight, and wide area.
[0017] Compared with the spiral and thin strip sizing characteristics of the cigarette paper in this case, the above method does not require a very precise and optimized connected domain analysis algorithm.
[0018] In this field, the calculation of connected domains is generally performed by area screening method. Specifically, it can be seen that in the scheme of a method for layer-by-layer segmentation of distorted inkjet characters in CN111860521A, the calculation of connected domains is mainly divided into two steps:
[0019] First, the input image is binarized, and the translation offset correction is determined by calculating the center of gravity of the binary image and the offset of the image center. Then, the grayscale interval of the text image is extracted, and the connected domains with pixel areas exceeding the text area and the connected domains with pixel areas less than 0.5 times the area of the coding points are filtered out to obtain a preliminary denoised text binary image. By calculating the grayscale projection of the text at various angles, the angle corresponding to the projection peak is found as the rotation offset correction.
[0020] Secondly, based on the image corrected in step 1), the image is closed using a circular template, and scattered points are non-directionally glued together to form a connected domain for the entire text area. The area of the connected domain is screened to obtain the text area range and crop it to achieve rough positioning of the text area.
[0021] The above method of removing irrelevant connected domains by area screening to obtain the required connected domain is a conventional connected domain calculation method in the art.
[0022] The technical problem solved in this case is: how to extract the spiral and slender gluing tracks on paper with complex texture and uneven light and dark. Summary of the invention
[0023] The purpose of the present invention is to provide an image recognition method. The method can obtain an accurate connected domain image by extracting a connected domain, performing preliminary area screening, and then performing dark contrast screening and contrast screening using the grayscale characteristics of the dark contrast image, thereby avoiding the influence of background stripes and other irrelevant interferences. At the same time, the present invention also discloses an image recognition device and system.
[0024] To achieve the above object, the present invention provides the following technical solution: an image recognition method, comprising the following steps performed in sequence:
[0025] Step 1: Perform noise reduction processing on the original image to obtain a noise-reduced image;
[0026] Step 2: Extract the connected domain in the denoised image;
[0027] Step 3: Use the area screening method to screen the connected domains obtained in step 2 to obtain connected domains that meet the requirements;
[0028] Step 4: According to the connected domains obtained by screening in step 3, the corresponding connected domains on the dark contrast image are retained, and the connected domains on the dark contrast image that are lower than a preset dark contrast threshold are deleted to obtain a grayscale screening map;
[0029] The dark contrast image is obtained by performing difference processing on the background image and the original image; the background image is obtained by performing mean filtering processing on the original image;
[0030] Step 5: Separate the area with a contrast greater than 1 on the grayscale screening image, and the area is the target to be identified.
[0031] In the above-mentioned image recognition method, the step 1 is specifically as follows:
[0032] Step 11: Perform point-by-point division operation on the dark contrast image and the background image to obtain a dark contrast image;
[0033] Step 12: Binarize the dark contrast image to obtain a dark contrast area;
[0034] Step 13: Perform morphological region filtering on the dark contrast area to obtain a denoised image.
[0035] In the above-mentioned image recognition method, the specific operation of step 13 is:
[0036] A circular structure element with a radius of 1.5 pixels is used to perform a morphological opening operation on the dark contrast area, and then a circular structure element with a radius of 3.5 pixels is used to perform a morphological closing operation on the dark contrast area that has been morphologically opened to obtain a denoised image.
[0037] In the above-mentioned image recognition method, the original image is obtained by the following method:
[0038] Step 100: Acquire a global image through an imaging system, wherein the global image contains a target object, and the target object consists of a target object and a target object background;
[0039] Step 200: Taking the optical center position of the imaging system as the symmetry center, demarcating a detection area R1 and a detection area R2 that penetrate the target object on both sides of the symmetry center of the global image;
[0040] Step 300: Calculate the vertical distribution function f of the image brightness of the detection area R1 and the detection area R2 left (row) and f right (row), and find its first-order derivative Df left (row) and Df right (row);
[0041] Step 400: First-order derivative Df left (row) and Df right (row) forward search for the first row position FR where the negative deviation is greater than the preset first threshold left and FR right , and in its local range [FR left -Range,FR left +Range] and [FR right -Range,FR right +Range] to find the minimum position UR left and UR right , is the upper edge row position of the target object in the detection area R1 and the detection area R2; the Range is a preset range value;
[0042] Step 500: First-order derivative Df left (row) and Df right (row) reverse search for the first row position FFR where the positive deviation is greater than the preset first threshold left and FFR right , and in its local range [FFR left -Range,FFR left+Range] and [FFR right -Range,FFR right +Range] to obtain the minimum value position DR left and DR right , is the lower edge row position of the target object in the detection area R1 and the detection area R2;
[0043] Step 600: According to UR left , UR right ,DR left and DR right Determine the range of the target object, and extract the image of the target position in the range as the original image.
[0044] In the above-mentioned image recognition method, after step 500, the method further includes: left ,DR left Calculate the left width PWidth of the target object left ;
[0045] According to UR right ,DR right Calculate the right width PWidth of the target object right ;
[0046] According to the left width PWidth left , right width PWidth right The ratio of determines the angle of the imaging system relative to the normal line of the target object, and adjusts the angle of the imaging system by the angle so that the angle between the imaging system and the normal line becomes smaller or coincides;
[0047] After adjusting the angle of the imaging system, steps 100 to 600 are performed again to obtain the required original image.
[0048] In the above-mentioned image recognition method, step 5 further includes step 6;
[0049] Step 6: Calculate the area of the target and compare the area of the target with the area of the original image to determine whether the area of the target meets the preset area range.
[0050] In the above-mentioned image recognition method, the method is applicable to the detection of paper sprayed with glue; the original image is an image of paper; and the target is a track of glue.
[0051] At the same time, the present invention also discloses an image recognition device, comprising the following units:
[0052] Image preprocessing unit: used to perform noise reduction processing on the original image to obtain a noise-reduced image;
[0053] Connected domain extraction unit: used to extract connected domains in denoised images;
[0054] The first screening module is used to screen the connected domains provided by the connected domain extraction unit by using an area screening method to obtain connected domains that meet the requirements;
[0055] The second screening module: according to the connected domains screened by the first screening module, the corresponding connected domains on the dark contrast image are retained, and the connected domains on the dark contrast image that are lower than a preset dark contrast threshold are deleted to obtain a grayscale screening map;
[0056] The dark contrast image is obtained by performing difference processing on the background image and the original image; the background image is obtained by performing mean filtering processing on the original image;
[0057] The third screening module is used to separate the area with a contrast greater than 1 on the grayscale screening image, and the area is the target to be identified.
[0058] In the above-mentioned image recognition device, the image preprocessing unit includes the following modules:
[0059] The first image processing module is used for performing point-by-point division operation on the dark contrast image and the background image to obtain a dark contrast image;
[0060] The second image processing module is used to perform binarization processing on the dark contrast image to obtain a dark contrast area;
[0061] The third image processing module is used to perform morphological region filtering on the dark contrast region to obtain a noise-reduced image.
[0062] In the above-mentioned image recognition device, it also includes an original image extraction unit;
[0063] The original image extraction unit includes the following modules:
[0064] A global image acquisition module: used for acquiring a global image through an imaging system, wherein the global image includes a target object, and the target object is composed of a target object and a target object background;
[0065] Detection area division module: used to define the detection area R1 and the detection area R2 that penetrate the target object on both sides of the symmetry center with the optical center position of the imaging system as the symmetry center;
[0066] First-order derivative calculation module: used to calculate the vertical distribution function f of the image brightness of the detection area R1 and the detection area R2 left (row) and f right (row), and find its first-order derivative Df left (row) and Df right (row);
[0067] Upper edge row position calculation module: used for the first-order derivative Df left (row) and Df right (row) forward search for the first row position FR where the negative deviation is greater than the preset first threshold left and FR right , and in its local range [FR left -Range,FR left +Range] and [FR right -Range,FR right +Range] to find the minimum position UR left and UR right , is the upper edge row position of the target object in the detection area R1 and the detection area R2; the Range is a preset range value;
[0068] Lower edge row position calculation module: used in the first-order derivative Df left (row) and Df right (row) reverse search for the first row position FFR where the positive deviation is greater than the preset first threshold left and FFR right , and in its local range [FFR left -Range,FFR left +Range] and [FFR right -Range,FFR right +Range] to obtain the minimum value position DR left and DR right , is the lower edge row position of the target object in the detection area R1 and the detection area R2;
[0069] Original image extraction module: used to extract the original image according to the UR left , UR right ,DR left and DR right Determine the range of the target object, and extract the image of the target position in the range as the original image.
[0070] In the above-mentioned image recognition device, the original image extraction unit further includes a normal calculation module: left ,DR left Calculate the left width PWidth of the target object left According to UR right ,DR right Calculate the right width PWidth of the target object right ; According to the left width PWidth left , right width PWidth rightThe ratio of determines the angle of the imaging system relative to the normal of the target object, and the angle of the imaging system is adjusted according to the angle to make the angle between the imaging system and the normal smaller or coincident; after adjusting the angle of the imaging system, the original image extraction unit acquires the global image with the adjusted imaging system and extracts the required original image.
[0071] The above-mentioned image recognition device further includes a result calculation unit: used to calculate the area of the target, and compare the area of the target with the area of the original image to determine whether the area of the target meets the preset area range.
[0072] Finally, the present invention also discloses an image recognition system, comprising the image recognition device and the imaging system as described above; the original image comes from the imaging system.
[0073] In the above-mentioned image recognition system, the original image is an image of paper; and the target is a track of glue.
[0074] Compared with the prior art, the present invention has the following beneficial effects:
[0075] The present invention extracts the connected domain, performs preliminary area screening, and then uses the grayscale characteristics of the dark contrast image to perform dark contrast screening and contrast screening, thereby obtaining an accurate connected domain image and avoiding the influence of background stripes and other irrelevant interferences.
[0076] As a further optimization of the present invention, the use of the mean background reconstruction contrast map in the preprocessing operation of the original image can suppress the unevenness of the background illumination and at the same time increase the dark contrast value of the glue line area, so that the glue line area and the non-glue line area can be better distinguished in the later stage.
[0077] As a further optimization of the present invention, a unique adaptive target detection method of the present invention is proposed when processing the global image. The method has an additional imaging tilt estimation capability to achieve the correction of the angle of the imaging device. BRIEF DESCRIPTION OF THE DRAWINGS
[0078] Figure 1 is a flow chart of Example 1;
[0079] Figure 2 is a global image of the cigarette paper of Example 2;
[0080] Figure 3 is a schematic simulation diagram of a cigarette paper marked with a detection area R1 and a detection area R2 according to Example 2;
[0081] Figure 4 is an image of a cigarette paper marked with detection area R1 and detection area R2 of Example 2;
[0082] Figure 5is the vertical distribution function f of Example 2 left (row) and f right (row) grayscale distribution display;
[0083] Figure 6 is the first-order derivative Df of Example 2 left (row) and Df right (row) grayscale distribution display;
[0084] Figure 7 is the background image of Example 2;
[0085] Figure 8 is the dark contrast image of Example 2;
[0086] Fig. 9 is the dark contrast image of Example 2;
[0087] Fig.10 is a dark contrast region diagram of Example 2;
[0088] Fig.11 is the denoised image of Example 2;
[0089] Fig.12 is a flow chart of the original image denoising stage of Example 2;
[0090] Fig.13 is a graph of the connected domain extracted in step 16 of Example 2;
[0091] Fig.14 is a graph of the connected domain extracted in step 17 of Example 2;
[0092] Fig.15 is a graph of the connected domain extracted in step 18 of Example 2;
[0093] Fig.16 is a graph of the connected domain extracted in step 19 of Example 2;
[0094] Fig.17 is a flow chart of the original image acquisition stage of Example 2;
[0095] Fig.18 is a flow chart of the original image denoising stage of Example 2;
[0096] Fig.19 This is an example diagram of a normal situation obtained after being processed by the method shown in Example 2;
[0097] Fig. 20 This is an example diagram of the multi-glue situation obtained after the method shown in Example 2;
[0098] Fig.21This is an example diagram of the glue shortage situation obtained after the method shown in Example 2;
[0099] Fig. 22 This is a structural block diagram of Example 3. DETAILED DESCRIPTION
[0100] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0101] Example 1
[0102] refer to Figure 1 , an image recognition method, comprising the following steps performed in sequence:
[0103] Step 1: Perform noise reduction processing on the original image to obtain a noise-reduced image;
[0104] Image denoising can significantly improve image contrast and reduce the interference of irrelevant factors when extracting connected domains.
[0105] Image noise reduction technology can be implemented in many ways in this field, such as mean filtering, adaptive Wiener filtering, median filtering, morphological noise filtering, wavelet denoising, etc., or a combination of the above methods and conventional methods in this field.
[0106] Step 2: Extract the connected domain in the denoised image;
[0107] The connected domain extraction algorithm is a type of image processing method, which is clearly introduced in the book "Image Processing" and will not be introduced or limited in detail here.
[0108] Step 3: Use the area screening method to screen the connected domains obtained in step 2 to obtain connected domains that meet the requirements;
[0109] The area screening method is a commonly used method in this field. Its main principle is: to screen out the connected domains whose area is greater than a screening threshold, and to delete the connected domains whose area is less than the screening threshold. In this embodiment, the range of the optional screening threshold is not limited to 50 to 500 pixels. The determination of the screening threshold is closely related to the specifications of the target to be detected. If the target to be detected is wide and long, the threshold pixel can be higher. If the target is thin and short, the screening threshold should be as low as possible.
[0110] Step 4: According to the connected domains obtained by screening in step 3, the corresponding connected domains on the dark contrast image are retained, and the connected domains on the dark contrast image that are lower than a preset dark contrast threshold are deleted to obtain a grayscale screening map;
[0111] The dark contrast image is obtained by performing difference processing on the background image and the original image; the background image is obtained by performing mean filtering processing on the original image;
[0112] More specifically, a difference operation is performed on the background image and the original image. In the difference operation, if the result of the difference is less than 0, the image element value that is less than zero is assigned to 0.
[0113] As an important innovation of this embodiment, after the area screening in step 3 is performed, no further operation will be performed on the original image. Compared with the original image, the dark contrast image has the following characteristics: the dark contrast image retains the dark grayscale area in the image and shields the bright spot area;
[0114] By extracting the connected domain on the original image, the corresponding connected domain on the dark contrast image is retained, and the connected domain of the dark contrast image is screened by the dark contrast threshold;
[0115] It should be noted that the definition of dark contrast threshold is: obtaining the threshold in the dark contrast image, the purpose is to segment the target area. In practice, the dark contrast threshold can be set to 8-20;
[0116] The significance of dark contrast threshold screening is to eliminate weak grayscale difference areas and improve the algorithm's anti-interference ability.
[0117] Step 5: Separate the area with a contrast greater than 1 on the grayscale screening image, and the area is the target to be identified.
[0118] The significance of contrast screening of each area on the grayscale screening map is to screen the areas that meet the contrast requirements and shield the areas that do not meet the contrast requirements.
[0119] Step 6: Calculate the area of the target and compare the area of the target with the area of the original image to determine whether the area of the target meets the preset area range, and then obtain a judgment result.
[0120] The present invention extracts the connected domain, performs preliminary area screening, and then uses the grayscale characteristics of the dark contrast image to perform dark contrast screening and contrast screening, so as to obtain an accurate connected domain image and avoid the influence of background stripes and other irrelevant interferences. The present invention is particularly suitable for judging objects with severe background interference and slender and tortuous targets. Compared with the implementation method using similar AI algorithms in the prior art, the processing process of the present invention is simpler while maintaining accuracy.
[0121] Example 2
[0122] This embodiment takes the case of spiral glue spraying trajectory recognition of cigarette paper as an example, starting from the acquisition of the global image, and discusses in detail a more specific application mode of the present invention. Specifically, it includes three stages: the original image acquisition stage, the original image denoising stage, and the connected domain extraction stage. Each stage is explained and analyzed one by one below;
[0123] Original image acquisition stage
[0124] refer to Fig.17 , the original image is obtained by the following method:
[0125] Step 100: Acquire a global image through an imaging system, wherein the global image contains a target object, and the target object consists of a target object and a target object background;
[0126] The global image of cigarette paper can be referenced Figure 2 , the cigarette paper itself is the target background, the spiral line on it is the track of glue, and the track is the target; the cigarette paper and the track constitute the target;
[0127] However, when the imaging system acquires an image, it is impossible to acquire only the target object. In the photo, there must be background other than the target object. Therefore, extracting the target object from the global image is a subsequent operation that needs to be performed.
[0128] Step 200: Taking the optical center position of the imaging system as the symmetry center, demarcating a detection area R1 and a detection area R2 that penetrate the target object on both sides of the symmetry center;
[0129] For details, please refer to Figure 3 and Figure 4 , Figure 3 It is a schematic simulation diagram of the optical center position and the detection area simulated by the applicant;
[0130] Figure 4 In actual application, Figure 2 The detection area is planned based on
[0131] In practical applications, the detection area R1 and the detection area R2 are generally rectangular. In order to ensure that the edge position of the cigarette paper can be identified from the upper and lower edges, the detection area R1 and the detection area R2 must be able to penetrate the cigarette paper in the width direction;
[0132] Step 300: Calculate the vertical distribution function f of the image brightness of the detection area R1 and the detection area R2 left (row) and f right (row), and find its first-order derivative Df left (row) and Df right(row);
[0133] The vertical distribution function is the superposition of the grayscale of the image in the horizontal direction, and the horizontal distribution function is the superposition of the grayscale of the image in the vertical direction;
[0134] The calculation formula is as follows:
[0135]
[0136]
[0137] Vertical distribution function f left (row) and f right (row) The grayscale distribution on the image can be shown in Figure 5 ; Figure 5 The image position corresponding to the detection area R1 and the detection area R2 is the vertical distribution function f left (row) and f right The area covered by the grayscale distribution of (row);
[0138] First-order derivative Df left (row) and Df right The grayscale distribution of (row) can be referenced Figure 6 ;
[0139] Step 400: First-order derivative Df left (row) and Df right (row) forward search for the first row position FR where the negative deviation is greater than the preset first threshold left and FR right , and in its local range [FR left -Range,FR left +Range] and [FR right -Range,FR right +Range] to find the minimum position UR left and UR right , is the upper edge row position of the target object in the detection area R1 and the detection area R2; the Range is a preset range value;
[0140] In practical applications, Range is generally set to 1 pixel to image height / 4 pixels of the region. In this embodiment, it is set to 10 pixels;
[0141] This step can determine the upper edge row position;
[0142] When the line of sight of the imaging system and the normal of the cigarette paper absolutely coincide, it is actually only necessary to calculate UR left or UR rightAny one of them can be used, but in actual production, it is difficult to have absolute overlap, so it is necessary to calculate UR left and UR right ;
[0143] Of course, a method for adjusting the line of sight of the imaging system using the data will be introduced later in this embodiment.
[0144] Step 500: First-order derivative Df left (row) and Df right (row) reverse search for the first row position FFR where the positive deviation is greater than the preset first threshold left and FFR right , and in its local range [FFR left -Range,FFR left +Range] and [FFR right -Range,FFR right +Range] to obtain the minimum value position DR left and DR right , is the lower edge row position of the target object in the detection area R1 and the detection area R2;
[0145] The calculation principle of this step is the same as step 400;
[0146] Step 600: According to UR left , UR right ,DR left and DR right Determine the range of the target object, and extract the image of the target position in the range as the original image.
[0147] Strategies for line of sight adjustment of imaging systems
[0148] In the above steps 400 and 500, UR has been calculated. left , UR right ,DR left and DR right ;
[0149] According to UR left ,DR left Calculate the left width PWidth of the target object left ;PWidth left =DR left -UR left .
[0150] According to UR right ,DR right Calculate the right width PWidth of the target object right ;PWidth right =DRright -UR right .
[0151] According to the left width PWidth left , right width PWidth right The ratio of determines the angle of the imaging system relative to the normal line of the target object, and adjusts the angle of the imaging system by the angle so that the angle between the imaging system and the normal line becomes smaller or coincides;
[0152] Specifically, to adjust the sight angle of the imaging system, it is first necessary to calculate the angle between the sight and the normal of the cigarette paper. The calculation formula is as follows:
[0153]
[0154] Where f is the focal length of the imaging system, H′ is the distance between the left and right paper tape detection areas, and β left and β right They are the imaging magnifications at the left and right side paper tape detection areas, respectively, and can be calculated from the ratio of the actual paper tape width (in mm) to the image width (in mm, determined by the product of the number of pixels and the pixel size).
[0155] The calculation formula for image width is: PWidth = (PWidth left +PWidth right ) / 2.
[0156] Once tanθ is obtained, the line of sight of the imaging system can be adjusted.
[0157] If the sight line is adjusted, it is necessary to completely perform the operations of step 100 to step 600 again to obtain the original image with a more correct position.
[0158] Raw image denoising stage
[0159] refer to Fig.18 The steps of this stage are as follows:
[0160] Step 11: Use a mean filter of maskSize*maskSize (maskSize=19 in the embodiment of the present invention) to perform mean filtering on the original image to obtain a background image; the background image can be referred to Figure 7 ;
[0161] Step 12: Difference the background image and the original image (the image element value less than zero is zero) to obtain a dark contrast image. The dark contrast image can be referred to Figure 8 ;
[0162] Step 13: Perform point-by-point division operation on the dark contrast image and the background image to obtain a dark contrast image; the point-by-point division operation refers to dividing pixels of two images of the same size and the same pixel position;
[0163] Dark contrast chart can be referenced Fig. 9 ;
[0164] Step 14: Binarize the dark contrast image to obtain a dark contrast area;
[0165] The binarization threshold is the weak contrast filtering threshold: GateWeakDiff, which is 11 in the embodiment of the present invention;
[0166] Dark contrast areas can be referenced Fig.10 ;
[0167] Step 15: Perform morphological region filtering on the dark contrast area to obtain a denoised image;
[0168] Morphological operations include dilation, erosion, opening, closing, etc. The dilation operation can enlarge the objects in the image and make them more connected; the erosion operation can reduce the objects in the image and make them more detailed; the opening operation can remove noise and smooth the edges of the image; the closing operation can fill the holes of the objects in the image.
[0169] Specifically in this embodiment, a morphological opening operation is performed using a circular structure element with a radius of 1.5 pixels, and then a morphological closing operation is performed using a circular structure element with a radius of 3.5 pixels to obtain a denoised area. The image of the denoised area can be referred to Fig.11 ;
[0170] The entire operation process from step 11 to step 15 can be referred to Fig.12 .
[0171] Through the above operations, a denoised image can be obtained, and then the next stage of processing can be carried out.
[0172] Connected domain extraction stage
[0173] The connected domain extraction stage is one of the core stages of the present invention. Its optimal processing result is inseparable from the above-mentioned operations, but it does not absolutely depend on the above-mentioned completely identical operations.
[0174] As those skilled in the art can know, as long as the image is segmented and denoised well, this step can actually be applied and an acceptable result can be obtained.
[0175] Next, based on Example 1, combined with the application object of cigarette paper, the extraction of connected domains is specifically described in detail;
[0176] refer to Fig.18 The steps of this stage are as follows:
[0177] Step 16: Extracting connected areas in the denoised image;
[0178] For the introduction of the specific method of extracting the connected domain, see Example 1;
[0179] The connected domain extracted can be seen Fig.13 ;
[0180] Step 17: Use the area screening method to screen the connected domains obtained in step 16 to obtain connected domains that meet the requirements;
[0181] In this embodiment, since the target is a spiral glue track that is long and continuous, based on this characteristic, the screening threshold of this embodiment is 300 pixels;
[0182] After this step, the number of connected domains is significantly reduced, and the connected domain images that meet the requirements can be seen Fig.14 ;
[0183] Step 18: According to the connected domains obtained by screening in step 17, the corresponding connected domains on the dark contrast image are retained, and the connected domains on the dark contrast image that are lower than the preset dark contrast threshold are deleted to obtain a grayscale screening map; the grayscale screening map can be seen Fig.15 ;
[0184] As an important innovation of this embodiment, after performing the area screening in step 3, no further operation will be performed on the original image;
[0185] Specifically speaking of cigarette paper, the original image has background interference caused by the fiber structure of the cigarette paper itself and the unevenness of the paper surface. Therefore, this step is to perform subsequent operations on the dark contrast image based on the connected domain that has been screened by area.
[0186] In this embodiment, the dark contrast threshold is 11.
[0187] Step 19: Separate the area with a contrast greater than 1 on the grayscale screening image, and the area is the target to be identified.
[0188] Target Fig.16 The presentation given, Fig.16 In the image, only the connected domains of the target we need remain, and other irrelevant connected domains disappear completely.
[0189] Step 20: Calculate the area of the target, and compare the area of the target with the area of the original image to determine whether the area of the target meets the preset area range, and then obtain a determination result.
[0190] Count the total area Aglue of all connected domains obtained in step 5 and the image area Apaper of the paper tape area, and the ratio of the two is the glue area ratio: AreaRatio.
[0191] Set the thresholds corresponding to no glue, little glue, normal, and much glue: fGateRatioNoGlue (set to 0.003 in the embodiment of the present invention), fGateRatioLessGlue (set to 0.01 in the embodiment of the present invention), fGateRatioNormGlue (set to 0.1 in the embodiment of the present invention). If AreaRatio is less than fGateRatioNoGlue, it is judged as no glue; if AreaRatio is greater than fGateRatioNoGlue and less than fGateRatioLessGlue, it is judged as little glue; if AreaRatio is greater than fGateRatioLessGlue and less than fGateRatioNormGlue, it is judged as normal; if AreaRatio is greater than fGateRatioNormGlue, it is judged as much glue.
[0192] Normal situation reference Fig.19 ; Multiple glue situation reference Fig. 20 , reference to the situation of less glue Fig.21 .
[0193] Example 3
[0194] refer to Fig. 22 , an image recognition system, comprising an image recognition device and an imaging system 1;
[0195] The image recognition device comprises the following units:
[0196] Original image extraction unit 2: used to obtain the original image;
[0197] The original image extraction unit includes the following modules:
[0198] A global image acquisition module 21 is used to acquire a global image through an imaging system, wherein the global image includes a target object, and the target object is composed of a target object and a target object background;
[0199] The detection area division module 22 is used to define the detection area R1 and the detection area R2 that penetrate the target object on both sides of the symmetry center of the global image with the optical center position of the imaging system as the symmetry center;
[0200] First-order derivative calculation module 23: used to calculate the vertical distribution function f of the image brightness of the detection area R1 and the detection area R2 left (row) and f right (row), and find its first-order derivative Df left(row) and Df right (row);
[0201] Upper edge row position calculation module 24: used for the first-order derivative Df left (row) and Df right (row) forward search for the first row position FR where the negative deviation is greater than the preset first threshold left and FR right , and in its local range [FR left -Range,FR left +Range] and [FR right -Range,FR right +Range] to find the minimum position UR left and UR right , is the upper edge row position of the target object in the detection area R1 and the detection area R2; the Range is a preset range value;
[0202] Lower edge row position calculation module 25: used for the first-order derivative Df left (row) and Df right (row) reverse search for the first row position FFR where the positive deviation is greater than the preset first threshold left and FFR right , and in its local range [FFR left -Range,FFR left +Range] and [FFR right -Range,FFR right +Range] to obtain the minimum value position DR left and DR right , is the lower edge row position of the target object in the detection area R1 and the detection area R2;
[0203] Original image extraction module 26: used to extract the original image according to the UR left , UR right ,DR left and DR right Determine the range of the target object, and extract the image of the target position in the range as the original image.
[0204] Normal calculation module 27: used to calculate the normal line according to UR left ,DR left Calculate the left width PWidth of the target object left According to UR right ,DR right Calculate the right width PWidth of the target object right ; According to the left width PWidth left , right width PWidthright The ratio of determines the angle of the imaging system relative to the normal of the target object, and the angle of the imaging system is adjusted according to the angle to make the angle between the imaging system and the normal smaller or coincident; after adjusting the angle of the imaging system, the original image extraction unit acquires the global image with the adjusted imaging system and extracts the required original image.
[0205] Image preprocessing unit 3: used to perform noise reduction processing on the original image to obtain a noise-reduced image;
[0206] More specifically:
[0207] The image preprocessing unit includes the following modules:
[0208] The first image processing module 31 is used for performing point-by-point division operation on the dark contrast image and the background image to obtain a dark contrast image; the dark contrast image is obtained by performing difference processing on the background image and the original image; the background image is obtained by performing mean filtering processing on the original image;
[0209] The second image processing module 32 is used to perform binarization processing on the dark contrast image to obtain a dark contrast area;
[0210] The third image processing module 33 is used to perform morphological region filtering on the dark contrast region to obtain a noise-reduced image.
[0211] Connected domain extraction unit 4: used to extract connected domains in the denoised image;
[0212] The first screening module 41 is used to screen the connected domains provided by the connected domain extraction unit by using an area screening method to obtain connected domains that meet the requirements;
[0213] The second screening module 42: retains the corresponding connected domains on the dark contrast image according to the connected domains screened by the first screening module, and deletes the connected domains on the dark contrast image that are lower than a preset dark contrast threshold, to obtain a grayscale screening map;
[0214] The third screening module 43 is used to separate the area with a contrast greater than 1 on the grayscale screening image, and the area is the target to be identified.
[0215] Result calculation unit 5 is used to calculate the area of the target, and compare the area of the target with the area of the original image to determine whether the area of the target meets the preset area range.
[0216] The working principle of the above system is:
[0217] The original image extraction unit starts to work. It obtains the global image through the global image acquisition module, and demarcates the detection area R1 and the detection area R2 on the global image through the detection area division module; the first-order derivative calculation module calculates the first-order derivative Df based on the output data of the detection area division module. left (row) and Df right (row); the upper edge row position calculation module and the lower edge row position calculation module are based on the first-order derivative Df left (row) and Df right (row) calculate the upper edge row position of the target object and the lower edge row position of the target object; the normal calculation module calculates the normal angle between the imaging system and the cigarette paper, and controls the imaging system to adjust the line of sight angle; after the adjustment, the global image acquisition module, the detection area division module, the first-order derivative calculation module, the upper edge row position calculation module, and the lower edge row position calculation module are reused to run, and the range of the original image is determined by the original image extraction module to extract the original image;
[0218] After the original image is extracted, the image preprocessing unit starts working. The specific working process is as follows:
[0219] The first image processing module processes to obtain a background image, a dark contrast image, and a dark contrast map; the second image processing module further performs binarization processing on the dark contrast map to obtain a dark contrast area; and the third image processing module performs morphological area filtering on the dark contrast area to obtain a denoised image.
[0220] After the noise reduction process is completed, the connected domain extraction is performed, and the connected domain extraction unit works. Specifically, the first screening module performs screening for the first time to remove part of the connected domain, the second screening module performs screening for the second time to remove part of the connected domain; the third screening module performs screening for the third time to remove part of the connected domain, and finally the target is obtained, and the result calculation unit calculates the result and outputs the result or alarm.
Claims
1. An image recognition method, characterized in that: The method comprises the following steps in sequence: Step 1: Perform noise reduction processing on the original image to obtain a noise-reduced image; Step 2: Extract the connected domain in the denoised image; Step 3: Use the area screening method to screen the connected domains obtained in step 2 to obtain connected domains that meet the requirements; Step 4: According to the connected domains obtained by screening in step 3, the corresponding connected domains on the dark contrast image are retained, and the connected domains on the dark contrast image that are lower than a preset dark contrast threshold are deleted to obtain a grayscale screening map; The dark contrast threshold is: a threshold used to segment the target area in the dark contrast image, and the dark contrast threshold is set to 8-20; The dark contrast image is obtained by performing difference processing between the background image and the original image; The background image is obtained by processing the original image with mean filtering; Step 5: Separate the area with a contrast greater than 1 on the grayscale screening image, and the area is the target to be identified; The original image is obtained by the following method: Step 100: Acquire a global image through an imaging system, wherein the global image contains a target object, and the target object consists of a target object and a target object background; Step 200: Taking the optical center position of the imaging system as the symmetry center, demarcating a detection area R1 and a detection area R2 that penetrate the target object on both sides of the symmetry center of the global image; Step 300: Calculate the vertical distribution function of the image brightness of the detection area R1 and the detection area R2 f left (row) and f right (row), and find its first-order derivative Df left (row) and Df right (row); The vertical distribution function is a superposition of gray levels in the horizontal direction of the image; ;; ; Step 400: First-order derivative Df left (row) and Df right (row) forward search for the first row position FR where the negative deviation is greater than the preset first threshold left and FR right , and in its local range [FR left -Range, FR left +Range] and [FR right -Range, FR right +Range] to find the minimum position UR left and UR right , is the upper edge row position of the target object in the detection area R1 and the detection area R2; the Range is a preset range value; Step 500: First-order derivative Df left (row) and Df right (row) reverse search for the first row position FFR where the positive deviation is greater than the preset first threshold left and FFR right , and in its local range [FFR left -Range, FFR left +Range] and [FFR right -Range, FFR right +Range] to obtain the minimum value position DR left and DR right , is the lower edge row position of the target object in the detection area R1 and the detection area R2; Step 600: According to UR left , UR right ,DR left and DR right Determine the range of the target object, and extract the image of the target position in the range as the original image.
2. The image recognition method according to claim 1, characterized in that: The step 1 is specifically as follows: Step 11: Perform point-by-point division operation on the dark contrast image and the background image to obtain a dark contrast image; Step 12: Binarize the dark contrast image to obtain a dark contrast area; Step 13: Perform morphological region filtering on the dark contrast area to obtain a denoised image.
3. The image recognition method according to claim 2, characterized in that: The specific operations of step 13 are: A circular structure element with a radius of 1.5 pixels is used to perform a morphological opening operation on the dark contrast area, and then a circular structure element with a radius of 3.5 pixels is used to perform a morphological closing operation on the dark contrast area that has been morphologically opened to obtain a denoised image.
4. The image recognition method according to claim 1, characterized in that: After step 500, the following step further includes: left ,DR left Calculate the left width PWidth of the target object left ; According to UR right ,DR right Calculate the right width PWidth of the target object right ; According to the left width PWidth left , right width PWidth right The ratio of determines the angle of the imaging system relative to the normal line of the target object, and adjusts the angle of the imaging system by the angle so that the angle between the imaging system and the normal line becomes smaller or coincides; After adjusting the angle of the imaging system, steps 100 to 600 are performed again to obtain the required original image.
5. The image recognition method according to claim 1, characterized in that: The step 5 also includes step 6; Step 6: Calculate the area of the target and compare the area of the target with the area of the original image to determine whether the area of the target meets the preset area range.
6. The image recognition method according to any one of claims 1 to 5, characterized in that: The method is applicable to the detection of paper sprayed with glue; the original image is an image of paper; and the target is a track of glue.
7. An image recognition device, characterized in that: The following units are included: Image preprocessing unit: used to perform noise reduction processing on the original image to obtain a noise-reduced image; Connected domain extraction unit: used to extract connected domains in denoised images; The first screening module is used to screen the connected domains provided by the connected domain extraction unit by using an area screening method to obtain connected domains that meet the requirements; The second screening module: according to the connected domains screened by the first screening module, the corresponding connected domains on the dark contrast image are retained, and the connected domains on the dark contrast image that are lower than a preset dark contrast threshold are deleted to obtain a grayscale screening map; The dark contrast image is obtained by performing difference processing between the background image and the original image; The background image is obtained by processing the original image with mean filtering; The dark contrast threshold is: a threshold used to segment the target area in the dark contrast image, and the dark contrast threshold is set to 8-20; The third screening module is used to separate the area with a contrast greater than 1 on the grayscale screening image, and the area is the target to be identified; Original image extraction unit; The original image extraction unit includes the following modules: A global image acquisition module: used to acquire a global image through an imaging system, wherein the global image includes a target object, and the target object consists of a target object and a target object background; Detection area division module: used to define the detection area R1 and the detection area R2 that penetrate the target object on both sides of the symmetry center with the optical center position of the imaging system as the symmetry center; First-order derivative calculation module: used to calculate the vertical distribution function of the image brightness of the detection area R1 and the detection area R2 f left (row) and f right (row), and find its first-order derivative Df left (row) and Df right (row); The vertical distribution function is a superposition of gray levels in the horizontal direction of the image; ;; ; Upper edge row position calculation module: used for first-order derivative Df left (row) and Df right (row) forward search for the first row position FR where the negative deviation is greater than the preset first threshold left and FR right , and in its local range [FR left -Range, FR left +Range] and [FR right -Range, FR right +Range] to find the minimum position UR left and UR right , is the upper edge row position of the target object in the detection area R1 and the detection area R2; the Range is a preset range value; Lower edge row position calculation module: used for first-order derivative Df left (row) and Df right (row) reverse search for the first row position FFR where the positive deviation is greater than the preset first threshold left and FFR right , and in its local range [FFR left -Range,FFR left +Range] and [FFR right -Range, FFR right +Range] to obtain the minimum value position DR left and DR right , is the lower edge row position of the target object in the detection area R1 and the detection area R2; Original image extraction module: used to extract the original image according to the UR left , UR right ,DR left and DR right Determine the range of the target object, and extract the image of the target position in the range as the original image.
8. The image recognition device according to claim 7, characterized in that: The image preprocessing unit includes the following modules: The first image processing module is used for performing point-by-point division operation on the dark contrast image and the background image to obtain a dark contrast image; The second image processing module is used to perform binarization processing on the dark contrast image to obtain a dark contrast area; The third image processing module is used to perform morphological region filtering on the dark contrast region to obtain a noise-reduced image.
9. The image recognition device according to claim 8, characterized in that: The original image extraction unit also includes a normal calculation module: left ,DR left Calculate the left width PWidth of the target object left According to UR right ,DR right Calculate the right width PWidth of the target object right ; According to the left width PWidth left , right width PWidth right The ratio of determines the angle of the imaging system relative to the normal of the target object, and the angle of the imaging system is adjusted according to the angle to make the angle between the imaging system and the normal smaller or coincident; after adjusting the angle of the imaging system, the original image extraction unit acquires the global image with the adjusted imaging system and extracts the required original image.
10. The image recognition device according to claim 7, characterized in that: It also includes a result calculation unit: used to calculate the area of the target, and compare the area of the target with the area of the original image to determine whether the area of the target meets the preset area range.
11. An image recognition system, characterized in that: It comprises the image recognition device and imaging system as claimed in claims 7 to 10; the original image comes from the imaging system.
12. The image recognition system according to claim 11, characterized in that: The original image is an image of paper; the target is a track of glue.
