Disclosure of Invention
Accordingly, it is necessary to provide a device area image extraction method and apparatus for overcoming the defect that the appearance of the smart device is disturbed more when viewed according to the appearance image.
An apparatus region image extraction method includes the steps of:
acquiring an appearance image of the intelligent device;
performing color space conversion processing on the appearance image of the intelligent equipment to generate a corresponding gray level image;
calculating a first adaptive threshold and a second adaptive threshold of an edge detection algorithm according to the gray level image;
determining edge contour information of the gray level image by combining an edge detection algorithm, the first adaptive threshold and the second adaptive threshold;
and extracting the equipment area image of the appearance image of the intelligent equipment according to the edge contour information.
According to the method for extracting the device area image, after the appearance image of the intelligent device is obtained, the appearance image of the intelligent device is subjected to color space conversion processing to generate a corresponding gray level image, and a first self-adaptive threshold and a second self-adaptive threshold of an edge detection algorithm are calculated according to the gray level image. Further, edge contour information of the gray level image is determined by combining an edge detection algorithm, the first adaptive threshold and the second adaptive threshold, so that an equipment area image of the intelligent equipment appearance image is extracted according to the edge contour information. Based on the method, the device area image in the intelligent device appearance image can be extracted without being influenced by the edge information distribution in the intelligent device appearance image, and the interference of shooting background is eliminated, so that the recovery evaluation can be performed on the device area of the intelligent device more accurately.
In one embodiment, before the process of performing color space conversion processing on the appearance image of the smart device to generate a corresponding grayscale image, the method further includes the following steps:
gaussian filtering processing is carried out on the appearance image of the intelligent equipment;
and performing smooth filtering processing on a color layer on the appearance image of the intelligent equipment after the Gaussian filtering processing.
In one embodiment, the process of gaussian filtering the appearance image of the smart device is as follows:
wherein, X1 represents the smart device appearance image after gaussian filtering, and X represents the smart device appearance image; j 1,2, H, i 1,2, W, j and i respectively represent coordinate values in a horizontal direction and a vertical direction relative to an origin of an upper left corner in the appearance image of the smart device, H represents a height of X, and W represents a width of X; w represents the length of the rectangular window, set to 3; a represents the amplitude of the corresponding rectangular window, set to 16; the rectangular window represents a template corresponding to the Gaussian filter as follows
In one embodiment, the process of performing color-level smoothing filtering on the gaussian-filtered smart device appearance image includes the steps of:
constructing a five-dimensional sphere consisting of a space domain and a color domain; the spatial domain is two coordinates j and i of a pixel point in a physical space, the color gamut is three colors of R, G and B in a color space, and the value ranges are all [0,255 ]; the airspace radius is set to 15, and the color gamut radius is set to 20;
calculating the sum of color vectors of all points in a five-dimensional sphere space relative to any pixel point on the basis of any pixel point in the appearance image of the intelligent equipment after Gaussian filtering;
moving any pixel point of iteration to a vector end point, wherein the sum of the color vectors of any pixel point of iteration is the central point of the five-dimensional sphere;
and determining the appearance image of the intelligent equipment after smooth filtering according to the iteration result of each pixel point in the five-dimensional sphere.
In one embodiment, the process of performing color space conversion processing on the appearance image of the smart device to generate a corresponding grayscale image is as follows:
G1(j,i)=0.1140*X2b(j,i)+0.58570*X2g(j,i)+0.2989*X2r(j,i)。
where G1 represents a grayscale image and X2 represents a smart device appearance image.
In one embodiment, the process of calculating a first adaptive threshold and a second adaptive threshold of an edge detection algorithm from a gray scale image comprises the steps of:
calculating a gradient image generated from the first gradient value and the second gradient value, and a maximum value of a sum of pixel values of the same position of the first gradient value and the second gradient value;
determining a histogram of the gradient image and a maximum value of the histogram;
traversing histogram summation, stopping summation and recording an index value when the summation result is greater than a preset threshold value;
the first adaptive threshold and the second adaptive threshold are calculated based on the index value, the maximum value of the histogram, and the maximum value of the pixel value sum.
In one embodiment, the process of extracting the device region image of the smart device appearance image according to the edge contour information includes the steps of:
performing morphological expansion operation on the edge contour information to obtain final edge contour information;
and screening the device area outline of the final edge outline information as a device area image.
An apparatus area image extraction device, comprising:
the image acquisition module is used for acquiring an appearance image of the intelligent equipment;
the conversion processing module is used for performing color space conversion processing on the appearance image of the intelligent equipment to generate a corresponding gray level image;
the threshold value calculation module is used for calculating a first self-adaptive threshold value and a second self-adaptive threshold value of an edge detection algorithm according to the gray level image;
the contour calculation module is used for determining the edge contour information of the gray level image by combining an edge detection algorithm, a first self-adaptive threshold and a second self-adaptive threshold;
and the region extraction module is used for extracting the device region image of the intelligent device appearance image according to the edge contour information.
After the appearance image of the intelligent device is obtained, the device area image extracting device performs color space conversion processing on the appearance image of the intelligent device to generate a corresponding gray level image, and calculates a first adaptive threshold and a second adaptive threshold of an edge detection algorithm according to the gray level image. Further, edge contour information of the gray level image is determined by combining an edge detection algorithm, the first adaptive threshold and the second adaptive threshold, so that an equipment area image of the intelligent equipment appearance image is extracted according to the edge contour information. Based on the method, the device area image in the intelligent device appearance image can be extracted without being influenced by the edge information distribution in the intelligent device appearance image, and the interference of shooting background is eliminated, so that the recovery evaluation can be performed on the device area of the intelligent device more accurately.
A computer storage medium having stored thereon computer instructions which, when executed by a processor, implement the device region image extraction method of any of the above embodiments.
After the appearance image of the intelligent device is obtained, the computer storage medium performs color space conversion processing on the appearance image of the intelligent device to generate a corresponding gray level image, and calculates a first adaptive threshold and a second adaptive threshold of an edge detection algorithm according to the gray level image. Further, edge contour information of the gray level image is determined by combining an edge detection algorithm, the first adaptive threshold and the second adaptive threshold, so that an equipment area image of the intelligent equipment appearance image is extracted according to the edge contour information. Based on the method, the device area image in the intelligent device appearance image can be extracted without being influenced by the edge information distribution in the intelligent device appearance image, and the interference of shooting background is eliminated, so that the recovery evaluation can be performed on the device area of the intelligent device more accurately.
A computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, the processor implementing the device region image extraction method of any of the above embodiments when executing the program.
After the appearance image of the intelligent device is obtained, the computer device performs color space conversion processing on the appearance image of the intelligent device to generate a corresponding gray level image, and calculates a first adaptive threshold and a second adaptive threshold of an edge detection algorithm according to the gray level image. Further, edge contour information of the gray level image is determined by combining an edge detection algorithm, the first adaptive threshold and the second adaptive threshold, so that an equipment area image of the intelligent equipment appearance image is extracted according to the edge contour information. Based on the method, the device area image in the intelligent device appearance image can be extracted without being influenced by the edge information distribution in the intelligent device appearance image, and the interference of shooting background is eliminated, so that the recovery evaluation can be performed on the device area of the intelligent device more accurately.
Detailed Description
For better understanding of the objects, technical solutions and effects of the present invention, the present invention will be further explained with reference to the accompanying drawings and examples. Meanwhile, the following described examples are only for explaining the present invention, and are not intended to limit the present invention.
The embodiment of the invention provides an equipment area image extraction method.
Fig. 1 is a flowchart illustrating an apparatus area image extracting method according to an embodiment, and as shown in fig. 1, the apparatus area image extracting method according to an embodiment includes steps S100 to S104:
s100, acquiring an appearance image of the intelligent device;
and obtaining an appearance image of the intelligent device by shooting the intelligent device. For example, when the smart device is recycled, the device recycling terminal provides a smart device appearance image including a shooting background and a device appearance image by shooting the smart device.
S101, performing color space conversion processing on the appearance image of the intelligent device to generate a corresponding gray level image;
and performing gray level processing on the appearance image of the intelligent device through color space conversion processing to obtain a gray level image of the appearance image of the intelligent device.
In one embodiment, fig. 2 is a flowchart of a device area image extraction method according to another embodiment, and as shown in fig. 2, before the process of performing color space conversion processing on the smart device appearance image in step S101 to generate a corresponding grayscale image, the method further includes step S200 and step S201:
s200, Gaussian filtering processing is carried out on the appearance image of the intelligent device;
and removing white noise in the appearance image of the intelligent equipment through Gaussian filtering processing.
In one embodiment, the process of performing gaussian filtering on the appearance image of the smart device in step S200 is as follows:
wherein, X1 represents the smart device appearance image after gaussian filtering, and X represents the smart device appearance image; j 1,2, H, i 1,2, W, j and i respectively represent coordinate values in a horizontal direction and a vertical direction relative to an origin of an upper left corner in the appearance image of the smart device, H represents a height of X, and W represents a width of X; w represents the length of the rectangular window, set to 3; a represents the amplitude of the corresponding rectangular window, set to 16; the rectangular window represents a template corresponding to the Gaussian filter as follows
S201, carrying out smooth filtering processing on a color layer of the appearance image of the intelligent device after the Gaussian filtering processing.
And smoothing the intelligent equipment appearance image subjected to Gaussian filtering to smooth areas with similar colors in the intelligent equipment appearance image to obtain the intelligent equipment appearance image subjected to the Gaussian filtering.
In one embodiment, fig. 3 is a flowchart of a device region image extraction method according to yet another embodiment, and as shown in fig. 3, a process of performing a smoothing filter process on a color level on an appearance image of a smart device after a gaussian filter process in step S201 includes steps S300 to S303:
s300, constructing a five-dimensional sphere consisting of a space domain and a color gamut; the spatial domain is two coordinates j and i of a pixel point in a physical space, the color gamut is three colors of R, G and B in a color space, and the value ranges are all [0,255 ]; the airspace radius is set to 15, and the color gamut radius is set to 20;
first, a five-dimensional sphere consisting of a space domain and a color domain is constructed. The airspace is two coordinates j and i of a pixel point in a physical space, the color gamut is three colors of R, G, B, red, green and blue in a color space, and the value ranges are all the same. The airspace radius was set to 15 and the gamut radius was set to 20.
S301, calculating the sum of color vectors of all points in a five-dimensional sphere space relative to any pixel point on the basis of any pixel point in the appearance image of the intelligent device after Gaussian filtering;
secondly, any pixel point p in the intelligent device appearance image X1 after being processed by Gaussian filtering0Based on this, all points in the five-dimensional sphere space are calculated relative to p0Sum of color vectors p0a0。
S302, moving any pixel point of iteration to a vector end point, wherein the sum of color vectors of any pixel point of iteration is the central point of a five-dimensional sphere;
moving p in an iterative five-dimensional sphere space0To the end of the vector; the process is iterated until the vector sum of all the points in the last five-dimensional sphere space relative to the center point of the sphere is the center point p of the sphere in the spacen。
And S303, determining the appearance image of the intelligent equipment after smooth filtering according to the iteration result of each pixel point in the five-dimensional sphere.
And performing the iteration operation on each pixel point in the intelligent device appearance image X1 to obtain a final smooth filtered intelligent device appearance image X2.
In one embodiment, the process of performing color space conversion processing on the smart device appearance image in step S101 to generate a corresponding grayscale image is as follows:
G1(j,i)=0.1140*X2b(j,i)+0.58570*X2g(j,i)+0.2989*X2r(j,i)。
where G1 represents a grayscale image and X2 represents a smart device appearance image.
S102, calculating a first adaptive threshold and a second adaptive threshold of an edge detection algorithm according to the gray level image;
in one embodiment, the edge detection algorithm comprises a sobel edge detection algorithm or a Canny edge detection algorithm. As a preferred embodiment, the edge detection algorithm comprises a Canny edge detection algorithm.
In one embodiment, fig. 4 is a flowchart of an apparatus region image extraction method according to yet another embodiment, and as shown in fig. 4, the process of calculating the first adaptive threshold and the second adaptive threshold of the edge detection algorithm according to the grayscale image in step S102 includes steps S400 to S402:
firstly, acquiring a first gradient value and a second gradient value; the first gradient value is the gradient value of the gray image in the horizontal direction, and the second gradient value is the gradient value of the gray image in the vertical direction;
wherein the first gradient value GxThe following formula:
second gradient value GyThe following formula:
wherein the first gradient value GxKernel K of convolution operationxThe following formula:
second gradient value GyKernel K of convolution operationyThe following formula:
s400, calculating a gradient image generated according to the first gradient value and the second gradient value and the maximum value of the pixel value sum of the same position of the first gradient value and the second gradient value;
calculating a first gradient value GxAnd a second gradient value GyGenerated gradient image GdThe following formula:
Gd(j,i)=Gx(j,i)+Gy(j,i)
then the maximum value gv of the sum of the pixel values at the same position is given by:
gv=max(Gx(j,i)+Gy(j,i))
s401, determining a histogram of the gradient image and a maximum value of the histogram;
computing a gradient image GdHistogram of (H)dThe maximum value Hsize ═ min (gv,255) of the histogram is obtained.
S402, traversing histogram summation, stopping summation and recording an index value when the summation result is greater than a preset threshold value;
traverse histogram HdAnd (5) obtaining a sum hv, stopping the summation operation when the hv is larger than a preset threshold value t, and recording the current index value idx, wherein t is H, W and 0.77.
And S403, calculating a first adaptive threshold and a second adaptive threshold according to the index value, the maximum value of the histogram and the maximum value of the pixel value sum.
Finally, the first adaptive threshold t1 is given by:
a second adaptive threshold t2, as follows:
s103, determining edge contour information of the gray level image by combining an edge detection algorithm, the first adaptive threshold and the second adaptive threshold;
the edge detection algorithm is used for combining the first adaptive threshold t1 and the second adaptive threshold t2 to obtain edge contour information E1 of the gray-scale image G1.
And S104, extracting the equipment area image of the intelligent equipment appearance image according to the edge contour information.
In one embodiment, as shown in fig. 4, the process of extracting the device region image of the smart device appearance image according to the edge contour information in step S104 includes steps S500 and S501:
s500, performing morphological expansion operation on the edge contour information to obtain final edge contour information;
and performing morphological dilation operation on the edge contour information E1 to obtain final edge contour information E.
S501, screening out the device area outline of the final edge outline information as a device area image.
And screening the device area outline of the final edge outline information E, and storing the device area outline as a device area image for appearance detection of subsequent device recovery.
In the method for extracting an image of an equipment region in any embodiment, after the appearance image of the smart device is obtained, color space conversion processing is performed on the appearance image of the smart device to generate a corresponding grayscale image, and a first adaptive threshold and a second adaptive threshold of an edge detection algorithm are calculated according to the grayscale image. Further, edge contour information of the gray level image is determined by combining an edge detection algorithm, the first adaptive threshold and the second adaptive threshold, so that an equipment area image of the intelligent equipment appearance image is extracted according to the edge contour information. Based on the method, the device area image in the intelligent device appearance image can be extracted without being influenced by the edge information distribution in the intelligent device appearance image, and the interference of shooting background is eliminated, so that the recovery evaluation can be performed on the device area of the intelligent device more accurately.
The embodiment of the invention also provides a device for extracting the equipment area image.
Fig. 5 is a block diagram of a device region image extraction apparatus according to an embodiment, and as shown in fig. 5, the device region image extraction apparatus according to an embodiment includes a block 100, a block 101, a block 102, a block 103, and a block 104:
the image acquisition module 100 is used for acquiring an appearance image of the intelligent device;
the conversion processing module 101 is configured to perform color space conversion processing on the appearance image of the smart device to generate a corresponding grayscale image;
a threshold calculation module 102, configured to calculate a first adaptive threshold and a second adaptive threshold of an edge detection algorithm according to the grayscale image;
the contour calculation module 103 is configured to determine edge contour information of the grayscale image by combining an edge detection algorithm, the first adaptive threshold, and the second adaptive threshold;
and the region extraction module 104 is configured to extract a device region image of the smart device appearance image according to the edge contour information.
After the appearance image of the intelligent device is obtained, the device area image extracting device performs color space conversion processing on the appearance image of the intelligent device to generate a corresponding gray level image, and calculates a first adaptive threshold and a second adaptive threshold of an edge detection algorithm according to the gray level image. Further, edge contour information of the gray level image is determined by combining an edge detection algorithm, the first adaptive threshold and the second adaptive threshold, so that an equipment area image of the intelligent equipment appearance image is extracted according to the edge contour information. Based on the method, the device area image in the intelligent device appearance image can be extracted without being influenced by the edge information distribution in the intelligent device appearance image, and the interference of shooting background is eliminated, so that the recovery evaluation can be performed on the device area of the intelligent device more accurately.
The embodiment of the invention also provides a computer storage medium, on which computer instructions are stored, and the instructions are executed by a processor to implement the device region image extraction method of any one of the above embodiments.
Those skilled in the art will understand that: all or part of the steps for implementing the method embodiments may be implemented by hardware related to program instructions, and the program may be stored in a computer readable storage medium, and when executed, the program performs the steps including the method embodiments; and the aforementioned storage medium includes: various media that can store program codes, such as a removable Memory device, a Random Access Memory (RAM), a Read-Only Memory (ROM), a magnetic disk, and an optical disk.
Alternatively, the integrated unit of the present invention may be stored in a computer-readable storage medium if it is implemented in the form of a software functional module and sold or used as a separate product. Based on such understanding, the technical solutions of the embodiments of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a terminal, or a network device) to execute all or part of the methods of the embodiments of the present invention. And the aforementioned storage medium includes: a removable storage device, a RAM, a ROM, a magnetic or optical disk, or various other media that can store program code.
Corresponding to the computer storage medium, in one embodiment, a computer device is further provided, where the computer device includes a memory, a processor, and a computer program stored in the memory and executable on the processor, and the processor executes the computer program to implement any one of the device region image extraction methods in the embodiments.
After the appearance image of the intelligent device is obtained, the computer device performs color space conversion processing on the appearance image of the intelligent device to generate a corresponding gray level image, and calculates a first adaptive threshold and a second adaptive threshold of an edge detection algorithm according to the gray level image. Further, edge contour information of the gray level image is determined by combining an edge detection algorithm, the first adaptive threshold and the second adaptive threshold, so that an equipment area image of the intelligent equipment appearance image is extracted according to the edge contour information. Based on the method, the device area image in the intelligent device appearance image can be extracted without being influenced by the edge information distribution in the intelligent device appearance image, and the interference of shooting background is eliminated, so that the recovery evaluation can be performed on the device area of the intelligent device more accurately.
The technical features of the above embodiments can be arbitrarily combined, and for the sake of brevity, all possible combinations of the technical features in the above embodiments are not described, but should be considered as the scope of the present specification as long as there is no contradiction between the combinations of the technical features.
The above examples only show some embodiments of the present invention, and the description thereof is more specific and detailed, but not construed as limiting the scope of the invention. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the inventive concept, which falls within the scope of the present invention. Therefore, the protection scope of the present patent shall be subject to the appended claims.