Product defect display enhancement method, device and equipment and readable storage medium
By performing color space conversion, brightness image filtering and scaling processing on the original image of the product, the defect display enhancement image is generated, which solves the problem that product defects in the prior art are not obvious enough, and achieves a clearer defect display effect.
Patent Information
- Application Number
- CN202510238978.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-28
- Publication Date
- 2025-06-24
AI Technical Summary
When the prior art displays product defects through photometric stereoscopic methods, the defects are not obvious enough in some scenarios and display enhancement is required.
By converting the original image of the product in color space, generating the original Lab image, and generating the brightness image based on this, performing edge-keeping filtering, determining the brightness difference image, calculating the scaling coefficient, scaling the brightness difference image, performing data cropping, and finally generating a defect display enhancement image.
It effectively improves the obvious display of product defect images and ensures that defects are clearer and more obvious in the display.
Smart Images

Figure CN120198327A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of image processing, and in particular, to a method, device, equipment, and readable storage medium for enhancing the display of product defects. Background Art
[0002] During the production process of products, due to factors such as production processes and production environments, some defects may occur in the products themselves, such as scratches of different depths. Since there are corresponding control specifications for the acceptance judgment of product defects on the production line, after the production of the product is completed, if it is determined that there are defects on the product, it is necessary to further display the product defects in the form of images.
[0003] Currently, the method of displaying product defects in the form of images is as follows: Based on the photometric stereo method, product images are obtained from four different angles of the product to be tested, so as to obtain four product images. Then, the brightness differences on the four product images are fused through corresponding algorithms to obtain a brightness difference fused image, and the defects existing on the product are displayed through the color difference displayed by the brightness difference fused image.
[0004] However, when displaying the defects existing on the product through the photometric stereo method, it is found that in some scenarios, the defects displayed on the corresponding brightness difference fused image are not obvious enough. Exemplarily, the product image (an image of a metal shell) collected is Figure 1 as shown, where the product defects are in the red circles, and the defects displayed on the corresponding brightness difference fused image are as Figure 2 shown. Obviously, the defects displayed on the brightness difference fused image are not obvious enough, so it is necessary to enhance the display of the determined product defects. Summary of the Invention
[0005] Based on this, in view of the above technical problems, it is necessary to provide a method, device, computer equipment, computer readable storage medium, and computer program product for enhancing the display of product defects, which can improve the obviousness of the display of product defects in images.
[0006] In a first aspect, the present application provides a method for enhancing the display of product defects, including:
[0007] Performing color space conversion on the obtained original product image to obtain an original Lab image; generating a brightness image based on the original Lab image, and performing edge-preserving filtering on the brightness image to obtain a filtered image;
[0008] Determining a brightness difference image based on the filtered image and the brightness image; calculating a scaling coefficient based on the brightness difference image;
[0009] Perform scaling processing on the luminance difference image based on a scaling coefficient to obtain a scaled luminance difference image; perform data clipping on the scaled luminance difference image to obtain clipped data;
[0010] Generate a defect display enhanced image based on the clipped data and the original Lab image.
[0011] In a second aspect, the present application provides a product defect display enhancement device, including:
[0012] An image processing module, configured to perform color space conversion on the acquired original product image to obtain an original Lab image; generate a luminance image based on the original Lab image, and perform edge-preserving filtering on the luminance image to obtain a filtered image;
[0013] A coefficient calculation module, configured to determine a luminance difference image based on the filtered image and the luminance image; calculate a scaling coefficient based on the luminance difference image;
[0014] A data clipping module, configured to perform scaling processing on the luminance difference image based on the scaling coefficient to obtain a scaled luminance difference image; perform data clipping on the scaled luminance difference image to obtain clipped data;
[0015] A display enhancement module, configured to generate a defect display enhanced image based on the clipped data and the original Lab image.
[0016] In a third aspect, the present application provides a computer device, which includes a memory and a processor. The memory stores a computer program, and when the processor executes the computer program, the steps in the above method are implemented.
[0017] In a fourth aspect, the present application provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps in the above method are implemented.
[0018] In a fifth aspect, the present application provides a computer program product, which includes a computer program. When the computer program is executed by a processor, the steps in the above method are implemented.
[0019] The above product defect display enhancement method, device, computer device, computer-readable storage medium, and computer program product perform color space conversion on the original product image, thereby obtaining the brightness corresponding to each pixel to obtain a brightness image. By filtering the brightness image, the brightness changes caused by product defects can be removed. By using a scaling factor to process the difference between the filtered image and the brightness image, the brightness value of the area where the product defect is located can be enhanced, so as to facilitate highlighting the display effect of the product defect. Then, data clipping can prevent the brightness value from exceeding the boundary. Finally, the image corresponding to the clipped data is converted back to an image in the same color space as the original product image through the original Lab image to obtain a defect display enhanced image. Through the above steps, the obviousness of the product defect image display can be effectively improved. Description of the Drawings
[0020] Figure 1 A metal shell image provided by an embodiment of the present application;
[0021] Figure 2 A brightness difference fusion image corresponding to the metal shell image provided by an embodiment of the present application;
[0022] Figure 3 An application environment diagram of a product defect display enhancement method provided by an embodiment of the present application;
[0023] Figure 4 A flowchart of a product defect display enhancement method provided by an embodiment of the present application;
[0024] Figure 5 A defect display enhanced image corresponding to the metal shell image provided by an embodiment of the present application;
[0025] Figure 6 A product original image and a defect display enhanced image corresponding to a plastic shell provided by an embodiment of the present application;
[0026] Figure 7 Another product original image and a defect display enhanced image corresponding to a plastic shell provided by an embodiment of the present application;
[0027] Figure 8 A structural block diagram of a product defect display enhancement device provided by an embodiment of the present application;
[0028] Figure 9 An internal structure diagram of a computer device provided by an embodiment of the present application;
[0029] Figure 10 Another internal structure diagram of a computer device provided by an embodiment of the present application;
[0030] Figure 11Internal structure diagram of a computer-readable storage medium provided by an embodiment of the present application. Detailed implementation manners
[0031] In order to make the objectives, technical solutions and advantages of the present application clearer, the present application will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0032] The product defect display enhancement method provided by the embodiments of the present application can be applied to, for example, Figure 3 the application environment shown in the figure. Among them, the terminal 102 communicates with the server 104 through a communication network. The data storage system can store the data that the server 104 needs to process. The data storage system can be integrated on the server 104, or placed in the cloud or other network servers. Among them, the terminal 102 can be, but is not limited to, various personal computers, laptop computers, smart phones, tablet computers, Internet of Things devices and portable wearable devices. The Internet of Things devices can be smart speakers, smart TVs, smart air conditioners, smart in-vehicle devices, etc. The portable wearable devices can be smart watches, smart bracelets, head-mounted devices, etc. The server 104 can be implemented by an independent server or a server cluster composed of multiple servers.
[0033] As Figure 4 shown in the figure, the embodiments of the present application provide a product defect display enhancement method, which is described by taking the method applied to Figure 3 the terminal 102 or the server 104 in the figure as an example. It can be understood that the computer device can include at least one of the terminal and the server. The method includes the following steps:
[0034] S110. Perform color space conversion on the obtained original product image to obtain an original Lab image; generate a luminance image based on the original Lab image, and perform edge-preserving filtering on the luminance image to obtain a filtered image.
[0035] The original image of the product is an image obtained by imaging the product using a preset optical device. Exemplarily, the optical device includes a CCD camera arranged directly above the product, and a coaxial light source is arranged directly below the CCD camera. The coaxial light source is used to illuminate the surface of the product, and the CCD camera is used to capture the product image, thereby obtaining the original image of the product. It should be noted that the original image of the product is an image in the RGB color space. Color space conversion is to convert an image from one color space to another color space. Common color spaces include RGB color space, HSV color space, HSL color space, and Lab color space. The color space conversion shown in this embodiment is specifically to convert the original image of the product from the RGB color space to the Lab color space, and the image obtained by converting the original image of the product to the Lab color space is recorded as the original Lab image.
[0036] The original Lab image includes three image channels, namely: L (brightness) channel, a (first color) channel and b (second color) channel, wherein the L channel is used to characterize the brightness change from black to white, the a channel is used to characterize the color change from dark green (low brightness value) to gray (medium brightness value) to bright pink (high brightness value), and the b channel is used to characterize the color change from bright blue (low brightness value) to gray (medium brightness value) to yellow (high brightness value). Each pixel in the original Lab image has a corresponding L (brightness) channel value, a channel value and b channel value. The L (brightness) channel value of each pixel in the original Lab image is extracted, and a new image can be generated through the L (brightness) channel value of each pixel, and the new image is recorded as a brightness image. It should be noted that there is only data of the L (brightness) channel in the brightness image, which is convenient for preventing the color difference of the product itself from adversely affecting the highlighting of product defects.
[0037] It should be noted that when scratches and other defects are generated on the product surface due to external forces, micro-deformation may also occur in the area around the defect. When the area around the defect is subsequently illuminated by a coaxial light source, the micro-deformation may cause the image brightness of the area around the defect to be low. The low imaging brightness will result in a low degree of visibility of the defect in the product image, that is, it is difficult for the staff to see the defects in the product image clearly. Figure 2 As shown, for this purpose, it is necessary to perform edge-preserving filtering on the brightness image, wherein the edge-preserving filtering is performed through a corresponding filter. The purpose of the edge-preserving filtering is to remove the noise in the product image while retaining the original brightness information of the area around the defect as much as possible, and the image obtained after edge-preserving filtering of the brightness image is recorded as the filtered image.
[0038] S120, determining a brightness difference image based on the filtered image and the brightness image; and calculating a scaling factor based on the brightness difference image.
[0039] Among them, the filtered image is the filtered luminance image, and its essence is still a kind of luminance image; the pixels in the filtered image correspond one by one to the pixels in the luminance image, and there is a one-to-one corresponding L (luminance) channel value for each pixel in the filtered image and the luminance image. That is to say, the filtered image and the luminance image belong to the images in the dimension of luminance. Therefore, the difference can be calculated between the filtered image and the luminance image to obtain the corresponding difference value, and this difference value is recorded as the luminance difference image. The pixels in the luminance difference image, the filtered image, and the luminance image correspond one by one. That is to say, each pixel in the luminance difference image has a corresponding pixel in the filtered image and the luminance image, and the L (luminance) channel value of each pixel in the luminance difference image is the difference between the L (luminance) channel values of the corresponding pixels in the filtered image and the luminance image.
[0040] Exemplarily, if the L (luminance) channel value corresponding to a certain pixel in the luminance difference image is 0.2, that is to say, it represents that the difference between the L (luminance) channel values of the corresponding pixels in the filtered image and the luminance image is 0.2, and so on. It should be noted that the luminance difference image focuses on the luminance difference between the filtered image and the luminance image, and the luminance difference of the corresponding pixels in the area around the product defect is higher, that is to say, the L (luminance) channel value of the corresponding pixels in the area around the product defect is higher, so as to facilitate highlighting the product defect.
[0041] It should be noted that although the L (luminance) channel value of the corresponding pixels in the area around the product defect in the luminance difference image will be higher than the L (luminance) channel value of other defect-free areas in the luminance difference image, the increase amplitude is not large. Exemplarily, the L (luminance) channel value of a certain pixel in other defect-free areas of the luminance difference image may be 0.2, but the L (luminance) channel value of the corresponding pixel in the area around the product defect in the luminance difference image is 0.7; in order to facilitate magnifying the difference between the L (luminance) channel value of the corresponding pixels in the area around the product defect in the luminance difference image and the L (luminance) channel value of other defect-free areas in the luminance difference image, it is necessary to magnify the L (luminance) channel value in this luminance difference image by using the corresponding scaling factor. It should be noted that the scaling factor can be determined through the luminance difference image. Exemplarily, the scaling factor is 10.
[0042] S130. Perform a scaling process on the luminance difference image based on the scaling factor to obtain a scaled luminance difference image; perform data clipping on the scaled luminance difference image to obtain clipped data.
[0043] Among them, the scaling factor is used to process the luminance difference image. Specifically, it increases the numerical value of the L (luminance) channel value corresponding to each pixel in the luminance difference image, thereby magnifying the difference between the L (luminance) channel value of the pixel corresponding to the product defect in the luminance difference image and the L (luminance) channel value of other defect-free areas in the luminance difference image. Exemplarily, after processing the luminance difference image with the scaling factor, the L (luminance) channel value of a certain pixel in other defect-free areas of the luminance difference image is increased from 0.2 to 2, and the L (luminance) channel value of the pixel corresponding to the product defect in the luminance difference image is increased from 0.7 to 7. And the image obtained after processing the luminance difference image with the scaling factor is denoted as the luminance difference scaled image.
[0044] It should be noted that the L (luminance) channel values of some pixels in the luminance difference scaled image may be too large, that is, the L (luminance) channel value exceeds the preset L channel value range. If the L (luminance) channel value corresponding to a certain pixel in the luminance difference scaled image exceeds this L channel value range, then this L (luminance) channel value is meaningless. Therefore, it is necessary to perform data clipping on the luminance difference scaled image. Data clipping means recovering the L (luminance) channel values that exceed this L channel value range in the luminance difference scaled image to within this L channel value range, so that the L (luminance) channel values are all meaningful. And the data obtained after data clipping of the L (luminance) channel values corresponding to each pixel in the luminance difference scaled image is denoted as the clipped data.
[0045] S140. Generate a defect display enhanced image based on the clipped data and the original Lab image.
[0046] Among them, the clipped data is the L (luminance) channel value corresponding to each pixel in the luminance difference scaled image. Since the luminance difference scaled image corresponds to each pixel in the original Lab image one by one, the clipped data is also the L (luminance) channel value corresponding to each pixel in the original Lab image one by one. Through the clipped data, the L (luminance) channel value corresponding to each pixel in the original Lab image can be processed to obtain an image for highlighting product defects, and this image for highlighting product defects is denoted as the defect display enhanced image. Exemplarily, this defect display enhanced image is as Figure 5 shown. Compared with Figure 2 the product defect shown, Figure 5 the product defect image shown is significantly enhanced.
[0047] It can be seen that in the embodiments of the present application, by performing color space conversion on the original product image, the brightness corresponding to each pixel is obtained to obtain a brightness image. By filtering the brightness image, the brightness change caused by product defects can be removed. By using a scaling factor to process the difference between the filtered image and the brightness image, the brightness value of the area where the product defect is located can be enhanced, so as to facilitate highlighting the display effect of the product defect. Then, by data clipping, the out-of-bounds of the brightness value can be prevented. Finally, the image corresponding to the clipped data is converted back to an image with the same color space as the original product image by means of the original Lab image to obtain a defect display enhanced image. Through the above steps, the obviousness of the product defect image display can be effectively improved.
[0048] In some embodiments, performing edge-preserving filtering on the brightness image to obtain a filtered image includes:
[0049] S112. Based on the original product image, determine the target defect size; based on the target defect size, determine the filter kernel of the filter.
[0050] Among them, after obtaining the original product image through an optical device, the area where the product defect is located in the original product image can be determined through a preset deep learning segmentation network, and the size of this area is recorded as the target defect size; exemplarily, in this embodiment, this area is a rectangular area, and the target defect size is the length w of the wide side of this rectangular area; the radius r of the filter can be further determined through the target defect size. Exemplarily, r = 1.2w. The filter uses its filter kernel to perform edge-preserving filtering on the generated brightness image. The size of the filter kernel is N*N, and the specific value of N is determined by the filter radius r. Exemplarily, r = (N - 1) / 2, that is, the corresponding filter kernel size can be determined through the calculated filter radius r. It should be noted that the types of filters adopted in this embodiment include but are not limited to bilateral filters, guided image filters, and weighted least square filters.
[0051] S113. Based on the filter kernel, perform filtering processing on the brightness image to obtain a filtered image.
[0052] Among them, the filter kernel is used to perform a convolution operation on the brightness image, that is, a weighted sum operation is performed on each pixel in the brightness image in turn, so as to re-determine the new L (brightness) channel value corresponding to each pixel in the brightness image, thereby realizing edge-preserving filtering of the brightness image.
[0053] It can be seen that in this embodiment, when a defect occurs on the surface of the product, micro-deformations may occur in the surrounding area of the defect, such as micro-depressions. Thus, when subsequently obtaining the original product image of the product, the L (luminance) channel value of the pixels corresponding to the area surrounding the product defect in the original product image is relatively low, that is, the display of the area surrounding the product defect in the original product image is relatively dark. This will have an adverse effect on highlighting the product defect subsequently. Therefore, by performing edge-preserving filtering on the luminance image, when the display of the area surrounding the product defect is relatively dark, the L (luminance) channel value of the pixels corresponding to the area surrounding the product defect can be effectively increased, thereby reducing the adverse effect brought by possible micro-deformations.
[0054] In some embodiments, based on the filtered image and the luminance image, a luminance difference image is determined, including:
[0055] S121. Determine the luminance value corresponding to each pixel in the filtered image to obtain a number of first luminance values; determine the luminance value corresponding to each pixel in the luminance image to obtain a number of second luminance values.
[0056] Among them, the filtered image is essentially also a kind of luminance image, and each pixel of it only corresponds to an L (luminance) channel value; and the L (luminance) channel value corresponding to the pixel in the filtered image is recorded as the first luminance value, and the L (luminance) channel value corresponding to the pixel in the luminance image is also recorded as the second luminance value.
[0057] S122. Calculate the difference between the first luminance value and the second luminance value corresponding to the pixels at the same position in the filtered image and the luminance image to obtain a luminance difference.
[0058] It should be noted that the resolutions of the filtered image and the luminance image are the same, and there are pixels in the filtered image that correspond one by one to the pixels in the luminance image; taking one pixel in the filtered image as an example, obtain the first luminance value of this pixel, and also obtain the second luminance value of the pixel at the same position as the above pixel on the luminance image, then calculate the difference between the first luminance value and the second luminance value, and record this difference as the luminance difference; through the above method, the luminance difference Delta corresponding to each group of corresponding pixels in the filtered image and the luminance image can be calculated. In this embodiment, the luminance difference Delta is specifically the absolute value of the difference between the first luminance value Lf and the second luminance value L, Delta = abs(Lf - L).
[0059] S123. Generate a luminance difference image based on the luminance difference.
[0060] Among them, the brightness differences corresponding to each group of corresponding pixels in the filtered image and the brightness image are respectively used as the new L (brightness) channel values, so that a new image can be generated, and this new image is denoted as the brightness difference image; the new L (brightness) channel value corresponding to each pixel in the brightness difference image also represents the difference between the corresponding first brightness value and the second brightness value.
[0061] It can be seen that in this embodiment, a new image, that is, the brightness difference image, can be constructed through the brightness differences between a group of corresponding pixels in the filtered image and the brightness image. Since the L (brightness) channel values corresponding to the defective areas and the non-defective areas in the brightness difference image are different, and the L (brightness) channel values corresponding to the defective areas are higher, it is convenient to highlight product defects.
[0062] In some embodiments, calculating a scaling coefficient based on the brightness difference image includes:
[0063] S124. Determine the target area corresponding to the target defect on the brightness difference image, and calculate the average brightness difference corresponding to the target area.
[0064] Among them, through the above S112 step, it can be known that the area where the product defect is located in the original product image can be determined through a preset deep learning segmentation network, and the resolution of the original product image and the brightness difference image is the same. The area where the product defect is located in the brightness difference image can be further determined through the area where the product defect is located in the determined original product image. The positions of the areas shown by the two are the same, and the area where the product defect is located in the brightness difference image is denoted as the target area. There are multiple pixels corresponding to the target area, and the L (brightness) channel value corresponding to each pixel represents the brightness difference between a corresponding group of first brightness value and second brightness value. The average value of the L (brightness) channel values corresponding to each pixel in the target area is denoted as the average brightness difference M.
[0065] S125. Determine the scaling coefficient based on the average brightness difference and a preset brightness difference parameter.
[0066] Among them, the brightness difference parameter is used to calculate in combination with the average brightness difference according to a corresponding calculation formula to obtain the scaling coefficient. The corresponding brightness difference parameter is preset according to historical experience. Exemplarily, the brightness difference parameter can be one of 40, 60, and 80. In this embodiment, the brightness difference parameter is preferably 40, and the calculation formula for calculating the scaling coefficient S is: S = 40 / M.
[0067] It can be seen that in this embodiment, by determining the average value M of the brightness difference and combining the preset brightness difference parameter and the corresponding calculation formula, the scaling coefficient can be calculated. Through this scaling coefficient, the difference between the L (brightness) channel values of the pixels in the area around the product defect and the L (brightness) channel values of the pixels not in the area around the product defect in the brightness difference image can be increased, so as to facilitate further highlighting of the product defect and further improve the obviousness of the product defect display.
[0068] In some embodiments, performing a scaling process on the brightness difference image based on the scaling coefficient to obtain a brightness difference scaled image includes:
[0069] S131. Determine the brightness difference corresponding to each pixel in the brightness difference image.
[0070] Wherein, the L (brightness) channel value corresponding to each pixel in the brightness difference image is also the brightness difference Delta corresponding to each pixel in the brightness difference image.
[0071] S132. Calculate the product of the brightness difference and the scaling coefficient, and generate a brightness difference scaled image based on the product.
[0072] Wherein, by multiplying the scaling coefficient S with the brightness difference corresponding to each pixel in the brightness difference image one by one, the product corresponding to each pixel can be obtained. This product represents the new L (brightness) channel value. A new image can be constructed through the new L (brightness) channel values corresponding to each pixel one by one, and this new image is denoted as the brightness difference scaled image. In this embodiment, the scaling coefficient S is 10, and the L (brightness) channel value corresponding to each pixel in the brightness difference scaled image is 10 times the L (brightness) channel value corresponding to each corresponding pixel in the brightness difference image. In this way, the difference between the L (brightness) channel values of the pixels in the area around the product defect and the L (brightness) channel values of the pixels not in the area around the product defect in the brightness difference image can be improved.
[0073] Exemplarily, the L (luminance) channel value of the pixels not in the area around the product defect in the luminance difference image is 0.2, and the L (luminance) channel value of the corresponding pixels in the scaled luminance difference image is 0.2 * 10 = 2. The L (luminance) channel value of the pixels in the area around the product defect in the luminance difference image is 0.7, and the L (luminance) channel value of the corresponding pixels in the scaled luminance difference image is 0.7 * 10 = 7. It can be seen that the luminance difference between the L (luminance) channel value of the pixels in the area around the product defect and the L (luminance) channel value of the pixels not in the area around the product defect in the luminance difference image is 0.7 - 0.2 = 0.5. However, the luminance difference between the L (luminance) channel value of the pixels in the area around the product defect and the L (luminance) channel value of the pixels not in the area around the product defect in the scaled luminance difference image is 7 - 2 = 5. Compared with the luminance difference image, the luminance difference between the L (luminance) channel value of the pixels in the area around the product defect and the L (luminance) channel value of the pixels not in the area around the product defect in the scaled luminance difference image has been further improved, which is convenient for further highlighting the product defect.
[0074] It can be seen that in this embodiment, by means of the scaling factor, the luminance difference between the L (luminance) channel value of the pixels in the area around the product defect and the L (luminance) channel value of the pixels not in the area around the product defect can be improved, so as to facilitate further highlighting the product defect.
[0075] In some embodiments, data clipping is performed on the scaled luminance difference image to obtain clipped data, including:
[0076] S133. Determine the scaled luminance difference value corresponding to each pixel in the scaled luminance difference image.
[0077] Wherein, the L (luminance) channel value corresponding to each pixel in the scaled luminance difference image is recorded as the scaled luminance difference value corresponding to each pixel in the scaled luminance difference image.
[0078] S134. In response to the scaled luminance difference value being less than a preset first threshold, change the scaled luminance difference value to the first threshold; or, in response to the scaled luminance difference value being greater than a preset second threshold, change the scaled luminance difference value to the second threshold; the second threshold is greater than the first threshold; based on the changed scaled luminance difference value, determine the clipped data.
[0079] It should be noted that, in order to prevent the luminance difference scaling value from losing its meaning due to being too large or too small, in this embodiment, a preset L-channel value range is provided. The minimum value of this L-channel value range is denoted as the first threshold, and the maximum value of this L-channel value range is denoted as the second threshold. Exemplarily, the first threshold is 0 and the second threshold is 100. Through this L-channel value range, the luminance difference scaling values corresponding to each pixel in the luminance difference scaled image can be compared one by one. If the luminance difference scaling value is less than the first threshold, the luminance difference scaling value is changed to the first threshold. If the luminance difference scaling value is greater than the second threshold, the luminance difference scaling value is changed to the second threshold, and the luminance difference scaling values corresponding to each pixel in the luminance difference scaled image after the comparison process of the L-channel value range are denoted as the cropped data.
[0080] It can be seen that in this embodiment, by limiting the luminance difference scaling value between the preset first threshold and the second threshold to obtain the cropped data, it can be ensured that the cropped data will not exceed the range formed by the first threshold and the second threshold, thereby ensuring that the cropped data has practical significance.
[0081] In some embodiments, based on the cropped data and the original Lab image, a defect display enhanced image is generated, including:
[0082] S141. Replace the luminance values of each pixel in the original Lab image based on the cropped data to obtain a target Lab image.
[0083] Among them, the cropped data is also the L (luminance) channel value corresponding to each pixel in the luminance difference scaled image. Since the luminance difference scaled image has the same resolution as the original Lab image, the cropped data is also the L (luminance) channel value corresponding to each pixel in the original Lab image. Each pixel in the original Lab image has a corresponding set of L (luminance) channel values, a (first color) channel values, and b (second color) channel values.
[0084] Taking the L (luminance) channel value corresponding to a pixel in the cropped data as an example, replace the luminance value of the corresponding pixel in the original Lab image with this L (luminance) channel value, and this luminance value is also the L (luminance) channel value of the corresponding pixel in the original Lab image; by replacing the L (luminance) channel values of all pixels in the original Lab image in the above manner, a new original Lab image is obtained, and this new original Lab image is denoted as the target Lab image.
[0085] S142. Perform color space conversion on the target Lab image to obtain a defect display enhanced image.
[0086] Among them, the color space corresponding to the target Lab image is the Lab color space. To facilitate the observation of the highlighted product defects, it is also necessary to convert this color space into the RGB color space, thereby obtaining a new image, and this new image is denoted as the defect display enhanced image.
[0087] It can be seen that in this embodiment, by using the cropping data to replace the brightness values of each pixel in the original Lab image to obtain the target Lab image, and performing color space conversion on the target Lab image to obtain the defect display enhanced image, it is thus convenient to obtain an image with prominent product defects.
[0088] Exemplarily, when performing the product defect display enhancement shown in this embodiment on a plastic shell, the product original image (Original Image) and the corresponding defect display enhanced image (Enhanced Image) are as Figure 6 or Figure 7 shown.
[0089] It should be understood that although the steps in the flowcharts involved in the above embodiments are sequentially shown according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless there is a clear description in this article, the execution of these steps has no strict order limit, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above embodiments may include multiple steps or multiple stages. These steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be executed alternately or in turn with at least a part of other steps or steps or stages in other steps.
[0090] Based on the same inventive concept, the embodiments of the present application also provide a product defect display enhancement device. The implementation solutions provided by this device to solve problems are similar to the implementation solutions described in the above method. Therefore, the specific limitations in one or more embodiments of the product defect display enhancement device provided below can refer to the limitations on the product defect display enhancement method in the above text, and will not be elaborated here.
[0091] As Figure 8 shown, the embodiments of the present application provide a product defect display enhancement device 800, including:
[0092] An image processing module 810, configured to perform color space conversion on the acquired product original image to obtain an original Lab image; generate a brightness image based on the original Lab image, and perform edge-preserving filtering on the brightness image to obtain a filtered image
[0093] The coefficient calculation module 820 is configured to determine a luminance difference image based on the filtered image and the luminance image; and calculate a scaling coefficient based on the luminance difference image.
[0094] The data clipping module 830 is configured to perform a scaling process on the luminance difference image based on the scaling coefficient to obtain a scaled luminance difference image; and perform data clipping on the scaled luminance difference image to obtain clipped data.
[0095] The display enhancement module 840 is configured to generate a defect display enhancement image based on the clipped data and the original Lab image.
[0096] In some embodiments, in terms of obtaining the filtered image by performing edge-preserving filtering on the luminance image, the image processing module 810 is specifically configured to:
[0097] Determine a target defect size based on the original product image.
[0098] Determine the filter kernel of the filter based on the target defect size.
[0099] Perform filtering processing on the luminance image based on the filter kernel to obtain the filtered image.
[0100] In some embodiments, in terms of determining the luminance difference image based on the filtered image and the luminance image, the coefficient calculation module 820 is specifically configured to:
[0101] Determine the luminance values corresponding to the pixels in the filtered image to obtain a number of first luminance values; determine the luminance values corresponding to the pixels in the luminance image to obtain a number of second luminance values.
[0102] Calculate the difference between the first luminance value and the second luminance value corresponding to the pixels at the same position in the filtered image and the luminance image to obtain a luminance difference.
[0103] Generate a luminance difference image based on the luminance difference.
[0104] In some embodiments, in terms of calculating the scaling coefficient based on the luminance difference image, the coefficient calculation module 820 is specifically configured to:
[0105] Determine a target area corresponding to the target defect on the luminance difference image, and calculate the average value of the luminance differences corresponding to the target area.
[0106] Determine the scaling coefficient based on the average value of the luminance differences and a preset luminance difference parameter.
[0107] In some embodiments, in terms of performing a scaling process on the luminance difference image based on the scaling coefficient to obtain a scaled luminance difference image, the data clipping module 830 is specifically configured to:
[0108] Determine the luminance differences corresponding to the pixels in the luminance difference image.
[0109] Calculate the product of the luminance difference and the scaling factor, and generate a luminance-difference scaled image based on the product.
[0110] In some embodiments, in terms of performing data clipping on the luminance-difference scaled image to obtain clipped data, the data clipping module 830 is specifically configured to:
[0111] Determine the luminance-difference scaling value corresponding to each pixel in the luminance-difference scaled image;
[0112] In response to the luminance-difference scaling value being less than a preset first threshold, change the luminance-difference scaling value to the first threshold; or,
[0113] In response to the luminance-difference scaling value being greater than a preset second threshold, change the luminance-difference scaling value to the second threshold; the second threshold is greater than the first threshold;
[0114] Determine the clipped data based on the changed luminance-difference scaling value.
[0115] In some embodiments, in terms of generating a defect display enhanced image based on the clipped data and the original Lab image, the display enhancement module 840 is specifically configured to:
[0116] Replace the luminance value of each pixel in the original Lab image with the clipped data to obtain a target Lab image;
[0117] Perform a color space conversion on the target Lab image to obtain a defect display enhanced image.
[0118] Each module in the above product defect display enhancement device can be implemented in whole or in part by software, hardware, and their combination. The above modules can be embedded in the processor in the computer device in hardware form or be independent of it, or can be stored in the memory in the computer device in software form, so as to be called by the processor to execute the operations corresponding to the above respective modules.
[0119] In some embodiments, a computer device is provided. The computer device can be a server, and its internal structure diagram can be as Figure 9As shown in the figure. The computer device includes a processor, a memory, an input / output interface (Input / Output, abbreviated as I / O), and a communication interface. Among them, the processor, the memory, and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store data related to the product defect display enhancement method. The input / output interface of the computer device is used to exchange information between the processor and external devices. The communication interface of the computer device is used to communicate with external terminals through a network connection. When the computer program is executed by the processor, it realizes the steps in the above product defect display enhancement method.
[0120] In some embodiments, a computer device is provided. The computer device can be a terminal, and its internal structure diagram can be as Figure 10 shown in the figure. The computer device includes a processor, a memory, an input / output interface, a communication interface, a display unit, and an input device. Among them, the processor, the memory, and the input / output interface are connected through a system bus, and the communication interface, the display unit, and the input device are connected to the system bus through the input / output interface. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The input / output interface of the computer device is used to exchange information between the processor and external devices. The communication interface of the computer device is used to communicate with external terminals in a wired or wireless manner. The wireless manner can be achieved through WIFI, a mobile cellular network, NFC (Near Field Communication), or other technologies. When the computer program is executed by the processor, it realizes the steps in the above product defect display enhancement method. The display unit of the computer device is used to form a visually visible picture, which can be a display screen, a projection device, or a virtual reality imaging device. The display screen can be a liquid crystal display screen or an electronic ink display screen; the input device of the computer device can be a touch layer covered on the display screen, or a button, a trackball, or a touchpad set on the computer device housing, or an external keyboard, touchpad, or mouse, etc.
[0121] Those skilled in the art can understand that Figure 9 or Figure 10The structure shown is only a block diagram of some of the structures related to the solution of this application, and does not constitute a limitation on the computer device to which the solution of this application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine some components, or have a different component arrangement.
[0122] In some embodiments, a computer device is provided, which includes a memory and a processor. The memory stores a computer program, and when the processor executes the computer program, the steps in the above method embodiments are implemented.
[0123] In some embodiments, as Figure 11 shown, an internal structure diagram of a computer-readable storage medium is provided. The computer-readable storage medium stores a computer program, and when the computer program is executed by the processor, the steps in the above method embodiments are implemented.
[0124] In some embodiments, a computer program product is provided, which includes a computer program, and when the computer program is executed by the processor, the steps in the above method embodiments are implemented.
[0125] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use, and processing of relevant data need to comply with the relevant laws, regulations, and standards of relevant countries and regions.
[0126] Those of ordinary skill in the art can understand that all or part of the processes in the methods of the above embodiments can be completed by instructing relevant hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above methods. Among them, any reference to a memory, database, or other medium used in the embodiments provided in the present application can include at least one of non-volatile and volatile memories. Non-volatile memory can include Read-Only Memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM), etc. The databases involved in the embodiments provided in the present application can include at least one of relational databases and non-relational databases. Non-relational databases can include distributed databases based on blockchain, etc., without limitation. The processors involved in the embodiments provided in the present application can be general-purpose processors, central processors, graphics processors, digital signal processors, programmable logic devices, data processing logics based on quantum computing, etc., without limitation.
[0127] The technical features of the above embodiments can be combined arbitrarily. For the sake of concise description, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, it should be considered as the scope described in this specification.
[0128] The above embodiments only represent several implementation manners of the present application. The description is relatively specific and detailed, but it should not be construed as a limitation on the patent scope of the present application. It should be noted that for those of ordinary skill in the art, without departing from the concept of the present application, several modifications and improvements can still be made, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the appended claims.
Claims
1. A method for enhancing product defect display, characterized in that: include: Perform color space conversion on the original product image to obtain the original Lab image; Generate a brightness image based on the original Lab image, and perform edge-preserving filtering on the brightness image to obtain a filtered image; Determining a brightness difference image based on the filtered image and the brightness image; Calculating a scaling factor based on the brightness difference image; Scaling the brightness difference image based on the scaling factor to obtain a brightness difference scaled image; Performing data cropping on the brightness difference scaled image to obtain cropped data; A defect display enhanced image is generated based on the cropped data and the original Lab image.
2. The method according to claim 1, characterized in that The performing edge-preserving filtering on the brightness image to obtain a filtered image includes: Determining a target defect size based on the original image of the product; Determining a filter kernel of a filter based on the target defect size; The brightness image is filtered based on the filter kernel to obtain a filtered image.
3. The method according to claim 1, characterized in that The step of determining a brightness difference image based on the filtered image and the brightness image comprises: Determine the brightness value corresponding to each pixel in the filtered image to obtain a plurality of first brightness values; determine the brightness value corresponding to each pixel in the brightness image to obtain a plurality of second brightness values; Calculate the difference between the first brightness value and the second brightness value corresponding to pixels at the same position in the filtered image and the brightness image to obtain a brightness difference; Based on the brightness difference values, a brightness difference image is generated.
4. The method according to claim 1, characterized in that: The calculating the scaling factor based on the brightness difference image comprises: Determine a target area corresponding to the target defect on the brightness difference image, and calculate a mean brightness difference value corresponding to the target area; A scaling factor is determined based on the brightness difference mean and a preset brightness difference parameter.
5. The method according to claim 1, characterized in that The step of scaling the brightness difference image based on the scaling factor to obtain a brightness difference scaled image includes: Determine the brightness difference value corresponding to each pixel in the brightness difference image; A product of the brightness difference value and the scaling factor is calculated, and a brightness difference scaling image is generated based on the product.
6. The method according to claim 1, characterized in that The step of performing data cropping on the brightness difference scaled image to obtain cropped data includes: Determine a brightness difference scaling value corresponding to each pixel in the brightness difference scaling image; In response to the brightness difference scaling value being less than a preset first threshold, changing the brightness difference scaling value to the first threshold; or, In response to the brightness difference scaling value being greater than a preset second threshold, changing the brightness difference scaling value to the second threshold; the second threshold being greater than the first threshold; The clipping data is determined based on the changed brightness difference scaling value.
7. The method according to claim 1, characterized in that The step of generating a defect display enhanced image based on the cropped data and the original Lab image comprises: Replacing the brightness value of each pixel in the original Lab image based on the cropped data to obtain a target Lab image; The target Lab image is converted into a color space to obtain a defect display enhanced image.
8. A product defect display enhancement device, characterized in that: include: The image processing module is used to convert the color space of the acquired original product image to obtain the original Lab image; Generate a brightness image based on the original Lab image, and perform edge-preserving filtering on the brightness image to obtain a filtered image; A coefficient calculation module, used for determining a brightness difference image based on the filtered image and the brightness image; Calculating a scaling factor based on the brightness difference image; A data clipping module, used for performing scaling processing on the brightness difference image based on the scaling factor to obtain a brightness difference scaled image; Performing data cropping on the brightness difference scaled image to obtain cropped data; The display enhancement module is used to generate a defect display enhanced image based on the cropped data and the original Lab image.
9. A computer device, comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.