Image compression method and related device for eliminating moiré by multiple perspective transformations
Through multiple perspective transformation methods, the molar pattern problem that occurs in the lighting defect detection of LCD display panels is solved, and the accurate detection of weak defects is achieved.
Patent Information
- Application Number
- CN202411776181.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-05
- Publication Date
- 2025-04-11
- Estimated Expiration
- 2044-12-05
AI Technical Summary
The LCD display panel is prone to molar patterns during the detection of lighting defects, making it difficult to detect weak defects.
Through the multiple perspective transformation method, the corner coordinates, real magnification and resolution of the original image are obtained, and the first perspective transformation is performed to correct the image and form a corrected image; then the second perspective transformation is performed based on the preset compression ratio and corrected corner coordinates, and the corrected image is compressed and corrected to form a compressed image to reduce the proportion of molar patterns.
It effectively reduces the molar pattern on the compressed image, improves the accuracy of defect detection, and avoids the problem of weak defects being diluted by grayscale.
Smart Images

Figure CN119254979B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of image compression technology, and more particularly to an image compression method and related device for eliminating moiré patterns through multiple perspective transformations. Background Art
[0002] Liquid Crystal Display (LCD) panels use the physical properties of liquid crystal, that is, the arrangement changes of liquid crystal molecules under the action of electric fields, to affect the passage of light and thus form images. In the image compression step for lighting defect detection of LCD display panels, because the spatial frequency of the screen itself and the spatial frequency of the camera may be close, this is easy to cause moiré, thereby interfering with the detection of defects based on compressed images. In order to eliminate the moiré of compressed images, the sampling frequency of the camera is increased during the optical structure design process, that is, the imaging magnification of the display panel on the CCD photosensitive element is increased, thereby widening the difference in the spatial frequencies of the two to reduce the moiré. However, the PPI of LCD display panels is relatively small and the physical size is large. When an image with a larger magnification is converted into a smaller magnification, moiré will appear on the entire screen, and some weak defects are easily diluted by grayscale and difficult to detect. Summary of the invention
[0003] The present application discloses an image compression method and a related device for eliminating moiré patterns by multiple perspective transformations, which are used to reduce moiré patterns on compressed images.
[0004] The first aspect of the present application discloses an image compression method for eliminating moiré patterns by multiple perspective transformations, comprising:
[0005] Obtaining the coordinates of the corner points of the effective display area of the original image, where the original image is an image of the product taken by the main viewing camera;
[0006] Acquire a real magnification and a resolution, wherein the resolution is a resolution of an LCD display panel, and the real magnification is a magnification between the original image and the image displayed on the LCD display panel;
[0007] Performing perspective transformation on the original image according to the real magnification, the resolution and the corner point coordinates to correct the original image and obtain a corrected image, wherein the corrected image includes the corrected corner point coordinates;
[0008] The corrected image is perspective transformed according to a preset compression ratio and the coordinates of the corrected corner points to compress the corrected image to obtain a compressed image.
[0009] Optionally, the obtaining of the actual magnification and resolution includes:
[0010] When the LCD display panel is a flat screen, the resolution of the LCD display panel includes a long side resolution and a wide side resolution;
[0011] Calculate the length or width of the original image according to the corner point coordinates;
[0012] The actual magnification is calculated according to the length value and the long side resolution, or the actual magnification is calculated according to the width value and the wide side resolution.
[0013] Optionally, the obtaining of the actual magnification and resolution includes:
[0014] When the LCD display panel is a curved screen, obtaining the resolution, screen profile parameters and curvature of the LCD display panel;
[0015] Establishing a geometric mathematical model according to the resolution, the screen contour parameters and the curvature;
[0016] The corner point coordinates are input into the geometric mathematical model to obtain the actual magnification.
[0017] Optionally, performing perspective transformation on the original image according to the real magnification, the resolution and the corner point coordinates to correct the original image to obtain the corrected image includes:
[0018] Calculate the corrected corner point coordinates according to the real magnification, the resolution and the corner point coordinates;
[0019] Calculate a first conversion relationship vector of perspective transformation according to the corner point coordinates and the corrected corner point coordinates;
[0020] According to the first transformation relationship vector, perspective transformation is performed one by one on the pixels in the original image to obtain a corrected image.
[0021] Optionally, after performing perspective transformation on the pixels in the original image one by one according to the first conversion relationship vector to obtain a corrected image, the method further includes:
[0022] The grayscale value of each pixel in the corrected image is calculated by bilinear interpolation or bicubic interpolation.
[0023] Optionally, after obtaining the corrected image, the method further includes:
[0024] Inputting the corrected image and the original image into a preset image feature model to perform feature comparison and obtain a comparison result;
[0025] If the comparison result indicates that there are characteristic differences between the corrected image and the original image, the real magnification is reacquired, and the perspective transformation of the original image is performed again to correct the original image and obtain the corrected image.
[0026] Optionally, performing perspective transformation on the corrected image according to a preset compression ratio and the coordinates of the corrected corner points to compress the corrected image to obtain the compressed image includes:
[0027] Calculating the compressed corner point coordinates according to the preset compression ratio and the corrected corner point coordinates;
[0028] Calculate a second conversion relationship vector of perspective transformation according to the corrected corner point coordinates and the compressed corner point coordinates;
[0029] Perform perspective transformation on the pixels in the rectified image one by one according to the second transformation relationship vector to obtain a compressed image.
[0030] Optionally, after performing perspective transformation on the pixels in the rectified image one by one according to the second conversion relationship vector to obtain a compressed image, the method further includes:
[0031] Acquire a target image generated by directly compressing the original image;
[0032] Performing two-dimensional discrete Fourier transform on the target image and the compressed image respectively to obtain a first transform result and a second transform result;
[0033] Performing centralization processing on the first transformation result and the second transformation result respectively to obtain a first processing result and a second processing result;
[0034] Outputting a first spectrum graph and a second spectrum graph according to the first processing result and the second processing result;
[0035] Moire detection is performed on the first spectrum graph and the second spectrum graph respectively.
[0036] The second aspect of the present application discloses an image compression system for eliminating moiré by multiple perspective transformations, comprising:
[0037] A first acquisition unit is used to acquire the coordinates of corner points of an effective display area of an original image, where the original image is an image of a product taken by a primary viewing camera;
[0038] A second acquisition unit, used to acquire a real magnification and a resolution, wherein the resolution is a resolution of the LCD display panel, and the real magnification is a magnification between the original image and the image displayed on the LCD display panel;
[0039] a correction unit, configured to perform perspective transformation on the original image according to the real magnification, the resolution and the corner point coordinates to correct the original image and obtain a corrected image, wherein the corrected image includes the corrected corner point coordinates;
[0040] The compression unit is used to perform perspective transformation on the rectified image according to a preset compression ratio and the coordinates of the rectified corner points to compress the rectified image and obtain a compressed image.
[0041] A third aspect of the present application provides an electronic device, including:
[0042] Processor, memory, input-output unit, and bus;
[0043] The processor is connected to the memory, the input and output unit, and the bus;
[0044] The memory stores a program, and the processor calls the program to execute the image compression method for eliminating moiré patterns by multiple perspective transformations as in the first aspect and any optional method in the first aspect.
[0045] In a fourth aspect, the present application provides a computer-readable storage medium on which a program is stored. When the program is executed on a computer, the image compression method for eliminating moiré patterns using multiple perspective transformations as in the first aspect and any optional method in the first aspect is performed.
[0046] It can be seen from the above technical solutions that the embodiments of the present application have the following advantages:
[0047] The present application provides an image compression method for eliminating moiré patterns through multiple perspective transformations. First, the coordinates of the corner points of the effective display area of the original image are obtained, and the original image is an image of the product taken by the main viewing camera; secondly, the real magnification and resolution are obtained, and the resolution is the resolution of the LCD display panel, and the real magnification is the magnification between the original image and the image displayed on the LCD display panel; then, the original image is perspectively transformed according to the real magnification, resolution and corner point coordinates to correct the original image and obtain a corrected image, and the corrected image includes the corrected corner point coordinates; finally, the corrected image is perspectively transformed according to a preset compression ratio and the corrected corner point coordinates to compress the corrected image and obtain a compressed image. This method performs a first perspective transformation on the original image according to the corner point coordinates, the real magnification and the resolution, corrects the pixels of the original image one by one to form a corrected image. The first perspective transformation corrects the image distortion caused by the viewing angle in the original image, and avoids the destruction of the information of the original image in subsequent processing steps; then a second perspective transformation is performed according to the corrected corner point coordinates of the corrected image and a pre-set compression ratio, and the distance between the pixels of the corrected image is also compressed to form a compressed image. The second perspective transformation reduces the gap between the lower spatial frequency part and the higher spatial frequency part in the corrected image, thereby reducing the proportion of moiré. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0049] Figure 1 A schematic diagram of an embodiment of an image compression method for eliminating moiré patterns by multiple perspective transformations of the present application;
[0050] Figure 2 A schematic diagram of another embodiment of the image compression method for eliminating moiré by multiple perspective transformations of the present application;
[0051] Figure 3 A schematic diagram of an embodiment of an image compression system for eliminating moiré patterns by multiple perspective transformations of the present application;
[0052] Figure 4 This is a schematic diagram of an embodiment of an electronic device of the present application. DETAILED DESCRIPTION
[0053] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.
[0054] It should be understood that when used in the present specification and the appended claims, the term "comprising" indicates the presence of described features, wholes, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or combinations thereof.
[0055] It should also be understood that the term “and / or” used in the specification and appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations.
[0056] As used in the specification and appended claims of this application, the term "if" can be interpreted as "when" or "uponce" or "in response to determining" or "in response to detecting", depending on the context. Similarly, the phrase "if it is determined" or "if [described condition or event] is detected" can be interpreted as meaning "uponce it is determined" or "in response to determining" or "uponce [described condition or event] is detected" or "in response to detecting [described condition or event]", depending on the context.
[0057] In addition, in the description of the present application specification and the appended claims, the terms "first", "second", "third", etc. are only used to distinguish the descriptions and cannot be understood as indicating or implying relative importance.
[0058] References to "one embodiment" or "some embodiments" etc. described in the specification of this application mean that one or more embodiments of the present application include specific features, structures or characteristics described in conjunction with the embodiment. Therefore, the statements "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. that appear in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways.
[0059] In the process of detecting lighting defects of LCD display panels, because the spatial frequency of the screen itself and the spatial frequency of the camera may be close, it is easy to cause moiré, which will interfere with the detection. In order to eliminate moiré, the sampling frequency of the camera is increased during the optical structure design process, that is, the imaging magnification of the display panel on the CCD photosensitive element is increased, thereby widening the difference in the spatial frequencies of the two to reduce moiré. However, the PPI of LCD display panels is relatively small and the physical size is large, which requires additional preprocessing during the detection process. At the same time, some weak defects are easily diluted by grayscale and difficult to detect. In order to improve detection accuracy and reduce preprocessing, the original image is compressed to a fixed magnification during the detection process to overcome the above problems, but this will make the originally weak moiré become more serious.
[0060] Based on this, the present application discloses an image compression method and related device for eliminating moiré patterns by multiple perspective transformations, which are used to reduce moiré patterns on compressed images.
[0061] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0062] The method of the present application can be applied to a server, a device, a terminal or other devices with logic processing capabilities, and the present application does not limit this. For the convenience of description, the following description is made by taking the execution subject as an example of a terminal.
[0063] See also Figure 1 The present application provides an embodiment of an image compression method for eliminating moiré patterns by multiple perspective transformations, comprising:
[0064] 101, obtaining the coordinates of the corner points of the effective display area of the original image, where the original image is an image of the product taken by the main viewing camera;
[0065] In this embodiment, a 151M main view camera is used to shoot, and the height of the main view camera is kept unchanged. Products with different resolutions and physical sizes are shot to obtain the original image. Then, the effective display area on the original image is determined, and the features of the product are included in the effective display area. The remaining background on the original image is removed, and unnecessary image information in the compressed image is reduced. The effective display area is generally a rectangle, but the position of the rectangle varies with the features of the product in the original image. Then, the coordinates of the four corners of the rectangle are used as the corner point coordinates, which are (x1, y1), (x1, y2), (x2, y1) and (x2, y2).
[0066] 102, obtaining a real magnification and a resolution, where the resolution is the resolution of the LCD display panel, and the real magnification is the magnification between the original image and the image displayed on the LCD display panel;
[0067] In this embodiment, the resolution of the LCD display panel is directly obtained by calling the specification data of the LCD display panel, and the unit of the resolution is generally pixel. Then, the pixel points of multiple features on the original image and the pixel points of multiple features on the image displayed on the LCD display panel are selected respectively. The selection of the above two features should be a one-to-one correspondence (for example, if the pixel point cluster representing the top feature of the product in the original image is selected, the pixel point cluster representing the top feature of the product is also selected in the image displayed on the LCD display panel). By comparing the pixel points of the multiple features selected from the above two images, the real magnification is calculated. It should also be noted that the shooting distance of the original image and the focal length of the camera can also be obtained, and the real magnification is directly calculated by the shooting distance and the focal length, but the accuracy of this direct calculation method is not as high as the method of comparing the pixel points of multiple features, so the method of comparing the pixel points of multiple features is preferred.
[0068] 103, performing perspective transformation on the original image according to the real magnification, resolution and corner point coordinates to correct the original image and obtain a corrected image, wherein the corrected image includes the corrected corner point coordinates;
[0069] In this embodiment, in order to eliminate image distortion caused by factors such as shooting angle and camera lens distortion, and obtain a corrected image that more accurately reflects the true shape and size of the product, a perspective transformation algorithm (such as the warpPerspective function in OpenCV) is used to transform the original image according to the true magnification L, the resolution of the LCD display panel, and the corner point coordinates (x1, y1), (x1, y2), (x2, y1) and (x2, y2) obtained in step 101. The perspective transformation adjusts the position of each pixel in the image so that the effective display area with uncertain position and angle in the original image can be correctly mapped on the LCD display panel and displayed to the user. The transformed image is the corrected image, and the corner point coordinates of the original image are transformed one by one into the corrected corner point coordinates, and then each pixel in the effective display area is perspectively transformed based on the transformation rule between the corner point coordinates and the corrected intersection point coordinates, so that the entire effective display area is transformed.
[0070] 104 , performing perspective transformation on the corrected image according to a preset compression ratio and the coordinates of the corrected corner points to compress the corrected image to obtain a compressed image.
[0071] In this embodiment, the size of the compressed image is calculated according to a preset compression ratio (e.g., the width and height are compressed to 50% of the original size respectively). The perspective transformation algorithm is used to transform the corrected image according to the coordinates of the correction corner points and the compressed image size. The transformed image is the compressed image, which maintains the correction effect of the corrected image but has a smaller size. The perspective transformation can adjust the pixel positions in the image to make them more evenly distributed, and transform the spatial frequency of the product in the original image, thereby further eliminating moiré.
[0072] In this embodiment, first, the coordinates of the corner points of the effective display area of the original image are obtained, and the original image is an image of the product taken by the main viewing camera; secondly, the real magnification and resolution are obtained, the resolution is the resolution of the LCD display panel, and the real magnification is the magnification between the original image and the image displayed on the LCD display panel; then, the original image is perspectively transformed according to the real magnification, resolution and corner point coordinates to correct the original image and obtain a corrected image, and the corrected image includes the corrected corner point coordinates; finally, the corrected image is perspectively transformed according to a preset compression ratio and the corrected corner point coordinates to compress the corrected image and obtain a compressed image. This method performs a first perspective transformation on the original image according to the corner point coordinates, the real magnification and the resolution, corrects the pixels of the original image one by one to form a corrected image. The first perspective transformation corrects the image distortion caused by the viewing angle in the original image, and avoids the destruction of the information of the original image in subsequent processing steps; then a second perspective transformation is performed according to the corrected corner point coordinates of the corrected image and a pre-set compression ratio, and the distance between the pixels of the corrected image is also compressed to form a compressed image. The second perspective transformation reduces the gap between the lower spatial frequency part and the higher spatial frequency part in the corrected image, thereby reducing the proportion of moiré.
[0073] See also Figure 2 The present application provides another embodiment of an image compression method for eliminating moiré patterns by multiple perspective transformations, comprising:
[0074] 201, obtaining the coordinates of the corner points of the effective display area of the original image, where the original image is an image of the product taken by the main viewing camera;
[0075] Step 201 in this embodiment is similar to step 101 in the above embodiment and will not be described again here.
[0076] 202, when the LCD display panel is a flat screen, the resolution of the LCD display panel includes a long side resolution and a wide side resolution, and the length value or the width value of the original image is calculated according to the corner point coordinates;
[0077] In this embodiment, when the LCD display panel is a flat screen, the image displayed on the LCD display panel is also rectangular, and the resolution of the LCD display panel is the long side resolution w and the wide side resolution h. Through the corner point coordinates (x1, y1), (x1, y2), (x2, y1) and (x2, y2), the length s and width f of the effective display area of the original image can be calculated, that is, the length s=|x1-x2|, and the width f=|y1-y2|.
[0078] 203, calculating the real magnification according to the length value and the long side resolution, or calculating the real magnification according to the width value and the wide side resolution;
[0079] In this embodiment, the real magnification L can be calculated according to the length value s and the long side resolution w, that is, L=s / w; the real magnification L can also be calculated according to the width value f and the wide side resolution h, that is, L=f / h. Which of the above methods is used to calculate the real magnification L depends on the effect of subsequent moiré elimination. If the effect of eliminating moiré by the method of obtaining the real magnification according to the formula L=s / w is better than the method of obtaining the real magnification according to the formula L=f / h, then the formula L=s / w is selected; vice versa.
[0080] 204, when the LCD display panel is a curved screen, obtaining a resolution, a screen profile parameter, and a curvature of the LCD display panel;
[0081] In this embodiment, when the LCD display panel is a curved screen, the image displayed on the LCD display panel is not a flat rectangle, and the real magnification cannot be directly obtained through the resolution and the length and width of the original image. Therefore, the resolution, screen contour parameters and curvature should be obtained by calling the specification data of the LCD display panel.
[0082] 205, establishing a geometric mathematical model according to the resolution, screen contour parameters and curvature, and inputting the corner point coordinates into the geometric mathematical model to obtain a real magnification;
[0083] In this embodiment, a geometric mathematical model is constructed by using the resolution, screen contour parameters and curvature obtained in step 204, wherein even for a curved screen, the resolution of the LCD display panel still includes a long side resolution w and a wide side resolution h. The model can describe the correspondence between the pixel points on the curved screen and the pixel points of the original image. By calculating the corresponding position of each pixel point in the plane image on the curved surface model, and then assigning the image pixel value to these corresponding positions, the mapping of the original image on the geometric mathematical model is realized. After the geometric mathematical model is established, the coordinates of the corner points of the image are input into the geometric mathematical model, and the geometric mathematical model outputs the real magnification L.
[0084] 206, calculating the corrected corner point coordinates according to the actual magnification, resolution and corner point coordinates;
[0085] In this embodiment, the corrected corner point coordinates (0,0), (0,L*w), (L*h,0) and (L*h,L*w) are calculated respectively according to the actual magnification L obtained in step 203 or step 205, the resolution (w and h) of the LCD display panel, and the corner point coordinates (x1,y1), (x1,y2), (x2,y1) and (x2,y2).
[0086] 207, calculating a first conversion relationship vector of perspective transformation according to the corner point coordinates and the corrected corner point coordinates;
[0087] In this embodiment, the first transformation relationship vector A describes how to map the pixel points in the original image to the corresponding positions in the corrected image. The perspective transformation relationship between the original image and the corrected image can be determined by the first transformation relationship vector A. Specifically, the horizontal coordinate of the corner point coordinates is set to X, that is, X={x1,x2}, and the vertical coordinate of the corner point coordinates is set to Y, that is, Y={y1,y2}; the horizontal coordinate of the corrected corner point coordinates is set to X', that is, X'={0,L*h}, and the vertical coordinate of the corrected corner point coordinates is set to Y', that is, Y'={0,L*w}. The first transformation relationship vector A is obtained by the following target formula:
[0088] , where A= .
[0089] 208, performing perspective transformation on the pixels in the original image one by one according to the first transformation relationship vector to obtain a corrected image;
[0090] In this embodiment, according to the first conversion relationship vector A calculated in step 207, the coordinates of the pixels in the original image are transformed into the coordinates of the corrected image one by one. Specifically, when the first conversion relationship vector A is known, the horizontal coordinate of each pixel point in the original image is input into the X of the target formula in step 207, and the vertical coordinate is input into the Y of the target formula to obtain the horizontal coordinate X' and the vertical coordinate Y' corresponding to each pixel point in the corrected image. When all the pixels in the original image are transformed, all the transformed pixels constitute the corrected image.
[0091] 209, inputting the corrected image and the original image into a preset image feature model to perform feature comparison and obtain a comparison result;
[0092] In this embodiment, in order to ensure that the corrected image is consistent with the original image in terms of features and avoid missing image information, which leads to meaningless compression of the image, the corrected image and the original image should be compared. The pre-set image feature model can identify and extract key features in the image, such as edges, textures, colors, etc. Using the image feature model, key features are extracted from the corrected image and the original image. These features are usually represented in the form of feature vectors, each of which contains a series of numerical values describing the characteristics of the image. The feature vector of the corrected image is compared with the feature vector of the original image, for example, the similarity or distance between the feature vectors is calculated to determine whether they are close enough, that is, to obtain a comparison result.
[0093] 210, if the comparison result indicates that there are characteristic differences between the corrected image and the original image, then re-acquire the real magnification, and perform perspective transformation on the original image again to correct the original image and obtain the corrected image;
[0094] In this embodiment, after the feature comparison in step 209, if there are significant differences between the feature vectors, which may be that the similarity is lower than a preset similarity threshold or the distance between the feature vectors exceeds a preset distance threshold, then it is considered that the corrected image and the original image have differences in features. At this time, the real magnification should be reacquired, and the re-acquisition method can be different from the method of the last acquisition. Then, a new perspective transformation relationship vector is calculated based on the re-acquired real magnification. This vector will be used to map the pixel points in the original image to the new position in the corrected image, perform perspective transformation on the original image, and obtain a new corrected image. Further, the new corrected image is input into the image feature model again for feature comparison. If there are still feature differences, continue to adjust the parameters and re-correct until the corrected image is consistent with the original image in features or reaches the preset accuracy requirements.
[0095] 211, calculating the gray value of each pixel in the corrected image by bilinear interpolation or bicubic interpolation;
[0096] In this embodiment, bilinear interpolation or bicubic interpolation is used to select a target pixel in the corrected image, then obtain the pixel corresponding to the target pixel on the original image, and then obtain the grayscale values of the pixels around the corresponding pixel on the original image to calculate the grayscale value of the target pixel. Both interpolation methods can produce a smoother grayscale transition effect.
[0097] Specifically, if the bilinear interpolation method is used, the gray value is calculated according to the following formula:
[0098] ,
[0099] Among them, (i+u,j+v) is the coordinate of the target pixel, i is the integer part of the horizontal coordinate, u is the decimal part of the horizontal coordinate, j is the integer part of the vertical coordinate, and v is the decimal part of the vertical coordinate; f(i+u,j+v) is the grayscale value of the target pixel, f(i,j) is the grayscale value of point (i,j), f(i+1,j) is the grayscale value of point (i+1,j), f(i,j+1) is the grayscale value of point (i,j+1), and f(i+1,j+1) is the grayscale value of point (i+1,j+1).
[0100] If bicubic interpolation is used, similar to bilinear interpolation, bilinear interpolation selects 4 surrounding pixels, while bicubic interpolation selects 16 surrounding pixels, which further improves the calculation accuracy, but at the same time the calculation complexity also increases. Therefore, the method for calculating the gray value of the target pixel can be selected according to the accuracy requirements of the compressed image.
[0101] 212, calculating the compressed corner point coordinates according to the preset compression ratio and the corrected corner point coordinates;
[0102] In this embodiment, the preset compression ratio is a value set according to actual work requirements, and the compressed corner point coordinates are calculated according to the compression ratio and the corrected corner point coordinates. The compressed corner point coordinates are one of the basic values for subsequent compression and correction of the image.
[0103] 213, calculating a second conversion relationship vector of perspective transformation according to the corrected corner point coordinates and the compressed corner point coordinates;
[0104] In this embodiment, similar to step 207, the second transformation relationship vector B describes how to map the pixel points in the rectified image to the corresponding positions in the compressed image, and the perspective transformation relationship between the rectified image and the compressed image can be determined by the second transformation relationship vector B. The formula for calculating the second transformation relationship vector B is also similar to step 207 and will not be described here.
[0105] 214, performing perspective transformation on the pixels in the rectified image one by one according to the second transformation relationship vector to obtain a compressed image;
[0106] In this embodiment, the coordinates of the pixels in the corrected image are transformed into the coordinates of the compressed image one by one according to the second conversion relationship vector B calculated in step 213. Specifically, when the second conversion relationship vector B is known, the horizontal coordinate and the vertical coordinate of each pixel point in the corrected image are input into the target formula to obtain the horizontal coordinate and the vertical coordinate corresponding to each pixel point in the compressed image. When all the pixels in the corrected image are transformed, all the transformed pixels constitute the compressed image.
[0107] 215, obtaining a target image generated by directly compressing the original image;
[0108] In this embodiment, other methods are used to directly compress the original image to obtain the target image. The target image is generated to use the target image as a reference object for subsequent detection of the actual effect of multiple perspective transformations in this embodiment on reducing moiré patterns.
[0109] 216, performing a two-dimensional discrete Fourier transform on the target image and the compressed image respectively to obtain a first transform result and a second transform result;
[0110] In this embodiment, the pixel matrices of the target image and the compressed image are transformed using a two-dimensional discrete Fourier transform formula or algorithm, so that the image can be converted from the spatial domain (i.e., the pixel domain) to the frequency domain. The results of the transformation of the target image and the compressed image are respectively the first transformation result and the second transformation result, and each of the first transformation result and the second transformation result is a complex matrix, which contains the frequency information of the corresponding image. Each element of the complex matrix corresponds to a specific frequency component, and its amplitude represents the intensity of the frequency component, and the phase represents the phase information of the frequency component.
[0111] 217, performing centralization processing on the first transformation result and the second transformation result respectively to obtain a first processing result and a second processing result;
[0112] In this embodiment, the first transformation result and the second transformation result are centered, that is, the low-frequency component is moved to the center of the spectrum graph, which helps to more intuitively observe and analyze the frequency characteristics of the image. A spectrum graph is generated based on the complex matrix after the centering process. The spectrum graph is usually presented in the form of a grayscale image or a color image, where the grayscale or color represents the intensity of the frequency component.
[0113] 218, outputting a first spectrum graph and a second spectrum graph according to the first processing result and the second processing result;
[0114] 219 , perform moiré detection on the first spectrum graph and the second spectrum graph respectively.
[0115] In this embodiment, the spectrograms of the target image and the compressed image are output as image files or displayed on the screen for subsequent analysis and comparison. By analyzing the two spectrograms, the characteristics of the target image and the compressed image in the frequency domain can be understood. For example, the distribution of low-frequency components and high-frequency components in the spectrogram, as well as the relative strengths between them, can be observed. This information helps to evaluate the impact of the image compression algorithm of this embodiment on the image quality. Specifically, for example, by analyzing and comparing the moiré ratio information, the spectrogram corresponding to the image with a higher moiré ratio is brighter (more white highlights).
[0116] In this embodiment, firstly, the coordinates of the corner points of the effective display area of the original image are obtained, and the original image is an image of the product taken by the main viewing camera; when the LCD display panel is a flat screen, the resolution of the LCD display panel includes the long side resolution and the wide side resolution, and the length value or the width value of the original image is calculated according to the corner point coordinates; the real magnification is calculated according to the length value and the long side resolution, or the real magnification is calculated according to the width value and the wide side resolution; when the LCD display panel is a curved screen, the resolution, screen contour parameters and curvature of the LCD display panel are obtained; a geometric mathematical model is established according to the resolution, the screen contour parameters and the curvature, and the corner point coordinates are input into the geometric mathematical model to obtain the real magnification; the corrected corner point coordinates are calculated according to the real magnification, resolution and corner point coordinates; the first transformation relationship vector of the perspective transformation is calculated according to the corner point coordinates and the corrected corner point coordinates; the pixel points in the original image are perspectively transformed one by one according to the first transformation relationship vector to obtain the corrected image; the corrected image and the original image are input into a pre-set image feature model to perform feature Compare and obtain a comparison result; if the comparison result indicates that there are feature differences between the corrected image and the original image, then re-acquire the real magnification, and perform perspective transformation on the original image again to correct the original image to obtain the corrected image; calculate the gray value of each pixel in the corrected image by bilinear interpolation or bicubic interpolation; calculate the compressed corner point coordinates according to a preset compression ratio and the corrected corner point coordinates; calculate the second transformation relationship vector of the perspective transformation according to the corrected corner point coordinates and the compressed corner point coordinates; perform perspective transformation on the pixels in the corrected image one by one according to the second transformation relationship vector to obtain a compressed image; obtain a target image directly compressed from the original image; perform two-dimensional discrete Fourier transformation on the target image and the compressed image respectively to obtain a first transformation result and a second transformation result; perform centralization processing on the first transformation result and the second transformation result respectively to obtain a first processing result and a second processing result; output a first spectrum map and a second spectrum map according to the first processing result and the second processing result; perform moiré detection on the first spectrum map and the second spectrum map respectively. This embodiment performs a first perspective transformation on the original image according to the corner point coordinates, the real magnification and the resolution, corrects the pixels of the original image one by one to form a corrected image. The first perspective transformation corrects the image distortion caused by the viewing angle in the original image, and avoids the destruction of the information of the original image in subsequent processing steps; then a second perspective transformation is performed according to the corrected corner point coordinates of the corrected image and a pre-set compression ratio, and the distance between the pixels of the corrected image is also compressed to form a compressed image. The second perspective transformation reduces the gap between the lower spatial frequency part and the higher spatial frequency part in the corrected image, thereby reducing the proportion of moiré.
[0117] See also Figure 3 The present application provides an embodiment of an image compression system for eliminating moiré by multiple perspective transformations, comprising:
[0118] The first acquisition unit 301 is used to acquire the coordinates of the corner points of the effective display area of the original image, where the original image is an image of the product taken by the main viewing camera;
[0119] A second acquisition unit 302 is used to acquire a real magnification and a resolution, where the resolution is the resolution of the LCD display panel, and the real magnification is the magnification between the original image and the image displayed on the LCD display panel;
[0120] A correction unit 303 is used to perform perspective transformation on the original image according to the real magnification, resolution and corner point coordinates to correct the original image and obtain a corrected image, wherein the corrected image includes the corrected corner point coordinates;
[0121] The compression unit 304 is used to perform perspective transformation on the rectified image according to a preset compression ratio and the coordinates of the correction corner points to compress the rectified image to obtain a compressed image.
[0122] Optionally, the second acquiring unit 302 is specifically configured to:
[0123] When the LCD display panel is a flat screen, the resolution of the LCD display panel includes a long side resolution and a wide side resolution;
[0124] Calculate the length or width of the original image based on the corner point coordinates;
[0125] Calculate the true magnification from the length value and the long side resolution, or from the width value and the wide side resolution.
[0126] Optionally, the second acquiring unit 302 is specifically configured to:
[0127] When the LCD display panel is a curved screen, obtaining the resolution, screen profile parameters and curvature of the LCD display panel;
[0128] Establish a geometric mathematical model based on resolution, screen contour parameters and curvature;
[0129] The coordinates of the corner points are input into the geometric mathematical model to obtain the true magnification.
[0130] Optionally, the correction unit 303 is specifically used for:
[0131] Calculate the corrected corner point coordinates according to the real magnification, resolution and corner point coordinates;
[0132] Calculate the first conversion relationship vector of perspective transformation according to the corner point coordinates and the corrected corner point coordinates;
[0133] The pixels in the original image are perspectively transformed one by one according to the first transformation relationship vector to obtain a corrected image.
[0134] Optionally, the correction unit 303 is specifically used for:
[0135] The grayscale value of each pixel in the rectified image is calculated by bilinear interpolation or bicubic interpolation.
[0136] Optionally, after the correction unit 303, the method further includes:
[0137] The comparison unit 305 is used to input the corrected image and the original image into a preset image feature model to perform feature comparison and obtain a comparison result;
[0138] The re-execution unit 306 is used to re-acquire the real magnification if the comparison result indicates that there are feature differences between the corrected image and the original image, and to re-execute the step of performing perspective transformation on the original image to correct the original image and obtain the corrected image.
[0139] Optionally, the compression unit 304 is specifically configured to:
[0140] Calculate the compressed corner point coordinates according to the preset compression ratio and the corrected corner point coordinates;
[0141] Calculate the second conversion relationship vector of the perspective transformation according to the corrected corner point coordinates and the compressed corner point coordinates;
[0142] The pixels in the rectified image are perspectively transformed one by one according to the second transformation relationship vector to obtain a compressed image.
[0143] Optionally, the compression unit 304 is specifically configured to:
[0144] Obtain a target image generated by directly compressing the original image;
[0145] Performing two-dimensional discrete Fourier transform on the target image and the compressed image respectively to obtain a first transform result and a second transform result;
[0146] Perform centralization processing on the first transformation result and the second transformation result respectively to obtain a first processing result and a second processing result;
[0147] Outputting a first spectrum graph and a second spectrum graph according to the first processing result and the second processing result;
[0148] Moire detection is performed on the first spectrum graph and the second spectrum graph respectively.
[0149] See also Figure 4 , the present application provides an electronic device, including:
[0150] Processor 401 , memory 402 , input / output unit 403 , and bus 404 .
[0151] The processor 401 is connected to the memory 402 , the input and output unit 403 , and the bus 404 .
[0152] The memory 402 stores a program, and the processor 401 calls the program to execute the following steps: Figure 1 or Figure 2 Image compression method for eliminating moiré patterns by multiple perspective transformations.
[0153] The present application provides a computer-readable storage medium, on which a program is stored, and when the program is executed on a computer, the program performs the following steps: Figure 1 or Figure 2 Image compression method for eliminating moiré patterns by multiple perspective transformations.
[0154] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0155] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.
[0156] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0157] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0158] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, read-only memory), random access memory (RAM, random access memory), disk or optical disk and other media that can store program code.
Claims
1. An image compression method for eliminating moiré by multiple perspective transformations, characterized in that: include: Obtaining the coordinates of the corner points of the effective display area of the original image, where the original image is an image of the product taken by the main viewing camera; Acquire a real magnification and a resolution, wherein the resolution is a resolution of an LCD display panel, and the real magnification is a magnification between the original image and the image displayed on the LCD display panel; Calculate the corrected corner point coordinates according to the real magnification, the resolution and the corner point coordinates; Calculate a first conversion relationship vector of perspective transformation according to the corner point coordinates and the corrected corner point coordinates; Performing perspective transformation on pixel points in the original image one by one according to the first transformation relationship vector to obtain a corrected image, wherein the corrected image includes coordinates of corrected corner points; Calculating the compressed corner point coordinates according to the preset compression ratio and the corrected corner point coordinates; Calculate a second conversion relationship vector of perspective transformation according to the corrected corner point coordinates and the compressed corner point coordinates; Performing perspective transformation on the pixels in the rectified image one by one according to the second transformation relationship vector to obtain a compressed image; The obtaining of the real magnification and resolution comprises: When the LCD display panel is a flat screen, the resolution of the LCD display panel includes a long side resolution and a wide side resolution; Calculating the length or width of the original image according to the corner point coordinates; calculating the real magnification according to the length and the long side resolution, or calculating the real magnification according to the width and the wide side resolution; When the LCD display panel is a curved screen, the resolution, screen contour parameters and curvature of the LCD display panel are obtained; a geometric mathematical model is established according to the resolution, the screen contour parameters and the curvature; the corner point coordinates are input into the geometric mathematical model to obtain the real magnification.
2. The image compression method according to claim 1, characterized in that: After performing perspective transformation on the pixels in the original image one by one according to the first conversion relationship vector to obtain a corrected image, the method further includes: The grayscale value of each pixel in the corrected image is calculated by bilinear interpolation or bicubic interpolation.
3. The image compression method according to claim 1, characterized in that: After obtaining the corrected image, the method further includes: Inputting the corrected image and the original image into a preset image feature model to perform feature comparison and obtain a comparison result; If the comparison result indicates that there are characteristic differences between the corrected image and the original image, the real magnification is reacquired, and the perspective transformation of the original image is performed again to correct the original image and obtain the corrected image.
4. The image compression method according to claim 1, characterized in that: After performing perspective transformation on the pixels in the rectified image one by one according to the second conversion relationship vector to obtain a compressed image, the method further includes: Acquire a target image generated by directly compressing the original image; Performing two-dimensional discrete Fourier transform on the target image and the compressed image respectively to obtain a first transform result and a second transform result; Performing centralization processing on the first transformation result and the second transformation result respectively to obtain a first processing result and a second processing result; Outputting a first spectrum graph and a second spectrum graph according to the first processing result and the second processing result; Moire detection is performed on the first spectrum graph and the second spectrum graph respectively.
5. An image compression system for eliminating moiré by multiple perspective transformations, characterized in that: include: A first acquisition unit is used to acquire the coordinates of corner points of an effective display area of an original image, where the original image is an image of a product taken by a primary viewing camera; A second acquisition unit, used to acquire a real magnification and a resolution, wherein the resolution is a resolution of the LCD display panel, and the real magnification is a magnification between the original image and the image displayed on the LCD display panel; a correction unit, configured to calculate the correction corner point coordinates according to the real magnification, the resolution and the corner point coordinates; calculate the first transformation relationship vector of the perspective transformation according to the corner point coordinates and the correction corner point coordinates; perform perspective transformation on the pixel points in the original image one by one according to the first transformation relationship vector to obtain a correction image, wherein the correction image includes the correction corner point coordinates; A compression unit, configured to calculate the compressed corner point coordinates according to a preset compression ratio and the corrected corner point coordinates; calculate a second transformation relationship vector of perspective transformation according to the corrected corner point coordinates and the compressed corner point coordinates; and perform perspective transformation on the pixel points in the corrected image one by one according to the second transformation relationship vector to obtain a compressed image; The second acquisition unit is specifically used for: When the LCD display panel is a flat screen, the resolution of the LCD display panel is obtained, and the resolution of the LCD display panel includes a long side resolution and a wide side resolution; the length value or the width value of the original image is calculated according to the corner point coordinates; the real magnification is calculated according to the length value and the long side resolution, or the real magnification is calculated according to the width value and the wide side resolution; When the LCD display panel is a curved screen, the resolution, screen contour parameters and curvature of the LCD display panel are obtained; a geometric mathematical model is established according to the resolution, the screen contour parameters and the curvature; and the corner point coordinates are input into the geometric mathematical model to obtain a true magnification.
6. An electronic device, characterized in that: include: Processor, memory, input-output unit, and bus; The processor is connected to the memory, the input and output unit, and the bus; The memory stores a program, and the processor calls the program to execute the image compression method for eliminating moiré patterns through multiple perspective transformations as claimed in any one of claims 1 to 4.
Citation Information
Patent Citations
Image perspective transformation method, device and equipment
CN110060200A