Image detection method, device, electronic device and storage medium
By automatically determining the image area and color channel and based on channel image segmentation, the inefficiency and high cost problems caused by manual selection of auxiliary light sources in the prior art are solved, and efficient and accurate image detection is achieved.
Patent Information
- Application Number
- CN202110193838.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-02-20
- Publication Date
- 2024-11-26
- Estimated Expiration
- 2041-02-20
AI Technical Summary
In the product acceptance process, the existing technology requires manual selection of auxiliary light sources for image segmentation, resulting in low efficiency in assembly line operation, relying on the professional level of operators and high cost.
By acquiring the image to be processed, determining the image area and color channel, segmenting the image based on the channel image, automatically determining whether the object to be detected is a standard object, and reducing dependence on the auxiliary light source.
It improves the efficiency and accuracy of image segmentation, saves labor costs and time costs, and reduces the misjudgment rate.
Smart Images

Figure CN112884740B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of image processing, and in particular to an image detection method, device, electronic device and storage medium. Background Art
[0002] In the product acceptance process, auxiliary light sources are usually required to achieve high-precision image segmentation, and then extract whether the object to be inspected meets the production standards based on the image segmentation results; in related technologies, auxiliary light sources are usually selected manually, which will bring time-consuming and labor-intensive problems, and then lead to low efficiency of assembly line operations. Summary of the invention
[0003] In view of this, embodiments of the present application hope to provide an image detection method, device, electronic device and storage medium.
[0004] The technical solution of this application is implemented as follows:
[0005] The present application provides an image detection method, the method comprising:
[0006] Acquire an image to be processed containing an object to be detected;
[0007] Determining an image area of the object to be detected in the image to be processed;
[0008] In the image area, determining a color channel whose color proportion is greater than or equal to a preset distribution ratio;
[0009] Based on the color channel, performing image acquisition on the image to be processed to obtain a channel image;
[0010] Based on the channel image, performing image segmentation on the image to be processed to determine a target area of the object to be detected in the image to be processed;
[0011] Based on the target area, it is determined whether the object to be detected is a standard object.
[0012] The embodiment of the present application further provides an image detection device, the image detection device comprising: an acquisition module, a first determination module, a collection module, and a second determination module; wherein:
[0013] The acquisition module is used to acquire the image to be processed containing the object to be detected;
[0014] The first determination module is used to determine the image area of the object to be detected in the image to be processed;
[0015] The first determination module is further used to determine, in the image area, a color channel whose color proportion is greater than or equal to a preset distribution ratio;
[0016] The acquisition module is used to acquire the image to be processed based on the color channel to obtain a channel image;
[0017] The second determination module is used to perform image segmentation on the image to be processed based on the channel image, and determine the target area of the object to be detected in the image to be processed;
[0018] The second determination module is further configured to determine whether the object to be detected is a standard object based on the target area.
[0019] An embodiment of the present application further provides an electronic device, the electronic device comprising: a processor, a memory, and a communication bus;
[0020] The communication bus is used to realize the communication connection between the processor and the memory;
[0021] The processor is used to execute the program in the memory to implement the above-mentioned image detection method.
[0022] Accordingly, an embodiment of the present application also provides a computer-readable storage medium, which stores one or more programs. The one or more programs can be executed by one or more processors to implement the steps of the image detection method described above.
[0023] The image detection method, device, electronic device and storage medium provided in the embodiments of the present application first obtain an image to be processed containing an object to be detected; and determine the image area of the object to be detected in the image to be processed; secondly, in the image area, determine the color channel whose color proportion is greater than or equal to a preset distribution ratio; based on the color channel, perform image acquisition on the image to be processed to obtain a channel image; finally, based on the channel image, perform image segmentation on the image to be processed to determine the target area of the object to be detected in the image to be processed; and based on the target area, determine whether the object to be detected is a standard object; in this way, by determining the color channel corresponding to the image area in the image to be processed, and processing the image to be processed based on the color channel to determine the target area of the object to be detected, and then judging whether the object to be detected is a standard object, the cost of determining the auxiliary light source corresponding to the image to be processed can be saved, and the efficiency of determining the object to be detected can be improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] Figure 1 A schematic diagram of a flow chart of an image detection method provided in an embodiment of the present application;
[0025] Figure 2 A schematic diagram of a flow chart of another image detection method provided in an embodiment of the present application;
[0026] Figure 3 A schematic diagram of a flow chart of another image detection method provided in an embodiment of the present application;
[0027] Figure 4 A schematic diagram of a process for an image detection method applied to a production line provided in an embodiment of the present application;
[0028] Figure 5 A schematic diagram of a process of applying an image detection method provided in an embodiment of the present application to actual production;
[0029] Figure 6 A schematic diagram of the structure of an image detection device provided in an embodiment of the present application;
[0030] Figure 7 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0031] The technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application.
[0032] It should be understood that the "embodiments of the present application" or "the aforementioned embodiments" mentioned throughout the specification mean that specific features, structures or characteristics related to the embodiments are included in at least one embodiment of the present application. Therefore, "in the embodiments of the present application" or "in the aforementioned embodiments" appearing throughout the specification do not necessarily refer to the same embodiment. In addition, these specific features, structures or characteristics can be combined in one or more embodiments in any suitable manner. In the various embodiments of the present application, the size of the serial numbers of the above-mentioned processes does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application. The above-mentioned serial numbers of the embodiments of the present application are for description only and do not represent the advantages and disadvantages of the embodiments.
[0033] Unless otherwise specified, the electronic device performs any step in the embodiments of the present application, and the processor of the electronic device may perform the step. It is also worth noting that the embodiments of the present application do not limit the order in which the electronic device performs the following steps. In addition, the methods used to process data in different embodiments may be the same method or different methods. It should also be noted that any step in the embodiments of the present application can be independently executed by the electronic device, that is, when the electronic device executes any step in the following embodiments, it may not rely on the execution of other steps.
[0034] In actual industrial production lines, especially in the acceptance stage of products to be inspected on the production line, it is usually necessary to rely on auxiliary light sources to achieve high-precision image segmentation of the products to be inspected, so as to extract whether the objects to be inspected meet the production standards; in related technologies, manual selection of auxiliary light sources is usually used to achieve high-precision image segmentation of products to be inspected, wherein a deep learning algorithm is first used to perform a large amount of annotation and training on each sample to be inspected to determine the specific auxiliary light source, and then manually select the corresponding auxiliary light source for later production operations. This will lead to the problem of over-reliance on the professional level of the operator. At the same time, in actual industrial production, when the replacement frequency of the samples to be inspected is too fast, there will be problems with increased algorithm deployment costs, labor costs and time costs.
[0035] Based on the above problems, the present application embodiment provides an image detection method, which is applied to electronic equipment, referring to Figure 1 The steps shown are explained below:
[0036] Step 101: Acquire an image to be processed containing an object to be detected.
[0037] In the embodiment of the present application, the electronic device may be any device with data processing capability.
[0038] In a feasible implementation, the electronic device can acquire the image to be processed through its internal image acquisition module.
[0039] In another feasible implementation, the electronic device may directly receive the image to be processed sent by a second electronic device that can communicate information with the electronic device.
[0040] It should be noted that the image format of the image to be processed includes but is not limited to: bitmap (Bitmap, BMP) format, Joint Photographic Experts Group (Joint Photographic Experts Group, JPEG) format, Portable Network Graphics (Portable Network Graphics, PNG) format and Personal Computer eXchange (Personal Computer eXchange, PCX) format, etc., and the embodiments of the present application do not impose any restrictions on this; accordingly, the number and size of the images to be processed are not subject to any restrictions in the embodiments of the present application.
[0041] Among them, the image to be processed can be a color image or a grayscale image; among them, the color image can be a pseudo-color image, a true color image, a monochrome image, etc., and the embodiments of the present application do not impose any limitations on this; in the following embodiments of the present application, the image to be processed refers to a color image.
[0042] In an embodiment of the present application, the image to be processed may be an image with a printing color mode (Cyan Magenta YellowblacK, CMYK), or an image with a red, green, and blue three-color mode (Red Green Blue, RGB), etc., and the embodiment of the present application does not impose any limitation on this.
[0043] In an embodiment of the present application, in an image to be processed that is acquired by an electronic device and contains an object to be detected, the object to be detected may be a person, an animal, text, a flower, a building, etc. The embodiment of the present application does not impose any limitation on the specific attributes of the object to be detected; accordingly, the number of objects to be detected, the specific position of the object to be detected in the image to be processed, and the specific form of expression are not limited in any way in the embodiment of the present application.
[0044] In a feasible implementation, the image to be processed containing the object to be detected may be a poster containing a plurality of people in motion.
[0045] In another feasible implementation, the image to be processed containing the object to be detected may be a blessing image that can present a text message of “Happy New Year”.
[0046] In yet another feasible implementation, the image to be processed containing the object to be detected may be a label image containing a related product trademark.
[0047] Based on this, the image to be processed containing the object to be detected can be an image presenting any picture, and the embodiments of the present application do not impose any limitation on this.
[0048] Step 102: Determine the image region of the object to be detected in the image to be processed.
[0049] In an embodiment of the present application, the electronic device determines an image area of the object to be detected in the image to be processed.
[0050] In a feasible implementation manner, the image region may be a location region where the object to be detected is located in the image to be processed.
[0051] In another feasible implementation manner, the image area may be a peripheral area corresponding to the position area where the object to be detected is located in the image to be processed.
[0052] Based on this, the image area determined by the electronic device is an area that has a certain correlation with the object to be detected; wherein, the image area can be one, or two or more, and the present application does not impose any limitation on this; accordingly, the shape, size and specific position of the image area in the image to be processed are not limited in the embodiments of the present application.
[0053] In an embodiment of the present application, the electronic device can determine the image area of the object to be inspected in the image to be processed based on an image segmentation method; wherein the image segmentation method includes but is not limited to: a threshold-based segmentation method, a region-based segmentation method, an edge-based segmentation method, and a segmentation method based on a specific theory, etc.
[0054] Step 103: In the image area, determine the color channels whose color proportion is greater than or equal to the preset distribution ratio.
[0055] In an embodiment of the present application, the electronic device determines, from the image area, a color channel whose color proportion is greater than or equal to a preset distribution ratio; wherein the preset distribution ratio can be a numerical value, for example, the preset distribution ratio can be set to 80%, 90% or 95%, etc.
[0056] It should be noted that each image or each image area has one or more color channels; the number of color channels depends on the color mode of the image or image area; accordingly, a CMYK image has 4 color channels, namely cyan, magenta, yellow and black; an RGB image has 3 color channels, namely red, green and blue.
[0057] In the embodiment of the present application, the number of color channels may be one or more than two, and the embodiment of the present application does not impose any limitation on this.
[0058] Step 104: Based on the color channel, perform image acquisition on the image to be processed to obtain a channel image.
[0059] In the embodiment of the present application, the electronic device performs image acquisition on the image to be processed based on the determined color channel to obtain a channel image.
[0060] In a feasible implementation, the electronic device first determines a light source that matches a color channel, and simultaneously irradiates the image to be processed with the light source, and simultaneously performs image acquisition on the image to be processed to obtain a channel image.
[0061] In an embodiment of the present application, the electronic device performs image acquisition on the image to be processed based on its internal image acquisition module to obtain a channel image; wherein, the image acquisition module has different ways of acquiring the image to be acquired and the channel image. In an embodiment of the present application, the image to be processed acquired by the image acquisition module is an RGB image, and the channel image acquired is a grayscale image; in an embodiment of the present application, the channel image can be a grayscale image corresponding to the image to be processed; wherein, the picture content presented by the channel image and the image to be processed differs only in color, and other presentation forms are the same.
[0062] It should be noted that a complete image is usually composed of three channels: red, green and blue. The thumbnails of the red, green and blue channels are displayed in grayscale, and different grayscale levels are used to represent the proportion of "red, green and blue" in the image. The pure white in the channel represents that the color light has the highest brightness here, and the brightness level is 255.
[0063] Step 105: Based on the channel image, perform image segmentation on the image to be processed to determine the target area of the object to be detected in the image to be processed.
[0064] In the embodiment of the present application, the electronic device performs image segmentation on the image to be processed based on the channel image to determine the target area of the image to be detected in the image to be processed.
[0065] Among them, the target area may refer to the location area of the object to be detected in the image to be processed; accordingly, the target area may be the same as the image area or may be different, and the embodiments of the present application do not impose any limitation on this.
[0066] In a feasible implementation, the target area refers to the location area of the object to be detected in the image to be processed; the image area refers to the region of interest (ROI) of the object to be detected in the image to be processed; wherein the location area may be the same as the ROI.
[0067] In another feasible implementation, the target area refers to the position area of the object to be detected in the image to be processed; the image area refers to the surrounding area corresponding to the ROI of the object to be detected in the image to be processed; wherein the position area is different from the periodic area corresponding to the ROI.
[0068] It should be noted that the specific position, shape, size, etc. of the target area in the image to be processed are not limited in the embodiments of the present application.
[0069] In an embodiment of the present application, the electronic device can adjust the image area in the image to be processed based on the corresponding relationship between the channel image and the image to be processed to obtain an adjusted image area, and then perform image segmentation on the image to be processed based on the adjusted image area to determine the target area of the object to be detected in the image to be processed.
[0070] Step 106: Based on the target area, determine whether the object to be detected is a standard object.
[0071] In the embodiment of the present application, the electronic device determines whether the object to be detected is a standard object based on the target area.
[0072] It should be noted that the standard object refers to an object that meets a preset rule or a preset threshold; in the embodiment of the present application, there is a corresponding relationship between the object to be detected and the standard object.
[0073] Among them, the electronic device extracts the object to be detected from the determined target area, and compares the extracted object to be detected with the reference object for similarity, and then determines whether the object to be detected is a standard object based on the similarity comparison result; in the embodiment of the present application, the reference object refers to the object used as the inspection standard.
[0074] In a feasible implementation, when the electronic device extracts the object to be detected as a first person in a walking state based on the target area, and obtains the second person in a walking state from the sample image, the electronic device performs a similarity comparison on the presentation posture, size, color parameters of the first person and the second person, and the first position of the image to be processed and the second position of the sample image respectively. When the comparison result meets the preset threshold and it is determined that the match degree between the first person and the second person is higher than 90%, the first person is further determined to be the standard object.
[0075] In another feasible implementation, when the electronic device extracts the first text line information representing "Happy New Year" as the object to be detected based on the target area, and obtains the second text line information representing "Happy New Year's Day" from the sample image, the electronic device performs a similarity comparison on the size, color parameters and presentation content of the first text line information and the second text line information. When the comparison result indicates that the matching degree between the first text line information and the second text line information is less than 80%, it is determined that the first text line information is not a standard object.
[0076] The sample image is an image that corresponds to the image to be processed and is used to check whether the object to be detected in the image to be processed meets the preset standard; accordingly, the sample image contains a reference object that corresponds to the object to be detected.
[0077] It should be noted that in an embodiment of the present application, a color channel whose color proportion meets a preset distribution ratio is determined from the image area of the image to be processed by the object to be detected, and the color channel is determined as the color parameter corresponding to the auxiliary light source for segmenting the image to be processed; in this way, the operation link of manually selecting the auxiliary light source by the technician in the relative technology can be avoided, thereby saving the labor cost and time cost of determining the auxiliary light source for segmenting the image to be processed; at the same time, image acquisition and image segmentation of the image to be processed based on the determined color channel can make the determination of the object to be detected in the target area of the image to be processed more accurate, thereby improving the accuracy and efficiency of extracting the object to be detected from the target area, and at the same time reducing the error rate of determining whether the object to be detected is a standard object.
[0078] The image detection method provided by the embodiment of the present application first obtains an image to be processed containing an object to be detected; and determines an image area of the object to be detected in the image to be processed; secondly, in the image area, determines a color channel whose color proportion is greater than or equal to a preset distribution ratio; based on the color channel, performs image acquisition on the image to be processed to obtain a channel image; finally, based on the channel image, performs image segmentation on the image to be processed to determine a target area of the object to be detected in the image to be processed; and based on the target area, determines whether the object to be detected is a standard object; in this way, by determining the color channel corresponding to the image area in the image to be processed, and processing the image to be processed based on the color channel to determine the target area of the object to be detected, and then judging whether the object to be detected is a standard object, the cost of determining the auxiliary light source corresponding to the image to be processed can be saved, and the efficiency of determining the object to be detected can be improved.
[0079] Based on the above embodiments, the present application also provides an image detection method, which is applied to electronic equipment, referring to Figure 1 and Figure 2 The steps shown are explained below:
[0080] Step 201: determine a marking area of the object to be detected in the image to be processed.
[0081] In an embodiment of the present application, the electronic device determines an identification area of the object to be detected in the image to be processed; wherein the identification area may be an area that has a certain association with the object to be detected; the electronic device may determine the corresponding identification area from the image to be processed based on the target detection method.
[0082] Among them, the electronic device can determine the location area of the object to be detected in the image to be processed as the identification area; the identification area can be the ROI of the object to be detected in the image to be processed; wherein the ROI can be an area to be processed outlined in the form of a square, circle, ellipse or irregular polygon.
[0083] It should be noted that ROI is an area selected by the electronic device from the image to be processed for focus in subsequent analysis; wherein, using ROI can reduce the processing time of the electronic device and increase the accuracy of determining the area.
[0084] The number of identification areas, the positions of the identification areas in the image to be processed, and the sizes of the identification areas in the image to be processed are not limited in the embodiments of the present application.
[0085] It should be noted that the logo area and the image area may be the same, different, or partially overlap, and the embodiment of the present application does not impose any limitation on this.
[0086] Step 202: Determine at least one boundary area based on the identified area.
[0087] The image area includes at least one boundary area.
[0088] In an embodiment of the present application, the electronic device determines at least one boundary area based on the identification area; wherein the boundary area refers to a surrounding area corresponding to the identification area.
[0089] It should be noted that at least one boundary area may be continuous or discontinuous; accordingly, there is a corresponding relationship between the boundary area and the identification area.
[0090] In the embodiment of the present application, the image area includes at least one boundary area; wherein the number of boundary areas can be determined by the electronic device based on the identification area, and there is no limitation on this in the embodiment of the present application.
[0091] It should be noted that in the embodiment of the present application, the electronic device determines at least one boundary area based on the identification area of the object to be detected in the image to be processed, so as to determine the specific boundary position of the object to be detected in the image to be processed, so that when the subsequent electronic device performs image segmentation based on the boundary area, it can determine the target area of the object to be detected more accurately.
[0092] Accordingly, when the electronic device performs step 103, that is, when the electronic device determines the color channel whose color proportion is greater than or equal to the preset distribution ratio in the image area, it can also be implemented by performing the following steps 203 to 205:
[0093] Step 203: Determine the color parameters of each boundary area.
[0094] In an embodiment of the present application, the electronic device obtains and determines the color parameters of each boundary area; wherein the color parameters refer to the color parameters corresponding to the content presented in each boundary area.
[0095] In a feasible implementation, when the image to be processed is a CMYK image, the electronic device determines that the color parameters of the corresponding boundary area may include: cyan, magenta, yellow and black.
[0096] In another feasible implementation, when the image to be processed is an RGB image, the electronic device determines that the color parameters of the corresponding boundary area may include: red, green, and blue.
[0097] It should be noted that the color parameters of each boundary area may be the same, different, or even partially the same, and the embodiments of the present application do not impose any limitation on this.
[0098] Step 204: Determine a color parameter set based on the color parameters of each boundary area.
[0099] In the embodiment of the present application, the electronic device determines a corresponding color parameter set based on the color parameters of each boundary area.
[0100] Among them, the color parameter set includes each color parameter and the proportion value of each color parameter in each boundary area; wherein, each color parameter in the color parameter set and the proportion value corresponding to each color parameter are stored accordingly; accordingly, the color parameter set can be represented by tables, images and texts, and the embodiments of the present application do not impose any limitations on this.
[0101] Step 205: From the color parameter set, determine the channels corresponding to the color parameters whose proportions are greater than or equal to the preset distribution ratio as the color channels.
[0102] In an embodiment of the present application, the electronic device selects and determines, from a color parameter set, a channel corresponding to a color parameter whose proportion is greater than or equal to a preset distribution ratio as a color channel.
[0103] In an embodiment of the present application, the color parameter set can be presented in the form of a color histogram; wherein the color histogram is a color feature widely used in many image retrieval systems; it describes the proportion of different colors in the entire image, and does not involve the spatial position of each color, that is, it does not involve describing the objects or objects in the image.
[0104] In a feasible implementation, the electronic device determines, from the color parameter set, that the color parameter having a proportion greater than or equal to a preset distribution ratio is red, and determines the channel corresponding to red as the color channel.
[0105] In another feasible implementation, the electronic device determines from the color parameter set that the color parameters whose proportions are greater than or equal to a preset distribution ratio are red and blue, and determines the channels corresponding to the red and blue colors, respectively.
[0106] It should be noted that in the embodiment of the present application, the corresponding color channel is determined based on the color parameters of each boundary area, so that the color parameters on which the determined color channel depends involve each boundary area, so that when the electronic device later performs image acquisition and segmentation on the object to be processed based on the color channel, the corresponding target area is obtained with higher accuracy, thereby improving the accuracy and efficiency of extracting the object to be detected from the target area, and at the same time reducing the error rate of determining whether the object to be detected is a standard object.
[0107] Accordingly, when the electronic device executes step 105, that is, the electronic device performs image segmentation on the image to be processed based on the channel image and determines the target area of the object to be detected in the image to be processed, it can also be implemented by executing the following steps 206 to 207:
[0108] Step 206: Adjust each boundary region based on the channel image to obtain at least one adjusted boundary region.
[0109] In an embodiment of the present application, the electronic device adjusts each boundary region based on a channel image to obtain at least one adjusted boundary region; wherein the channel image is a grayscale image corresponding to the image to be processed.
[0110] In a feasible implementation, the electronic device adjusts the position information of each boundary region in the image to be processed based on the channel image, that is, based on the correspondence between the channel image and the image to be processed, to obtain at least one adjusted boundary region.
[0111] In a feasible implementation, the electronic device adjusts the size of each boundary region in the image to be processed based on the channel image, that is, based on the correspondence between the channel image and the image to be processed, to obtain at least one adjusted boundary region.
[0112] In a feasible implementation, the electronic device adjusts the shape of each boundary region in the image to be processed based on the channel image, that is, based on the correspondence between the channel image and the image to be processed, to obtain at least one adjusted boundary region.
[0113] Based on this, in an embodiment of the present application, the relevant information of each boundary area is adjusted, and the relevant information includes but is not limited to: the position information, size information and shape information of each boundary area in the image to be processed.
[0114] It should be noted that the boundary area and the adjusted boundary area may be the same or different, and this is not limited in any way in the embodiments of the present application.
[0115] Step 207: Based on the at least one adjusted boundary region, perform image segmentation on the image to be processed to determine a target region of the object to be detected in the image to be processed.
[0116] In an embodiment of the present application, the electronic device performs image segmentation on the image to be processed based on at least one adjusted boundary area, and determines a target area of the object to be detected in the image to be processed.
[0117] Among them, the electronic device performs image segmentation, i.e., region segmentation, on the image to be processed based on at least one adjusted boundary area, so as to divide the image to be processed into a target area and a sample area; wherein the target area is the position area where the object to be detected is located in the image to be processed, and correspondingly, the sample area is the area that is not the position area in the image to be processed.
[0118] It should be noted that the target area is the location area of the object to be detected in the image to be processed. Accordingly, the size and shape of the target area correspond to the specific attributes of the object to be detected.
[0119] It should be noted that by adjusting each boundary area to determine more accurate boundary information, namely the adjusted boundary area, and based on the adjusted boundary area, performing image segmentation on the image to be processed, the target area position of the object to be detected in the image to be processed can be determined more accurately, thereby improving the accuracy and efficiency of extracting the object to be detected from the target area, and at the same time reducing the error rate of determining whether the object to be detected is a standard object.
[0120] The image detection method provided by the embodiment of the present application determines the corresponding color channel by determining the color parameters corresponding to each boundary area of the image to be processed of the object to be detected, so that the parameters on which the color channel depends are determined to be more comprehensive, and the labor cost and time cost of determining the auxiliary light source for segmenting the image to be processed can be saved; at the same time, based on the channel image corresponding to the color channel, each boundary area in the image to be processed is adjusted, and based on the adjusted boundary area, the image to be processed is segmented to determine the target area of the object to be detected, which can make the determined target area more accurate, thereby improving the accuracy and efficiency of extracting the object to be detected from the target area, and at the same time can reduce the error rate of determining whether the object to be detected is a standard object.
[0121] Based on the above embodiments, the present application also provides an image detection method, which is applied to electronic equipment, referring to Figures 1 to 3 The steps shown are explained below:
[0122] Step 301: extract the object to be detected from the target area.
[0123] In an embodiment of the present application, the electronic device extracts an object to be detected from a target area; wherein the target area is determined based on at least one adjusted boundary area; and the target area includes but is not limited to the object to be detected.
[0124] The method used by the electronic device to extract the object to be detected from the target area is not limited in any way in the embodiments of the present application.
[0125] Step 302: extract the reference object based on the acquired sample image.
[0126] In an embodiment of the present application, the electronic device acquires a sample image and extracts a reference object from the sample image; wherein the sample image matches the image to be processed, and the object to be detected corresponds to the reference object.
[0127] It should be noted that the sample image is an image stored in the database and used for comparison and analysis with the image to be processed; the specific format, expression form, etc. of the sample image are not limited in the embodiments of the present application.
[0128] Accordingly, the method used by the electronic device to obtain the sample image and extract the reference object from the sample image may be the same as the method used to obtain the image to be processed and extract the object to be detected from the image to be processed, or may be different, and no limitation is imposed on this in the embodiments of the present application.
[0129] Step 303: Based on the object to be detected and the reference object, determine whether the object to be detected is a standard object.
[0130] In the embodiment of the present application, the electronic device determines whether the object to be detected is a standard object based on the respectively acquired object to be detected and the reference object.
[0131] It should be noted that there is a corresponding relationship between the standard object, the reference object and the object to be detected; in a feasible implementation method, the standard object can be an object whose similarity with the reference object meets a certain threshold. At the same time, the degree of association between the object to be detected and the standard object is not limited in the embodiments of the present application.
[0132] It should be noted that by comparing with the reference object in the sample image, it is determined whether the object to be detected extracted from the target area is a standard object. In this way, there is a reference basis for judging the object to be detected, thereby reducing the error rate of determining whether the object to be detected is a standard object.
[0133] In a feasible implementation, the electronic device performs a similarity comparison between the object to be detected and the reference object, and determines whether the object to be detected meets relevant standards based on the similarity comparison result, that is, determines whether the object to be detected is a standard object.
[0134] In a feasible implementation, when the electronic device executes step 303, it can also be implemented by the following steps 303a to 303b:
[0135] Step 303a: perform a similarity comparison between the object to be detected and the reference object to obtain a comparison result.
[0136] In a feasible implementation, the electronic device compares the color parameters of the object to be detected and the reference object to obtain a comparison result.
[0137] In another feasible implementation, the electronic device compares the size parameters of the object to be detected and the reference object to obtain a comparison result.
[0138] In another feasible implementation, the electronic device compares the morphological parameters of the object to be detected and the reference object to obtain a comparison result.
[0139] Based on this, the electronic device can compare the color parameters and / or size parameters and / or shape parameters and other related information of the object to be detected and the reference object to obtain a comparison result.
[0140] The comparison result may be expressed as a numerical value, such as 80%, 90%, etc., or as a text description, such as not quite a match, very much a match, etc., and this is not limited in any way in the embodiments of the present application.
[0141] Step 303b: When the comparison result is greater than or equal to a preset threshold, the object to be detected is determined to be a standard object.
[0142] In the embodiment of the present application, the electronic device determines that the object to be detected is a standard object when the comparison result is greater than or equal to a preset threshold, that is, the similarity between the object to be detected and the reference object meets the preset threshold.
[0143] Among them, the preset threshold can be determined by the electronic device based on a preset strategy, or it can be input into the electronic device by a technician operating the electronic device through an external input device. The specific source and specific value of the preset threshold are not limited in any way in the embodiments of the present application.
[0144] In a feasible implementation, when the comparison result is greater than or equal to a preset threshold, the electronic device determines that the object to be detected is a standard object and marks the object to be detected as passed.
[0145] In another feasible implementation, when the comparison result is less than a preset threshold, the electronic device determines that the object to be detected is not a standard object and marks the object to be detected as failed.
[0146] It should be noted that in the embodiment of the present application, by comparing with the reference object of the sample image and comparing the comparison result with the preset threshold, it is determined whether the object to be detected extracted from the target area is a standard object. In this way, there is a reference basis for judging the object to be detected, thereby reducing the error rate of determining whether the object to be detected is a standard object.
[0147] The image detection method provided by the embodiment of the present application determines the corresponding color channel by determining the color parameters corresponding to each boundary area of the image to be processed of the object to be detected, so that the parameters on which the color channel depends are determined to be more comprehensive, and the labor cost and time cost of determining the auxiliary light source for segmenting the image to be processed can be saved; at the same time, based on the channel image corresponding to the color channel, each boundary area in the image to be processed is adjusted, and based on the adjusted boundary area, the image to be processed is segmented to determine the target area of the object to be detected, which can make the determined target area more accurate, thereby improving the accuracy and efficiency of extracting the object to be detected from the target area; at the same time, by comparing with the reference object of the sample image, it is determined whether the object to be detected extracted from the target area is a standard object, which can reduce the error rate of determining whether the object to be detected is a standard object.
[0148] Based on the above embodiment, when the electronic device executes step 104, that is, the electronic device performs image acquisition on the image to be processed based on the color channel to obtain the channel image, it can also be implemented by following steps A1 to A2:
[0149] Step A1: determine the adjustment light source corresponding to the color channel.
[0150] In an embodiment of the present application, the electronic device determines the corresponding adjustment light source that matches the color channel based on the color channel; in a feasible implementation, when the color channel is red, the electronic device determines the red adjustment light source corresponding to the color channel.
[0151] Among them, the adjustment of the irradiation angle, light intensity, and light texture of the light source is not limited in any way in the embodiments of the present application.
[0152] Step A2: adjusting the light source, performing image acquisition on the image to be processed, and obtaining a channel image.
[0153] In an embodiment of the present application, the electronic device adjusts the light source to illuminate the image to be processed and simultaneously captures the image to be processed to obtain a channel image; wherein, the specific description of the channel image can refer to the above description and will not be repeated here.
[0154] In a feasible implementation, the electronic device uses a red adjustment light source to illuminate the image to be processed and simultaneously collects the image to be processed to obtain a channel image.
[0155] In another feasible implementation, the electronic device uses a red adjustment light source and a blue adjustment light source to jointly illuminate the image to be processed, and at the same time, performs image acquisition on the image to be processed to obtain a channel image.
[0156] It should be noted that in the embodiment of the present application, the electronic device performs image acquisition on the image to be processed based on the determined adjusted light source to obtain a channel image. In this way, the color light source corresponding to the color channel is determined as the auxiliary light source for segmenting the image to be processed, which can avoid the operation link in the relative technology that requires technicians to manually select the auxiliary light source, thereby saving the labor cost and time cost of determining the auxiliary light source for segmenting the image to be processed.
[0157] Based on this, Figure 4 As shown, it is a flow chart of an image detection method applied to a production line provided by an embodiment of the application; wherein 401 is to obtain an image to be processed, corresponding to the electronic device provided in the embodiment of the application obtaining an image to be processed containing an object to be detected; 402 is to determine a boundary area from the image to be processed, that is, corresponding to the embodiment of the application, the electronic device determines a marking area from the image to be processed, and further determines at least one boundary area based on the marking area; 403 is to determine the color channel of the boundary area, and accordingly, 404 is to determine the light source corresponding to the color channel; after executing 401 to 404, the electronic device determines the corresponding production auxiliary After the light source, the specific application on the production line begins, that is, first execute 405, start; secondly, execute 406, use the light source to determine the channel image, and execute 407, determine the target area, that is, the electronic device performs image segmentation on the image to be processed based on the channel image to determine the target area; then, execute 408, extract the object to be detected from the target area; finally, execute 409, compare and determine the result, that is, the electronic device compares the object to be detected with the reference object in the sample image to determine whether the object to be detected is a standard object; accordingly, after the electronic device obtains a new image to be processed, 405 to 409 can be directly executed.
[0158] At the same time, when the electronic device executes the above 401 to 409, it can be divided into five major steps: Step 1, collect images through natural light, that is, obtain the image to be processed; Step 2, determine the boundary area through the target detection algorithm, that is, locate and segment the ROI and the surrounding area corresponding to the ROI; Step 3, analyze the color distribution of the boundary area, and select the channel corresponding to the color that occupies the main part as the color channel; Step 4, collect the image to be processed through the light source corresponding to the color channel to obtain a channel image, that is, a grayscale image; Step 5, based on the channel image, perform image segmentation on the image to be processed, and extract the object to be detected for relevant comparison to obtain the detection result.
[0159] Accordingly, if Figure 5 As shown, it is a schematic diagram of a process of applying an image detection method provided in an embodiment of the present application to actual production; first, 501 is image acquisition, which corresponds to Figure 4The natural light collected image in obtains the relevant logo image to be detected to obtain 502; at the same time, the electronic device performs target detection on the image in 502 to intercept the ROI corresponding to the logo and the surrounding area of ROI, wherein 5022 refers to ROI, and correspondingly, the surrounding area of 5022, namely 5021, refers to the surrounding area of ROI; secondly, the electronic device counts the color parameters corresponding to the surrounding area of ROI to obtain a color distribution diagram, as shown in 503, and then through the color histogram analysis, it is obtained that 504, the surrounding area of ROI is mainly distributed in red; then 505 is executed, in actual production, the red light source corresponding to the red channel is used to filter the image collected by natural light, so as to obtain Figure 4 The corresponding channel image is obtained so that the electronic device can later execute 506, that is, loop sampling, segmentation and comparison, etc.; accordingly, after the electronic device repeatedly obtains new images to be processed multiple times, that is, after executing 501, it can directly execute 505 to 506.
[0160] Based on the above embodiments, the present application also provides an image detection device 6, which can be applied to Figures 1 to 3 In an image detection method provided in a corresponding embodiment, referring to Figure 6 As shown, the image detection device 6 may include: an acquisition module 61, a first determination module 62, a collection module 63 and a second determination module 64, wherein:
[0161] An acquisition module 61 is used to acquire an image to be processed containing an object to be detected;
[0162] A first determination module 62, used to determine an image area of the object to be detected in the image to be processed;
[0163] The first determination module 62 is further used to determine, in the image area, a color channel whose color proportion is greater than or equal to a preset distribution ratio;
[0164] An acquisition module 63 is used to acquire the image to be processed based on the color channel to obtain a channel image;
[0165] A second determination module 64 is used to perform image segmentation on the image to be processed based on the channel image, and determine a target area of the object to be detected in the image to be processed;
[0166] The second determination module 64 is further configured to determine whether the object to be detected is a standard object based on the target area.
[0167] In other embodiments of the present application, the first determination module 62 is further used to determine an identification area of the object to be detected in the image to be processed; based on the identification area, determine at least one boundary area; wherein the image area includes at least one boundary area.
[0168] In other embodiments of the present application, the first determination module 62 is also used to determine the color parameters of each boundary area; determine a color parameter set based on the color parameters of each boundary area; and from the color parameter set, determine the channel corresponding to the color parameter whose proportion is greater than or equal to a preset distribution ratio as the color channel.
[0169] In other embodiments of the present application, the acquisition module 63 is also used to determine the adjustment light source corresponding to the color channel; the adjustment light source is used to perform image acquisition on the image to be processed to obtain a channel image.
[0170] In other embodiments of the present application, the second determination module 64 is also used to adjust each boundary area based on the channel image to obtain at least one adjusted boundary area; based on the at least one adjusted boundary area, perform image segmentation on the image to be processed to determine the target area of the object to be detected in the image to be processed.
[0171] In other embodiments of the present application, the second determination module 64 is further used to extract the object to be detected from the target area; extract the reference object based on the acquired sample image; and determine whether the object to be detected is a standard object based on the object to be detected and the reference object.
[0172] In other embodiments of the present application, the second determination module 64 is further used to perform a similarity comparison between the object to be detected and the reference object to obtain a comparison result; when the comparison result is greater than or equal to a preset threshold, the object to be detected is determined to be a standard object.
[0173] It should be noted that the specific implementation process of the steps executed by each module in this embodiment can be referred to Figures 1 to 3 The implementation process of the image detection method provided in the corresponding embodiment will not be repeated here.
[0174] The image detection device provided in the embodiment of the present application determines the corresponding color channel by determining the color parameters corresponding to each boundary area of the image to be processed of the object to be detected, so that the parameters on which the color channel depends are determined to be more comprehensive, and the labor cost and time cost of determining the auxiliary light source for segmenting the image to be processed can be saved; at the same time, based on the channel image corresponding to the color channel, each boundary area in the image to be processed is adjusted, and based on the adjusted boundary area, the image to be processed is segmented to determine the target area of the object to be detected, which can make the determined target area more accurate, thereby improving the accuracy and efficiency of extracting the object to be detected from the target area; at the same time, by comparing with the reference object of the sample image, it is determined whether the object to be detected extracted from the target area is a standard object, which can reduce the error rate of determining whether the object to be detected is a standard object.
[0175] Based on the above embodiments, the embodiments of the present application further provide an electronic device 7, which can be applied to Figures 1 to 3 In an image detection method provided in a corresponding embodiment, referring to Figure 7 As shown, the electronic device 7 may include: a processor 71, a memory 72, and a communication bus 73, wherein:
[0176] The communication bus 73 is used to implement the communication connection between the processor 71 and the memory 72 .
[0177] The processor 71 is used to execute the program of the image detection method stored in the memory 72 to realize the reference Figures 1 to 3 The corresponding embodiment provides an image detection method.
[0178] The electronic device provided in the embodiment of the present application determines the corresponding color channel by determining the color parameters corresponding to each boundary area of the image to be processed of the object to be detected, so that the parameters on which the color channel depends are determined to be more comprehensive, and the labor cost and time cost of determining the auxiliary light source for segmenting the image to be processed can be saved; at the same time, based on the channel image corresponding to the color channel, each boundary area in the image to be processed is adjusted, and based on the adjusted boundary area, the image to be processed is segmented to determine the target area of the object to be detected, which can make the determined target area more accurate, thereby improving the accuracy and efficiency of extracting the object to be detected from the target area; at the same time, by comparing with the reference object of the sample image, it is determined whether the object to be detected extracted from the target area is a standard object, which can reduce the error rate of determining whether the object to be detected is a standard object.
[0179] Based on the foregoing embodiments, the embodiments of the present application provide a computer-readable storage medium, which stores one or more programs, and the one or more programs can be executed by one or more processors to implement the following. Figures 1 to 3 The corresponding embodiments provide steps of the image detection method.
[0180] It should be noted that the above-mentioned computer-readable storage medium can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), a magnetic random access memory (FRAM), a flash memory (Flash Memory), a magnetic surface memory, an optical disc, or a compact disc read-only memory (CD-ROM) and other memories; it can also be various electronic devices including one or any combination of the above-mentioned memories, such as mobile phones, computers, tablet devices, personal digital assistants, etc.
[0181] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.
[0182] The serial numbers of the above-mentioned embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.
[0183] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course, by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, a magnetic disk, or an optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to execute the methods described in each embodiment of the present application.
[0184] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0185] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0186] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0187] The above are only preferred embodiments of the present application, and are not intended to limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the present application specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present application.
Claims
1. An image detection method, the method include: Acquire an image to be processed containing an object to be detected; Determining an image area of the object to be detected in the image to be processed; In the image area, determining a color channel whose color proportion is greater than or equal to a preset distribution ratio; Based on the color channel, performing image acquisition on the image to be processed to obtain a channel image; Adjusting the image region according to the corresponding relationship between the channel image and the image to be processed; Based on the adjusted image area, performing image segmentation on the image to be processed to determine a target area of the object to be detected in the image to be processed; Based on the target area, it is determined whether the object to be detected is a standard object.
2. The method according to claim 1, wherein the determining the image area of the object to be detected in the image to be processed, include: Determine a marking area of the object to be detected in the image to be processed; Based on the identification area, at least one boundary area is determined; wherein the image area includes at least one boundary area.
3. The method according to claim 2, wherein in the image area, a color channel having a color proportion greater than or equal to a preset distribution ratio is determined, include: determining a color parameter of each of the boundary regions; Determining a color parameter set based on the color parameter of each of the boundary regions; From the color parameter set, a channel corresponding to a color parameter whose proportion is greater than or equal to the preset distribution ratio is determined as the color channel.
4. The method according to claim 1, wherein the image to be processed is collected based on the color channel to obtain a channel image, include: Determining an adjustment light source corresponding to the color channel; The adjusted light source is used to collect the image to be processed to obtain the channel image.
5. The method according to claim 2, wherein the image to be processed is segmented based on the adjusted image area to determine the target area of the object to be detected in the image to be processed, include: Based on the channel image, adjusting each of the boundary regions to obtain at least one adjusted boundary region; Based on at least one of the adjusted boundary regions, the image to be processed is segmented to determine a target region of the object to be detected in the image to be processed.
6. The method according to claim 1, wherein the step of determining whether the object to be detected is a standard object based on the target area, include: Extracting the object to be detected from the target area; Extracting a reference object based on the acquired sample image; Based on the object to be detected and the reference object, it is determined whether the object to be detected is the standard object.
7. The method according to claim 6, wherein the step of determining whether the object to be detected is the standard object based on the object to be detected and the reference object, include: Performing a similarity comparison between the object to be detected and the reference object to obtain a comparison result; When the comparison result is greater than or equal to a preset threshold, the object to be detected is determined to be the standard object.
8. An image detection device, the image detection device include: An acquisition module, a first determination module, a collection module, and a second determination module; wherein: The acquisition module is used to acquire the image to be processed containing the object to be detected; The first determination module is used to determine the image area of the object to be detected in the image to be processed; The first determination module is further used to determine, in the image area, a color channel whose color proportion is greater than or equal to a preset distribution ratio; The acquisition module is used to acquire the image to be processed based on the color channel to obtain a channel image; The second determining module is used to adjust the image area according to the corresponding relationship between the channel image and the image to be processed; The second determination module is further used to perform image segmentation on the image to be processed based on the adjusted image area, and determine a target area of the object to be detected in the image to be processed; The second determination module is further configured to determine whether the object to be detected is a standard object based on the target area.
9. An electronic device, include: processor, memory, and communication bus; The communication bus is used to realize the communication connection between the processor and the memory; The processor is used to execute the program in the memory to implement the image detection method according to any one of claims 1 to 7.
10. A computer-readable storage medium storing one or more programs, wherein the one or more programs can be executed by one or more processors to implement the steps of the image detection method according to any one of claims 1 to 7.
