Disclosure of Invention
In view of this, the present application provides an image processing method, an image processing apparatus, an image processing medium, an image processing device, and an image processing system, and mainly aims to solve the problem that the existing image processing method has a low accuracy in detecting defects of an image with relatively complex interference.
According to an aspect of the present application, there is provided an image processing method including:
acquiring a plurality of original images containing semantic segmentation objects, cutting each original image to obtain a plurality of subgraphs corresponding to each original image, merging the plurality of subgraphs corresponding to each original image according to a preset arrangement rule, and generating a merged graph corresponding to each original image;
taking the combined image corresponding to each original image as an input image of one channel, and performing multi-channel image transformation on the basis of the combined image corresponding to each original image to obtain a variable-dimension image;
obtaining defect position information in the variable-dimension image through a trained neural network model;
and acquiring the defect characteristics of the variable-dimension image based on the defect position information in the variable-dimension image, and determining the defect type of the semantic segmentation object according to the defect characteristics.
Optionally, the performing multi-channel image transformation based on the merged image corresponding to each original image to obtain a variable-dimension image includes:
and performing multi-channel image transformation on the merged image corresponding to each original image by adopting a Reshape transformation method to obtain a variable-dimension image.
Optionally, the obtaining the defect feature of the variable-dimension image based on the defect position information in the variable-dimension image includes:
and calculating an operator based on the defect position information and a preset defect characteristic to obtain the defect characteristic of the variable-dimension image.
Optionally, the determining a defect type of the semantic segmentation object according to the defect feature includes:
dividing the defect characteristics into key characteristics of the target defects and constraint characteristics of the target defects according to the judgment conditions of the defect types;
determining the defect type to which the target defect belongs according to the key characteristics of the target defect;
and when the constraint characteristic of the target defect meets the constraint condition of the defect type, the target defect is a defect corresponding to the defect type.
Optionally, the determining, according to the key feature of the target defect, a defect type to which the target defect belongs includes:
and determining the defect type to which the target defect belongs according to the key characteristics of the target defect and a preset defect type classification table.
Optionally, when the constraint feature of the target defect satisfies the constraint condition of the defect type, after the target defect is a defect corresponding to the defect type, the image processing method further includes:
and determining the defect grade corresponding to the target defect according to the key characteristics of the target defect.
Optionally, after determining the defect type to which the target defect belongs according to the key feature of the target defect, the image processing method further includes:
and when the constraint characteristic of the target defect does not meet the constraint condition of the defect type, the target defect is a non-defect.
Optionally, the key features of the target defect include at least one of length, width, aspect ratio, length-to-width mean, contrast, and area.
Optionally, the determining a defect type of the semantic segmentation object according to the defect feature includes:
comparing the defect characteristics with a preset defect characteristic classification table;
and determining the defect type and defect grade of the semantic segmentation object according to the comparison result.
Optionally, after determining the defect type and the defect classification of the semantic segmentation object, the image processing method further includes:
and screening the target detection object according to the defect type, defect classification and preset requirements of the semantic segmentation object.
Optionally, the trained neural network model includes an input layer, a convolutional layer, and a decision layer, which are connected in sequence, where the convolutional layer includes a plurality of down-sampling layers and a plurality of up-sampling layers, and an attention mechanism layer is added between every two down-sampling layers and between every two up-sampling layers.
Optionally, the image processing method further comprises:
obtaining a plurality of subgraphs corresponding to each original image;
performing confidence calculation on each subgraph to obtain a confidence subgraph of each subgraph;
merging the multiple confidence coefficient subgraphs corresponding to each original image according to a preset arrangement rule to generate a confidence coefficient merged graph corresponding to each original image;
and taking the confidence coefficient merged image corresponding to each original image as an input image of one channel, and performing multi-channel image transformation on the basis of the confidence coefficient merged image corresponding to each original image to obtain a defect segmentation image.
Optionally, the performing confidence computation on each subgraph to obtain a confidence subgraph of each subgraph includes:
and (4) performing confidence calculation on each subgraph by using a softmax activation function, and acquiring a confidence subgraph of each subgraph.
According to another aspect of the present application, there is provided an image processing method apparatus, including:
the merged image obtaining module is used for obtaining a plurality of original images containing semantic segmentation objects, cutting each original image to obtain a plurality of sub-images corresponding to each original image, merging the plurality of sub-images corresponding to each original image according to a preset arrangement rule, and generating a merged image corresponding to each original image;
the variable-dimension image acquisition module is used for taking the combined image corresponding to each original image as an input image of one channel, and performing multi-channel image transformation based on the combined image corresponding to each original image to obtain a variable-dimension image;
the defect position information acquisition module is used for acquiring defect position information in the variable-dimension image through the trained neural network model;
and the defect type determining module is used for obtaining the defect characteristics of the variable-dimension image based on the defect position information in the variable-dimension image and determining the defect type of the semantic segmentation object according to the defect characteristics.
Optionally, the performing multi-channel image transformation based on the merged image corresponding to each original image to obtain a variable-dimension image includes:
and performing multi-channel image transformation on the merged image corresponding to each original image by adopting a Reshape transformation method to obtain a variable-dimension image.
Optionally, the obtaining the defect feature of the variable-dimension image based on the defect position information in the variable-dimension image includes:
and calculating an operator based on the defect position information and preset defect characteristics to obtain the defect characteristics of the variable-dimension image.
Optionally, the determining a defect type of the semantic segmentation object according to the defect feature includes:
dividing the defect characteristics into key characteristics of the target defects and constraint characteristics of the target defects according to the judgment conditions of the defect types;
determining the defect type to which the target defect belongs according to the key characteristics of the target defect;
and when the constraint characteristic of the target defect meets the constraint condition of the defect type, the target defect is a defect corresponding to the defect type.
Optionally, the determining, according to the key feature of the target defect, a defect type to which the target defect belongs includes:
and determining the defect type to which the target defect belongs according to the key characteristics of the target defect and a preset defect type classification table.
Optionally, when the constraint feature of the target defect satisfies the constraint condition of the defect type, after the target defect is a defect corresponding to the defect type, the image processing method further includes:
and determining the defect grade corresponding to the target defect according to the key characteristics of the target defect.
Optionally, after determining the defect type to which the target defect belongs according to the key feature of the target defect, the image processing method further includes:
and when the constraint characteristic of the target defect does not meet the constraint condition of the defect type, the target defect is a non-defect.
Optionally, the key features of the target defect include at least one of length, width, aspect ratio, length-to-width mean, contrast, and area.
Optionally, the determining a defect type of the semantic segmentation object according to the defect feature includes:
comparing the defect characteristics with a preset defect characteristic classification table;
and determining the defect type and defect grade of the semantic segmentation object according to the comparison result.
Optionally, after determining the defect type and defect grade of the semantic segmentation object, the image processing method further includes:
and screening the target detection object according to the defect type, defect classification and preset requirements of the semantic segmentation object.
Optionally, the trained neural network model includes an input layer, a convolutional layer, and a decision layer, which are connected in sequence, where the convolutional layer includes a plurality of downsampling layers and a plurality of upsampling layers, and an attention mechanism layer is added between every two downsampling layers and between every two upsampling layers.
Optionally, the image processing method further comprises:
obtaining a plurality of subgraphs corresponding to each original image;
performing confidence calculation on each subgraph to obtain a confidence subgraph of each subgraph;
merging the multiple confidence coefficient subgraphs corresponding to each original image according to a preset arrangement rule to generate a confidence coefficient merged graph corresponding to each original image;
and taking the confidence coefficient combination image corresponding to each original image as an input image of one channel, and performing multi-channel image transformation on the basis of the confidence coefficient combination image corresponding to each original image to obtain a defect segmentation image.
Optionally, the performing confidence computation on each subgraph to obtain a confidence subgraph of each subgraph includes:
and (4) solving the confidence coefficient of each subgraph by adopting a softmax activation function, and acquiring the confidence coefficient subgraph of each subgraph.
According to another aspect of the present application, a storage medium is provided, where at least one executable instruction is stored, and the executable instruction causes a processor to perform operations corresponding to the image processing method.
According to another aspect of the present application, there is provided a computer device including: the system comprises a processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface are communicated with each other through the communication bus;
the memory is used for storing at least one executable instruction, and the executable instruction enables the processor to execute the operation corresponding to the image processing method.
According to another aspect of the present application, a defect detection system is provided, and the defect detection system includes an image acquisition device and a computer device, and the computer device is used for implementing corresponding operations of the image processing method.
By means of the technical scheme, the technical scheme provided by the embodiment of the application at least has the following advantages:
according to the image processing method, the device, the medium, the equipment and the system, the multiple original images are subjected to multi-channel transformation to obtain a variable-dimension image, the trained neural network model is used for obtaining the defect characteristics in the variable-dimension image, the defect types are determined based on the defect characteristics, the multiple original images can represent the defect information more accurately and abundantly, the defect information is enhanced through the multi-channel transformed variable-dimension image, and the variable-dimension image is used as the input data of the trained neural network model, so that the input data of the trained neural network model has more abundant defect information, the output defect characteristics are identified accurately, the determined defect types are more accurate, and the defect detection accuracy is improved.
The foregoing description is only an overview of the technical solutions of the present application, and the present application can be implemented according to the content of the description in order to make the technical means of the present application more clearly understood, and the following detailed description of the present application is given in order to make the above and other objects, features, and advantages of the present application more clearly understandable.
Detailed Description
The present application will be described in detail below with reference to the accompanying drawings in conjunction with embodiments. It should be noted that the embodiments and features of the embodiments in the present application may be combined with each other without conflict.
To further explain the technical means and effects of the present application for achieving the intended purpose, the following detailed description of the embodiments, structures, features and effects according to the present application will be made with reference to the accompanying drawings and preferred embodiments. In the following description, different "one embodiment" or "an embodiment" refers to not necessarily the same embodiment. Furthermore, the particular features, structures, or characteristics may be combined in any suitable manner in one or more embodiments.
Aiming at the problem that the defect detection accuracy of the existing image processing method on the image with complex interference is low, the embodiment of the application provides an image processing method, as shown in fig. 1, the method comprises the following steps:
102: acquiring a plurality of original images containing semantic segmentation objects, cutting each original image to obtain a plurality of subgraphs corresponding to each original image, merging the plurality of subgraphs corresponding to each original image according to a preset arrangement rule to generate a merged graph corresponding to each original image;
in the prior art, conventional methods detect and identify defects on the object under test such as: SP (service provider) scratching, ink scratching, platform scratching, BG (color Block) heterochrosis, platform stamping and the like, the background interference is complex, the defects are difficult to segment from the background by the conventional image detection method, so that the defect of complex background interference cannot be solved, and the image processing difficulty is high and the efficiency is low. The semantic segmentation can detect and recognize any shape, and the semantic segmentation object is the shape capable of detecting and recognizing. The application provides and adopts a plurality of original images, because original images can be abundanter and become the sign defect information, be convenient for discern the defect, carry out the multichannel transform with a plurality of original images simultaneously and obtain a variable dimension image, make the variable dimension image further richen defect information behind the multichannel transform to further improve defect identification's the degree of accuracy.
In this embodiment, each original image is cropped according to a preset cropping rule to obtain a plurality of subgraphs corresponding to each original image, and the plurality of subgraphs corresponding to each original image are merged according to a preset arrangement rule to generate a merged graph corresponding to each original image.
104: taking the combined image corresponding to each original image as an input image of one channel, and performing multi-channel image transformation on the basis of the combined image corresponding to each original image to obtain a variable-dimension image;
in an embodiment of the present application, performing multi-channel image transformation based on a merged image corresponding to each original image to obtain a variable-dimension image, includes:
and performing multi-channel image transformation on the merged image corresponding to each original image by adopting a Reshape transformation method to obtain a variable-dimension image.
In the existing method, each original image is taken as a channel, and the original images of four channels are superposed together to be taken as spiritThe input of images via the network model results in the neural network model not being able to accurately learn the characteristics of the defect locations in the images. Therefore, a method for Reshape transformation is proposed, which is to transform data into
Is converted into
And then input into a neural network model, which can accurately learn the characteristics of the defect locations in the image.
106: obtaining defect position information in the variable-dimension image through the trained neural network model;
and selecting the imaged detected defect image as a data set, cutting the detected defect image containing the defect to obtain a plurality of small images, and labeling the defect in the small images so that the neural network model can accurately obtain the defect characteristics according to the labeling information.
Specifically, if the quality of the data set is poor, the labeling condition is not satisfied, and labeling is not needed. Including but not limited to the following: if the original picture is fuzzy, not marking; and if the data is repeatedly marked with the first picture, the data is not repeatedly marked. In general, for evaluating the quality of a model, a sample data set needs to be divided into two parts, wherein one part is a training set and is used for training the model; one part is a test set, and the model is tested; generally, no overlapping part exists between the two test sets, and the training set and the test set are divided uniformly and randomly as much as possible.
The image annotation provides two modes of brush annotation and line segment annotation. If the defect is larger, the shape of the defect is outlined by using line segment marking, and then fine modification is carried out. If the defects are small, the image can be finely marked by using a brush after being amplified; note that after re-labeling, the labeled image segments are observed to be as smooth as possible, and the smoothness improves the subsequent training precision to a certain extent.
And training the neural network model based on the data set to obtain the trained neural network model.
In one embodiment of the present application, the trained neural network model includes an input layer, a convolutional layer and a decision layer connected in sequence, where the convolutional layer includes a plurality of down-sampling layers and a plurality of up-sampling layers, and an attention mechanism layer is added between every two down-sampling layers and between every two up-sampling layers.
Specifically, the variable-dimension image is transmitted to the convolutional layer after entering from the input layer, the defect position is obtained after the convolutional layer is processed, the decision layer is output, and the decision layer outputs the defect position.
The convolutional layer includes a downsampling portion and an upsampling portion. And a downsampling part which consists of a3 multiplied by 3 convolutional layer and 1 maximal 2 multiplied by 2 pooling layer to form a downsampled module.
When the input image size is 512 × 512 × 3, the specific implementation is as follows:
a1, conv1: three times of convolution of 16 channels of [3,3] is carried out to obtain a primary effective characteristic layer of [512, 16], and then 2 x 2 maximum pooling is carried out to obtain a characteristic layer of [256, 16 ].
a2, conv2: and (3) carrying out three times of 16-channel convolution of [3,3] on the [256, 16] feature layers obtained by conv1 to obtain a 256,16] preliminary effective feature layer, and then carrying out 2 x 2 maximum pooling to obtain a 128,16] feature layer.
a3, conv3: and (3) carrying out 32-channel convolution for [3,3] three times on the characteristic layers of [128, 16] obtained by conv2 to obtain a preliminary effective characteristic layer of [128, 32], and then carrying out 2 x 2 maximum pooling to obtain a characteristic layer of [64, 32 ].
a4, conv4: and (4) carrying out convolution on the feature layers of [64, 32] obtained by conv3 for three times of [3,3] 32 channels to obtain a primary effective feature layer of [64, 32], and then carrying out 2X 2 maximum pooling to obtain a feature layer of [32,32 ].
a5, conv5: performing three times of [3,3] 64-channel convolution on [32,32 ] obtained by conv4 to obtain a [32, 64] preliminary effective characteristic layer, and performing 2 x 2 maximum pooling to obtain a [16, 64] characteristic layer
a6, conv6: three times of 64-channel convolution of [3,3] is performed on [16, 64] obtained by conv5 to obtain a preliminary effective feature layer of [16, 64 ].
The method and the device increase the down-sampling times and reduce the number of channels for outputting samples in each stage. Such an operation may increase the field of view of the network and learn features of a larger area, but the number of padding times in the network introduces extra noise, and the reduction of the number of channels cannot sufficiently learn the features of the defect and the background.
Specifically, after six downsampling, in order to increase the size of a picture and extract deep information, six upsampling is used, and in the process of upsampling, the number of channels of the picture is halved, which is opposite to the change of the number of feature extraction channels of a downsampling part. In order to strengthen the feature extraction network, feature fusion is carried out by utilizing the six primary effective feature layers, and the feature fusion mode is that the feature layers are up-sampled and stacked.
The specific execution mode is as follows:
a1, conv1: and performing convolution of 64 channels of [3,3] for three times on [16, 64] obtained by downsampling to obtain a primary effective characteristic layer of [16, 64], and performing 2 x 2 maximum pooling to obtain a characteristic layer of [32, 64 ].
a2, conv2: three 32-channel convolutions of [3,3] are performed on [32, 64] obtained for conv1 to obtain a preliminary valid feature layer of [32,32 ], and then 2 x 2 max pooling is performed to obtain a feature layer of [64, 32 ].
a3, conv3: and (4) carrying out convolution on [64, 32] obtained by conv2 for three times of [3,3] 32 channels to obtain a primary effective characteristic layer of [64, 32], and then carrying out 2X 2 maximum pooling to obtain a characteristic layer of [128, 32 ].
a4, conv4: and (4) carrying out three times of [3,3] 16-channel convolution on [128, 32] obtained by conv3 to obtain a [128, 16] preliminary effective characteristic layer, and then carrying out 2 x 2 maximum pooling to obtain a [256, 16] characteristic layer.
a5, conv5: performing three times of [3,3] 16-channel convolution on [256, 16] obtained by conv4 to obtain a [256, 16] preliminary effective characteristic layer, and performing 2 x 2 maximum pooling to obtain a [512, 16] characteristic layer
A6, conv6: three [3,3] 16-channel convolutions are performed on [512, 16] obtained by conv5 to obtain a preliminary valid feature layer of [521,512,16 ].
After the six-time down-sampling and six-time up-sampling processing, the obtained defect characteristics are richer, and particularly, an attention mechanism layer is added between every two down-samplings and every two up-samplings, so that the attention mechanism layer pays more attention to the area where the defect position is located, and the defect identification accuracy is improved.
108: and acquiring the defect characteristics of the variable-dimension image based on the defect position information in the variable-dimension image, and determining the defect type of the semantic segmentation object according to the defect characteristics.
In one embodiment of the present application, obtaining defect features of a variable-dimension image based on defect position information in the variable-dimension image comprises:
and calculating an operator based on the defect position information and preset defect characteristics to obtain the defect characteristics of the variable-dimension image.
Specifically, there are many defect feature calculation operators, such as a defect length calculation operator, a defect width calculation operator, a defect area calculation operator, and the like, and the defect length is calculated based on the defect position information and a preset defect length calculation operator, taking the defect length as an example. The defect information can be more abundantly represented by the variable-dimension image obtained by multi-channel transformation of a plurality of original images, so that the defect position obtained based on the variable-dimension image is more accurate, the defect characteristic calculated based on the defect position is more accurate, and the accuracy of defect detection is improved.
For further definition and explanation, in one embodiment of the present application, as shown in fig. 2, determining a defect type of a target inspection object according to a defect feature includes:
202: dividing the defect characteristics into key characteristics of the target defects and constraint characteristics of the target defects according to the judgment conditions of the defect types;
204: determining the defect type of the target defect attribution according to the key characteristics of the target defect;
206: and when the constraint characteristics of the target defects meet the constraint conditions of the defect types, the target defects are the defects corresponding to the defect types.
In this embodiment, there are many defect types, which defect type the defect belongs to is determined according to the key features of the defect, and the detected defect is a true defect or a false defect, so that it is further determined whether the defect belonging to the defect type is a true defect or a false defect, and it is further determined through the constraint feature of the defect, and when the constraint feature satisfies the constraint condition of the defect type, it is determined that the target defect belongs to the defect type. Therefore, the detection accuracy rate for solving the complex background interference is improved, and the subsequent detection universality of the defects is further improved.
In an embodiment of the present application, determining a defect type to which a target defect belongs according to a key feature of the target defect includes:
and determining the defect type to which the target defect belongs according to the key characteristics of the target defect and a preset defect type classification table.
Specifically, a preset defect type classification table is created according to common defects of a known target and experience of manual detection and defect type division, the preset defect type classification table reflects the relationship between defect types and key features corresponding to the defect types, and the defect types can be obtained according to the key features of the target defects and the preset defect type classification table.
In an embodiment of the application, when the constraint feature of the target defect satisfies the constraint condition of the defect type, and the target defect is a defect corresponding to the defect type, the image processing method further includes: and determining the defect grade corresponding to the target defect according to the key characteristics of the target defect.
Specifically, when the defect is judged to be a true defect, the classification of the target defect is determined according to the key characteristics of the target defect, so that whether the target defect meets the screening condition or not is determined according to the classification of the target defect, and the detection accuracy is improved.
In an embodiment of the present application, after determining a defect type to which a target defect belongs according to a key feature of the target defect, the image processing method further includes: and when the constraint characteristic of the target defect does not meet the constraint condition of the defect type, the target defect is a non-defect.
Specifically, the detected defects are true defects and false defects, and if the false defects are detected, the detection accuracy is reduced, so that the method and the device judge the true defects or the false defects through the constraint characteristics, the target defects of which the constraint characteristics meet the constraint conditions of the defect types are the true defects, the target defects of which the constraint characteristics do not meet the constraint conditions of the defect types are the non-defects, and the true defects or the false defects are further judged through the constraint characteristics, so that the defect detection accuracy is improved.
In one embodiment of the present application, the key features of the target defect include at least one of length, width, aspect ratio average, contrast, and area.
Specifically, the key features are:
the defects are long: the length of the minimum bounding rectangle, L1 in fig. 3.
Wide (deep) defect: the width of the minimum bounding rectangle, W1 in FIG. 3.
Defect (length + width)/2: (length of the minimum bounding rectangle + width of the minimum bounding rectangle)/2, such as (L1 + W1)/2 in FIG. 3.
Defect area: the number of pixels corresponding to the defect (the area of the minimum circumscribed rectangle of the non-defect), such as the area of the black region of the image.
Defect length-width ratio: the length of the minimum bounding rectangle/the width of the minimum bounding rectangle is L1/W1 in FIG. 3.
The defect type: defects are detected by defined types, such as 0 for long shoots, 1 for short shoots, etc.
Confidence coefficient: the accuracy with which defects are identified by deep learning, 0.0 to 1.0, the greater the accuracy.
Length of the long side of the minimum circumscribed rectangle: the length of the minimum bounding rectangle, L1 in fig. 3.
Defect equivalent rectangular bone length: length of defective bone, L0 in fig. 3.
Minimum circumscribed rectangle minor face length: the width of the minimum bounding rectangle, W1 in FIG. 3.
Defect-equivalent rectangular bone width: width of the defective bone, W0 in fig. 3.
Average width of main direction of region: average width along the long side of the minimum bounding rectangle.
Area: the number of pixels corresponding to the defect (the area of the minimum circumscribed rectangle of the non-defect), such as the area of the black region in fig. 3.
Absolute difference between average gray level of defect and background:
in which
The average gray level of the defect is represented,
representing the average gray level of the background surrounding the defect.
Standard deviation of mean average gray level of defect area and background:
wherein
Represents the standard deviation of the mean gray level of the defect area and the background,
indicates the number of pixels that are defective,
indicating the gray level of a certain pixel of the defect,
representing the average gray level of the background around the defect.
In one embodiment of the present application, determining a defect type of a semantic segmentation object according to defect features includes:
comparing the defect characteristics with a preset defect characteristic classification table;
and determining the defect type and defect grade of the semantic segmentation object according to the comparison result.
In an embodiment of the application, after determining the defect type and the defect classification of the semantically segmented object, the image processing method further includes:
and screening the target detection object according to the defect type, defect classification and preset requirements of the semantic segmentation object.
Specifically, after the type and the classification of the defects are determined, the detected objects meeting the preset screening requirements are screened out, and the defects of the detected objects are marked, so that the later maintenance and the management of the detected objects are facilitated.
Compared with the prior art, the method for processing the images comprises the steps of carrying out multi-channel transformation on a plurality of original images to obtain a variable-dimension image, obtaining defect characteristics in the variable-dimension image by using a trained neural network model, determining defect types based on the defect characteristics, and further enhancing the defect information by using the multi-channel transformed variable-dimension image as well as using the variable-dimension image as input data of the trained neural network model, so that the input data of the trained neural network model has more abundant defect information, further identifying the output defect characteristics accurately, determining the defect types more accurately and improving the defect detection accuracy.
In one embodiment of the present application, the image processing method further includes:
obtaining a plurality of subgraphs corresponding to each original image;
performing confidence calculation on each subgraph to obtain a confidence subgraph of each subgraph;
merging a plurality of confidence coefficient subgraphs corresponding to each original image according to a preset arrangement rule to generate a confidence coefficient merged graph corresponding to each original image, and performing binarization processing on each confidence coefficient merged graph;
and taking the confidence coefficient merged image after binarization processing corresponding to each original image as an input image of one channel, and performing multi-channel image transformation on the basis of the confidence coefficient merged image corresponding to each original image to obtain a defect segmentation image.
The method comprises the steps of cutting a plurality of original images into images according with the size of input size during neural network model training in a crop small image mode, using the cut small images as subgraphs, obtaining the confidence coefficient of each subgraph to obtain confidence coefficient subgraphs, combining the confidence coefficient subgraphs into a confidence coefficient big image, and carrying out binarization on the confidence coefficient big image through a confidence coefficient threshold value of a segmentation image of 255 to obtain a defect segmentation image, wherein as shown in figure 4, the background in the defect segmentation image is black, white and bright areas are defects, and the defect segmentation image is convenient for a user to know the condition of visually knowing the defects.
In an embodiment of the present application, performing confidence level calculation on each subgraph, and obtaining a confidence level subgraph of each subgraph includes:
and (4) performing confidence calculation on each subgraph by using a softmax activation function, and acquiring a confidence subgraph of each subgraph.
Specifically, the output value of each pixel point in the subgraph is converted into probability distribution with the positive value and the sum of 1 through a softmax activation function, and the confidence coefficient of each class in each pixel point is obtained.
Further, as an implementation of the method shown in fig. 1, an embodiment of the present application provides an image processing apparatus, as shown in fig. 5, the apparatus includes:
a merged image obtaining module 502, configured to obtain multiple original images including semantic segmentation objects, crop each original image, obtain multiple sub-images corresponding to each original image, merge the multiple sub-images corresponding to each original image according to a preset arrangement rule, and generate a merged image corresponding to each original image;
a dimension-variable image obtaining module 504, configured to use the merged image corresponding to each original image as an input image of one channel, and perform multi-channel image transformation based on the merged image corresponding to each original image to obtain a dimension-variable image;
a defect location information obtaining module 506, configured to obtain defect location information in the dimension-variable image through the trained neural network model;
and the defect type determining module 508 is configured to obtain a defect feature of the variable-dimensional image based on the defect location information in the variable-dimensional image, and determine a defect type of the semantic segmentation object according to the defect feature.
Compared with the prior art, the image processing method and device have the advantages that the multiple original images are subjected to multi-channel transformation to obtain a variable-dimension image, the trained neural network model is used for obtaining defect characteristics in the variable-dimension image, defect types are determined based on the defect characteristics, the multiple original images can represent the defect information more accurately and abundantly, the defect information is enhanced through the multi-channel transformed variable-dimension image, and the variable-dimension image is used as input data of the trained neural network model, so that the input data of the trained neural network model has the richer defect information, the output defect characteristics are identified accurately, the determined defect types are more accurate, and the defect detection accuracy is improved.
In an embodiment of the present application, performing multi-channel image transformation based on a merged image corresponding to each original image to obtain a variable-dimension image, includes:
and performing multi-channel image transformation on the merged image corresponding to each original image by adopting a Reshape transformation method to obtain a variable-dimension image.
In one embodiment of the present application, obtaining defect features of a variable-dimensional image based on defect location information in the variable-dimensional image comprises:
and calculating an operator based on the defect position information and preset defect characteristics to obtain the defect characteristics of the variable-dimension image.
In one embodiment of the present application, determining a defect type of a semantic segmentation object according to defect features includes:
dividing the defect characteristics into key characteristics of the target defects and constraint characteristics of the target defects according to the judgment conditions of the defect types;
determining the defect type of the target defect attribution according to the key characteristics of the target defect;
and when the constraint characteristic of the target defect meets the constraint condition of the defect type, the target defect is a defect corresponding to the defect type.
In an embodiment of the present application, determining a defect type to which a target defect belongs according to a key feature of the target defect includes:
and determining the defect type to which the target defect belongs according to the key characteristics of the target defect and a preset defect type classification table.
In an embodiment of the application, when the constraint feature of the target defect satisfies the constraint condition of the defect type, and the target defect is a defect corresponding to the defect type, the image processing method further includes:
and determining the defect grade corresponding to the target defect according to the key characteristics of the target defect.
In an embodiment of the present application, after determining a defect type to which a target defect belongs according to a key feature of the target defect, the image processing method further includes:
and when the constraint characteristic of the target defect does not meet the constraint condition of the defect type, the target defect is a non-defect.
In one embodiment of the present application, the key features of the target defect include at least one of length, width, aspect ratio average, contrast, and area.
In one embodiment of the present application, determining a defect type of a semantic segmentation object according to defect features includes:
comparing the defect characteristics with a preset defect characteristic classification table;
and determining the defect type and defect grade of the semantic segmentation object according to the comparison result.
In an embodiment of the application, after determining the defect type and the defect classification of the semantic segmentation object, the image processing method further includes:
and screening the target detection object according to the defect type, defect classification and preset requirements of the semantic segmentation object.
In one embodiment of the present application, the trained neural network model includes an input layer, a convolutional layer and a decision layer connected in sequence, where the convolutional layer includes a plurality of down-sampling layers and a plurality of up-sampling layers, and an attention mechanism layer is added between every two down-sampling layers and between every two up-sampling layers.
In one embodiment of the present application, the image processing method further includes:
obtaining a plurality of subgraphs corresponding to each original image;
performing confidence calculation on each subgraph to obtain a confidence subgraph of each subgraph;
merging the multiple confidence coefficient subgraphs corresponding to each original image according to a preset arrangement rule to generate a confidence coefficient merged graph corresponding to each original image;
and taking the confidence coefficient merged image corresponding to each original image as an input image of one channel, and performing multi-channel image transformation on the basis of the confidence coefficient merged image corresponding to each original image to obtain a defect segmentation image.
In an embodiment of the present application, performing confidence level calculation on each subgraph, and obtaining a confidence level subgraph of each subgraph includes:
and (4) solving the confidence coefficient of each subgraph by adopting a softmax activation function, and acquiring the confidence coefficient subgraph of each subgraph.
According to an embodiment of the present application, there is provided a storage medium storing at least one executable instruction, where the computer executable instruction may execute the image processing method in any of the above method embodiments.
Fig. 6 is a schematic structural diagram of a computer device according to an embodiment of the present application, and the specific embodiment of the present application does not limit a specific implementation of the computer device.
As shown in fig. 6, the computer apparatus may include: a processor (processor) 602, a communication Interface 604, a memory 606, and a communication bus 608.
Wherein: the processor 602, communication interface 604, and memory 606 communicate with one another via a communication bus 608.
A communication interface 604 for communicating with network elements of other devices, such as clients or other servers.
The processor 602 is configured to execute the program 610, and may specifically execute relevant steps in the foregoing image processing method embodiments.
In particular, the program 610 may include program code comprising computer operating instructions.
The processor 602 may be a central processing unit CPU, or an Application Specific Integrated Circuit ASIC (Application Specific Integrated Circuit), or one or more Integrated circuits configured to implement embodiments of the present Application. The computer device includes one or more processors, which may be the same type of processor, such as one or more CPUs; or may be different types of processors such as one or more CPUs and one or more ASICs.
The memory 606 stores a program 610. Memory 606 may comprise high-speed RAM memory, and may also include non-volatile memory (non-volatile memory), such as at least one disk memory.
The program 610 may specifically be configured to cause the processor 602 to perform the following operations:
acquiring a plurality of original images containing semantic segmentation objects, cutting each original image to obtain a plurality of subgraphs corresponding to each original image, merging the plurality of subgraphs corresponding to each original image according to a preset arrangement rule, and generating a merged graph corresponding to each original image;
taking the combined image corresponding to each original image as an input image of one channel, and performing multi-channel image transformation based on the combined image corresponding to each original image to obtain a variable-dimension image;
obtaining defect position information in the variable-dimension image through the trained neural network model;
and acquiring the defect characteristics of the variable-dimension image based on the defect position information in the variable-dimension image, and determining the defect type of the semantic segmentation object according to the defect characteristics.
It will be apparent to those skilled in the art that the modules or steps of the present application described above may be implemented by a general purpose computing device, they may be centralized on a single computing device or distributed across a network of multiple computing devices, and in one embodiment, they may be implemented by program code executable by a computing device, such that they may be stored in a memory device and executed by a computing device, and in some cases, the steps shown or described may be executed out of order, or separately as individual integrated circuit modules, or multiple modules or steps thereof may be implemented as a single integrated circuit module. Thus, the present application is not limited to any specific combination of hardware and software.
The above embodiments are only exemplary embodiments of the present application, and are not intended to limit the present application, and the protection scope of the present application is defined by the claims. Various modifications and equivalents may be made by those skilled in the art within the spirit and scope of the present application and such modifications and equivalents should also be considered to be within the scope of the present application.