Image correction method and image correction device
By converting the image to be corrected and the preset image to the orthogonal color space, calculating the characteristic values of each color channel and correcting the mapping relationship, the problems of unstable image color difference and color extraction in industrial detection are solved, and efficient and convenient image correction effect is achieved.
Patent Information
- Application Number
- CN202411627471.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-14
- Publication Date
- 2025-04-18
AI Technical Summary
In industrial detection scenarios, due to instability in imaging and reflection or color differences in the material itself, there is a color difference in the image, unstable color extraction, and the existing color correction technology has poor effect and complex operation.
By converting the image to be corrected and the preset image to the orthogonal color space, the characteristic values of each color channel are calculated, and image correction is performed based on the mapping relationship of these characteristic values, and independent channel correction is performed using the characteristics of the orthogonal color space.
It improves the effect and convenience of image correction, enhances the flexibility and scope of correction, and reduces the complexity and calculation amount of image processing.
Smart Images

Figure CN119850492A_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the technical field of image correction, and in particular, relates to an image correction method and an image correction device. Background Art
[0002] In industrial inspection scenarios, due to unstable imaging and the reflection of the material itself, different images may have color differences, or the material itself has color differences, resulting in unstable color extraction. In the related art, the color correction method has poor correction effect and is complicated to operate. Summary of the invention
[0003] The present application aims to solve at least one of the technical problems existing in the related art. To this end, the present application proposes an image correction method and an image correction device, which correct the image to be corrected based on the independent characteristics of each color channel in the orthogonal color space, improve the correction effect, and the correction method is convenient.
[0004] In a first aspect, the present application provides an image correction method, the method comprising:
[0005] Converting the image to be corrected into an orthogonal color space to obtain an orthogonal image to be corrected, and converting a preset image into the orthogonal color space to obtain a preset orthogonal image;
[0006] Calculating the characteristic values of the orthogonal image to be corrected in each color channel and the characteristic values of the preset orthogonal image in each color channel respectively, to obtain the first characteristic value of the orthogonal image to be corrected in each color channel and the second characteristic value of the preset orthogonal image in each color channel; the first characteristic value of each color channel corresponds to the second characteristic value of each color channel one by one;
[0007] The image to be corrected is corrected based on the first characteristic value of each color channel and the second characteristic value of each color channel.
[0008] According to the image correction method of the present application, the image to be corrected is converted into an orthogonal color space, and the preset image is converted into an orthogonal color space to obtain the orthogonal image to be corrected and the preset orthogonal image, and the eigenvalues of the orthogonal image to be corrected and the preset orthogonal image in the orthogonal color space are calculated respectively. The eigenvalue of the preset orthogonal image is used as a reference, and based on the independent characteristics of each color channel in the orthogonal color space, the image to be corrected is corrected to improve the correction effect, and the correction method is convenient.
[0009] According to the image correction method of the present application, the image to be corrected is converted into an orthogonal color space to obtain an orthogonal image to be corrected, and the preset image is converted into the orthogonal color space to obtain a preset orthogonal image, including:
[0010] Convert at least part of the correction area of the image to be corrected to the orthogonal color space to obtain the orthogonal image to be corrected; convert at least part of the preset area of the preset image to the orthogonal color space to obtain the preset orthogonal image; the at least part of the correction area corresponds to the at least part of the preset area.
[0011] According to the image correction method of the present application, the step of respectively calculating the eigenvalues of the orthogonal image to be corrected in each color channel and the eigenvalues of the preset orthogonal image in each color channel to obtain the first eigenvalues of the orthogonal image to be corrected in each color channel and the second eigenvalues of the preset orthogonal image in each color channel includes:
[0012] The characteristic values of the at least part of the corrected area of the orthogonal image to be corrected in each color channel and the characteristic values of the at least part of the preset area of the preset image in each color channel are calculated respectively to obtain the first characteristic value of the at least part of the corrected area in each color channel and the second characteristic value of the at least part of the preset area in each color channel.
[0013] According to the image correction method of the present application, the correcting the image to be corrected based on the first eigenvalue of each color channel and the second eigenvalue of each color channel includes:
[0014] Respectively calculating a mapping relationship between the first eigenvalue and the second eigenvalue under the same color channel;
[0015] Based on the mapping relationship, the image to be corrected is corrected.
[0016] According to the image correction method of the present application, the step of correcting the image to be corrected based on the mapping relationship includes:
[0017] Based on the mapping relationship of the target color channel in each color channel, the pixel value corresponding to the target pixel position in the target color channel is processed to obtain a corrected pixel value;
[0018] Based on the corrected pixel values, the target color channel of the image to be corrected is corrected.
[0019] According to the image correction method of the present application, the correcting the image to be corrected based on the first eigenvalue of each color channel and the second eigenvalue of each color channel includes:
[0020] Based on the first eigenvalues of the color channels and the second eigenvalues of the color channels, the image to be corrected is corrected to obtain a corrected image to be corrected in the orthogonal color space;
[0021] The corrected image to be corrected is converted into a required color space.
[0022] According to the image correction method of the present application, the image to be corrected is converted into an orthogonal color space to obtain an orthogonal image to be corrected, and the preset image is converted into the orthogonal color space to obtain a preset orthogonal image, including:
[0023] Acquire a conversion relationship between the current color space of the image to be corrected and the current color space of the preset image and the orthogonal color space;
[0024] Based on the conversion relationship, the image to be corrected and the preset image are respectively converted into the orthogonal color space to obtain the orthogonal image to be corrected and the preset orthogonal image.
[0025] In a second aspect, the present application provides an image correction device, the device comprising:
[0026] A first processing module, used for converting the image to be corrected into an orthogonal color space to obtain an orthogonal image to be corrected, and converting a preset image into the orthogonal color space to obtain a preset orthogonal image;
[0027] A second processing module is used to calculate the characteristic value of the orthogonal image to be corrected in each color channel and the characteristic value of the preset orthogonal image in each color channel, respectively, to obtain the first characteristic value of the orthogonal image to be corrected in each color channel and the second characteristic value of the preset orthogonal image in each color channel; the first characteristic value of each color channel corresponds to the second characteristic value of each color channel one by one;
[0028] The third processing module is used to correct the image to be corrected based on the first characteristic value of each color channel and the second characteristic value of each color channel.
[0029] According to the image correction device of the present application, the orthogonal image to be corrected and the preset orthogonal image are obtained by converting the image to be corrected into an orthogonal color space and converting the preset image into an orthogonal color space, and the eigenvalues of the orthogonal image to be corrected and the preset orthogonal image in the orthogonal color space are calculated respectively. The eigenvalue of the preset orthogonal image is used as a reference, and based on the independent characteristics of each color channel in the orthogonal color space, the image to be corrected is corrected, the correction effect is improved, and the correction method is convenient.
[0030] In a third aspect, the present application provides an electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the image correction method as described in the first aspect above when executing the computer program.
[0031] In a fourth aspect, the present application provides a non-transitory computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the image correction method as described in the first aspect above.
[0032] In a fifth aspect, the present application provides a computer program product, including a computer program, which, when executed by a processor, implements the image correction method as described in the first aspect above.
[0033] The above one or more technical solutions in the embodiments of the present application have at least one of the following technical effects:
[0034] The orthogonal image to be corrected and the preset orthogonal image are obtained by converting the image to be corrected into an orthogonal color space and converting the preset image into an orthogonal color space, and the eigenvalues of the orthogonal image to be corrected and the preset orthogonal image in the orthogonal color space are calculated respectively. The eigenvalue of the preset orthogonal image is used as a reference, and based on the independent characteristics of each color channel in the orthogonal color space, the image to be corrected is corrected to improve the correction effect, and the correction method is convenient.
[0035] Furthermore, by selecting at least part of the correction area from the image to be corrected, converting the area to an orthogonal color space to obtain an orthogonal image to be corrected, determining at least part of a preset area from a preset image, converting at least part of the preset area to an orthogonal color space to obtain a preset orthogonal image, local color correction of the image to be corrected is achieved, thereby improving the flexibility of correction and increasing the breadth of applicability.
[0036] Furthermore, by respectively calculating the mapping relationship between the first eigenvalue and the second eigenvalue under the same color channel, a mapping relationship of mapping the first eigenvalue under the same color channel to the second eigenvalue is obtained. Based on the mapping relationship, the alignment accuracy of the first eigenvalue and the second eigenvalue under the same color channel is improved, thereby improving the correction accuracy and correction efficiency.
[0037] Furthermore, the pixel value at the target pixel position of the target color channel is corrected to correct the target color channel, further refine the correction unit, and improve the correction accuracy of the image to be corrected.
[0038] Additional aspects and advantages of the present application will be given in part in the description below, and in part will become apparent from the description below, or will be learned through the practice of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] The above and / or additional aspects and advantages of the present application will become apparent and easily understood from the description of the embodiments in conjunction with the following drawings, in which:
[0040] Figure 1 This is one of the flowcharts of the image correction method provided in the embodiment of the present application;
[0041] Figure 2 This is the second flow chart of the image correction method provided in the embodiment of the present application;
[0042] Figure 3 This is the third flow chart of the image correction method provided in the embodiment of the present application;
[0043] Figure 4 is a structural schematic diagram of an image correction device provided in an embodiment of the present application;
[0044] Figure 5 It is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0045] The following will be combined with the drawings in the embodiments of the present application to clearly describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments in the present application belong to the scope of protection of this application.
[0046] The terms "first", "second", etc. in the specification and claims of this application are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable under appropriate circumstances, so that the embodiments of the present application can be implemented in an order other than those illustrated or described here, and the objects distinguished by "first", "second", etc. are generally of one type, and the number of objects is not limited. For example, the first object can be one or more. In addition, "and / or" in the specification and claims represents at least one of the connected objects, and the character " / " generally indicates that the objects associated with each other are in an "or" relationship.
[0047] The image correction method, image correction device, electronic device and readable storage medium provided in the embodiments of the present application are described in detail below with reference to the accompanying drawings through specific embodiments and their application scenarios.
[0048] The image correction method may be applied to a terminal, and may be specifically executed by hardware or software in the terminal.
[0049] The terminal includes but is not limited to portable communication devices such as mobile phones or tablet computers. It should also be understood that in some embodiments, the terminal may not be a portable communication device, but a desktop computer.
[0050] In the following various embodiments, a terminal including a display and a touch-sensitive surface is described. However, it should be understood that the terminal may include one or more other physical user interface devices such as a physical keyboard, a mouse and a joystick.
[0051] The image correction method provided in the embodiment of the present application may be executed by an electronic device or a functional module or functional entity in the electronic device that can implement the image correction method. The electronic devices mentioned in the embodiment of the present application include but are not limited to mobile phones, tablet computers, computers, cameras, and wearable devices. The image correction method provided in the embodiment of the present application is described below using an electronic device as an example of the execution subject.
[0052] like Figure 1 As shown, the image correction method includes: step 110, step 120 and step 130.
[0053] The image correction method can be applied in industrial inspection scenarios, for example, by collecting images of automated machinery products and production products to inspect automated machinery products and production products.
[0054] Step 110: convert the image to be corrected into an orthogonal color space to obtain an orthogonal image to be corrected, and convert the preset image into an orthogonal color space to obtain a preset orthogonal image;
[0055] In this step, the image to be corrected is an image with chromatic aberration that needs to be corrected.
[0056] The image to be corrected can be obtained by photographing an image sensor.
[0057] For example, when it is necessary to detect product A in an industrial scene, an image of product A can be captured by an image sensor to obtain an image to be corrected.
[0058] The preset image is a predetermined image having the same photographed object as the image to be corrected.
[0059] For example, in an industrial inspection scenario, you can first collect multiple images of product A in the industrial scene, select the one with the best shooting effect from the multiple images as the preset image, and in the subsequent inspection process, use the preset image as a reference to correct the image to be corrected.
[0060] The preset image may be an image with high user satisfaction selected by the user from multiple images, or the preset image may also be determined based on actual conditions, which is not limited in this application.
[0061] The shooting conditions such as shooting angle and lighting direction of the image to be corrected and the preset image are the same. However, due to the influence of imaging instability, there may be differences between the image to be corrected and the preset image.
[0062] An orthogonal color space is a color space in which the color components are mutually orthogonal or approximately orthogonal.
[0063] It should be noted that the orthogonality of the color space enables the color components to have better independence and separation when representing colors.
[0064] Orthogonal color spaces include: Lαβ color space and brightness-phase color-orthogonal color (YIQ) color space, etc.
[0065] In the actual implementation process, the selection of the orthogonal color space can be based on user customization or based on actual conditions, and this application does not limit it.
[0066] The orthogonal image to be corrected is an image to be corrected in an orthogonal color space.
[0067] The preset orthogonal image is a preset image in an orthogonal color space.
[0068] The color space of the image to be corrected and the color space of the preset image may be a red-green-blue (RGB) color space.
[0069] It should be noted that any color in the RGB color space is obtained by mixing the three primary colors of red, green and blue in different proportions. It is difficult to correct the color of the image to be corrected by changing the colors of the three channels.
[0070] like Figure 2 As shown, in the actual implementation process, when the color space of the image to be corrected and the color space of the preset image are RGB color spaces, the color space to be converted can be selected, such as converting the image to be corrected and the preset image to Lαβ color space, respectively, to obtain the orthogonal image to be corrected and the preset orthogonal image.
[0071] Step 120, respectively calculating the eigenvalues of the orthogonal image to be corrected in each color channel and the eigenvalues of the preset orthogonal image in each color channel, to obtain the first eigenvalues of the orthogonal image to be corrected in each color channel and the second eigenvalues of the preset orthogonal image in each color channel; the first eigenvalues of each color channel correspond to the second eigenvalues of each color channel one by one;
[0072] In this step, the three color channels of the orthogonal image to be corrected are axially orthogonal.
[0073] The three color channels of the orthogonal image are axially orthogonal.
[0074] It should be noted that, when the axes of the color channels are orthogonal, changing any color channel does not affect the other two color channels. This correlation allows the three color channels to be processed separately.
[0075] The eigenvalue can be a numerical value representing the color distribution of the image calculated based on the actual situation of the image.
[0076] The eigenvalues can be mean and variance, etc.
[0077] It is understandable that the image color distribution of each color channel is different, and the calculated eigenvalues will also be different.
[0078] The first eigenvalue is the eigenvalue of the orthogonal image to be corrected in each color channel.
[0079] The second eigenvalue is a eigenvalue of a preset orthogonal image in each color channel.
[0080] It can be understood that both the orthogonal image to be corrected and the preset orthogonal image include three color channels, namely, a first color channel, a second color channel and a third color channel.
[0081] The first color channel of the orthogonal image to be corrected corresponds to the first color channel of the preset orthogonal image.
[0082] The second color channel of the orthogonal image to be corrected corresponds to the second color channel of the preset orthogonal image.
[0083] The third color channel of the orthogonal image to be corrected corresponds to the third color channel of the preset orthogonal image.
[0084] The first eigenvalue of the first color channel of the orthogonal image to be corrected corresponds to the second eigenvalue of the first color channel of the preset orthogonal image.
[0085] The first eigenvalue of the second color channel of the orthogonal image to be corrected corresponds to the second eigenvalue of the second color channel of the preset orthogonal image.
[0086] The first eigenvalue of the third color channel of the orthogonal image to be corrected corresponds to the second eigenvalue of the third color channel of the preset orthogonal image.
[0087] Step 130: Correct the image to be corrected based on the first eigenvalue of each color channel and the second eigenvalue of each color channel.
[0088] In this step, after the first eigenvalue of each color channel and the second eigenvalue of each color channel are calculated, the first eigenvalue of each color channel can be converted into the second eigenvalue of each color channel.
[0089] For example, when the first eigenvalue of the first color channel of the orthogonal image to be corrected is 15 and the second eigenvalue of the first color channel of the preset orthogonal image is 10, the first eigenvalue 15 of the first color channel of the orthogonal image to be corrected is converted into 10.
[0090] When the first eigenvalue of the second color channel of the orthogonal image to be corrected is 20 and the second eigenvalue of the first color channel of the preset orthogonal image is 25, the first eigenvalue 20 of the second color channel of the orthogonal image to be corrected is converted into 25.
[0091] When the first eigenvalue of the third color channel of the orthogonal image to be corrected is 10 and the second eigenvalue of the third color channel of the preset orthogonal image is 12, the first eigenvalue 10 of the third color channel of the orthogonal image to be corrected is converted into 12.
[0092] In the actual implementation process, after the three color channels of the orthogonal image to be corrected are corrected respectively, the correction of the image to be corrected is completed. At this time, it can be approximately considered that there is no color difference between the orthogonal image to be corrected and the preset orthogonal image.
[0093] During the research and development process, the inventors found that in industrial inspection scenarios, due to unstable imaging, the reflection of the material itself may cause color differences between different images, or the color difference of the material itself may cause unstable color extraction. In the related art, the method of color correction has a large amount of image processing calculation, poor correction effect and a small scope of application.
[0094] The present application converts the image to be corrected and the preset image into orthogonal color space respectively, and utilizes the characteristics of the orthogonal color space, that is, the color channels are axially orthogonal, and changing any channel will not affect other color channels. Each color channel can be corrected separately, and each color channel is opposite to each other, and the natural effect of the image to be corrected is not changed, thereby improving the correction effect. In addition, in the correction process, by respectively calculating the eigenvalues of the orthogonal image to be corrected on each color channel and the eigenvalues of the preset orthogonal image on each color channel, the second eigenvalues of the orthogonal image to be corrected on each color channel are corrected based on the second eigenvalues of the preset orthogonal image on each color channel. The correction process directly acts on the entire image to be corrected, and there is no need to distinguish between the foreground and background of the image to be corrected. The correction method is convenient.
[0095] According to the image correction method provided by the embodiment of the present application, the orthogonal image to be corrected and the preset orthogonal image are obtained by converting the image to be corrected into an orthogonal color space and converting the preset image into an orthogonal color space, and the eigenvalues of the orthogonal image to be corrected and the preset orthogonal image in the orthogonal color space are calculated respectively. The eigenvalue of the preset orthogonal image is used as a reference, and based on the independent characteristics of each color channel in the orthogonal color space, the image to be corrected is corrected, the correction effect is improved, and the correction method is convenient.
[0096] In some embodiments, step 110 may further include:
[0097] Convert at least part of the correction area of the image to be corrected to the orthogonal color space to obtain the orthogonal image to be corrected; convert at least part of the preset area of the preset image to the orthogonal color space to obtain the preset orthogonal image; at least part of the correction area corresponds to at least part of the preset area.
[0098] In this embodiment, at least part of the correction area is an area where color aberration exists in the image to be corrected and needs to be corrected.
[0099] At least part of the preset area is the same area as the photographed object included in at least part of the correction area.
[0100] At least part of the correction area may be an area consisting of one or more areas to be corrected on the image to be corrected.
[0101] For example, at least part of the correction area can be based on user customization, such as an area of interest set by the user, or an area where a product feature is located. At least part of the correction area can also be determined based on actual conditions, which is not limited in this application.
[0102] Likewise, at least part of the preset area may also be one or more areas on the preset image corresponding to at least part of the correction area.
[0103] In the actual implementation process, after determining at least part of the correction area and at least part of the preset area, at least part of the correction area and at least part of the preset area are respectively converted into orthogonal color space to obtain the orthogonal image to be corrected and the preset orthogonal image.
[0104] The remaining area of the image to be corrected except at least a part of the correction area does not need to be converted into the orthogonal color space, and the remaining area can keep the color space to which it belongs unchanged.
[0105] Likewise, the remaining area of the preset image except at least a portion of the preset area does not need to be converted into the orthogonal color space, and the remaining area can keep the color space to which it belongs unchanged.
[0106] According to the image correction method provided by the embodiment of the present application, by selecting at least a part of the correction area from the image to be corrected, converting the area to an orthogonal color space, obtaining the orthogonal image to be corrected, determining at least a part of the preset area from the preset image, converting at least a part of the preset area to an orthogonal color space, obtaining the preset orthogonal image, local color correction of the image to be corrected is achieved, the flexibility of correction is improved and the breadth of applicability is increased, there is no need to process areas of no interest in the image, and the image processing efficiency is improved.
[0107] In some embodiments, step 120 may further include:
[0108] The characteristic values of at least part of the correction area of the orthogonal image to be corrected in each color channel and the characteristic values of at least part of the preset area of the preset image in each color channel are calculated respectively to obtain the first characteristic value of at least part of the correction area in each color channel and the second characteristic value of at least part of the preset area in each color channel.
[0109] In this embodiment, in the actual implementation process, after obtaining the orthogonal image to be corrected and the preset orthogonal image, the characteristic values of at least part of the corrected area in each color channel and the characteristic values of at least part of the preset area in each color channel are calculated.
[0110] That is, the first eigenvalue of at least part of the correction region in the first color channel, the first eigenvalue of at least part of the correction region in the second color channel, and the first eigenvalue of at least part of the correction region in the third color channel are calculated.
[0111] The second eigenvalue of at least part of the preset area in the first color channel, the second eigenvalue of at least part of the preset area in the second color channel, and the second eigenvalue of at least part of the preset area in the third color channel are calculated.
[0112] It can be understood that, for the remaining area of the orthogonal image to be corrected except for at least a part of the correction area, it remains unchanged and there is no need to calculate the characteristic value.
[0113] Similarly, the remaining area of the preset orthogonal image except at least a portion of the preset area remains unchanged, and there is no need to calculate the eigenvalue.
[0114] According to the image correction method provided in the embodiment of the present application, by calculating the characteristic values of at least part of the correction area in each color channel and the characteristic values of at least part of the preset area in each color channel, the color distribution characteristics of at least part of the correction area and the color distribution characteristics of at least part of the preset area are obtained, and there is no need to process irrelevant parts of the image, thereby improving the flexibility of image processing and effectively improving the image processing efficiency.
[0115] In some embodiments, step 110 may further include:
[0116] Obtaining a conversion relationship between a current color space of an image to be corrected and a current color space of a preset image and an orthogonal color space;
[0117] Based on the conversion relationship, the image to be corrected and the preset image are respectively converted into orthogonal color spaces to obtain the orthogonal image to be corrected and the preset orthogonal image.
[0118] In this embodiment, the current color space is the color space to which the image belongs before correction is performed.
[0119] The current color space may be: RGB color space and Cyan-Magenta-Yellow (CMY) color space, etc.
[0120] The conversion relationship is a conversion formula or a conversion method for converting an image from one color space to another color space.
[0121] The conversion relationship may be a linear conversion relationship or a nonlinear conversion relationship.
[0122] In the actual execution process, after obtaining the conversion relationship between the current color space of the image to be corrected and the current color space of the preset image and the orthogonal color space, the image to be corrected and the preset image can be processed through the conversion relationship, and the image to be corrected can be converted to the orthogonal color space and the preset image can be converted to the orthogonal color space respectively to obtain the orthogonal image to be corrected and the preset orthogonal image.
[0123] According to the image correction method provided in the embodiment of the present application, by obtaining the conversion relationship between the current color space and the orthogonal color space of the image to be corrected and the preset image, the image to be corrected and the preset image are effectively converted to the orthogonal color space through the conversion relationship, thereby improving the precision and accuracy of the color space conversion and reducing the conversion error.
[0124] like Figure 3 As shown, in some embodiments, step 120 may also include:
[0125] Calculate the mapping relationship between the first eigenvalue and the second eigenvalue under the same color channel respectively;
[0126] Based on the mapping relationship, the image to be corrected is corrected.
[0127] In this embodiment, the mapping relationship is a relationship of mapping the first eigenvalue to the second eigenvalue.
[0128] For example, in the case where the first eigenvalue of the first color channel of the orthogonal image to be corrected and the preset orthogonal image is 15 and the second eigenvalue is 10, the mapping relationship may be:
[0129]
[0130] It can be understood that the mapping relationship between the second color channel and the third color channel can be calculated in the above manner.
[0131] In the actual implementation process, after the mapping relationship of each color channel is obtained, each color channel of the orthogonal image to be corrected can be corrected respectively based on the mapping relationship of each color channel.
[0132] like Figure 3 As shown, after the image to be corrected and the preset image are converted into the orthogonal color space, the orthogonal image to be corrected and the preset orthogonal image can be obtained.
[0133] The second eigenvalue of each color channel of the preset image and the first eigenvalue of each color channel of the orthogonal image to be corrected can be calculated respectively, and the mapping relationship of each color channel is calculated based on the first eigenvalue and the second eigenvalue of each color channel, and the image to be corrected is corrected based on the mapping relationship.
[0134] According to the image correction method provided in the embodiment of the present application, by respectively calculating the mapping relationship between the first eigenvalue and the second eigenvalue under the same color channel, a mapping relationship of mapping the first eigenvalue under the same color channel to the second eigenvalue is obtained, and based on the mapping relationship, the alignment accuracy of the first eigenvalue and the second eigenvalue under the same color channel is improved, thereby improving the correction accuracy and correction efficiency.
[0135] In some embodiments, correcting the image to be corrected based on the mapping relationship may further include:
[0136] Based on the mapping relationship between the target color channels in each color channel, the pixel value corresponding to the target pixel position in the target color channel is processed to obtain a corrected pixel value;
[0137] Based on the correction pixel values, the target color channel of the image to be corrected is corrected.
[0138] In this embodiment, the target color channel is any one of the three color channels in the orthogonal color space.
[0139] The target pixel position is the position of any pixel point on the target color channel.
[0140] The pixel value is the actual pixel value at the target pixel location.
[0141] The corrected pixel value is a pixel value obtained by correcting the pixel value at the target pixel position.
[0142] For example, the pixel value corresponding to the target pixel position is 12, and the mapping relationship is: In the case of, the pixel value corresponding to the target pixel position is corrected, and the corrected pixel value is That is, after the target pixel position is corrected, the corrected pixel value obtained is 8.
[0143] It should be noted that all pixel positions on the target color channel can be corrected in the same manner as the target pixel position to complete the correction of the target color channel.
[0144] Similarly, the three color channels of the orthogonal space can be corrected in the same manner as the target color channel to complete the correction of the image to be corrected.
[0145] According to the image correction method provided in the embodiment of the present application, the pixel value of the target pixel position of the target color channel is corrected through the mapping relationship of the target color channel to correct the target color channel, further refine the correction unit, and improve the correction accuracy of the image to be corrected.
[0146] In some embodiments, step 130 may further include:
[0147] Based on the first eigenvalue of each color channel and the second eigenvalue of each color channel, the image to be corrected is corrected to obtain a corrected image to be corrected in an orthogonal color space;
[0148] Convert the corrected image to the required color space.
[0149] In this embodiment, the corrected image to be corrected is an image still in the orthogonal color space obtained after the image to be corrected is corrected.
[0150] The required color space is the color space required for subsequent use of the image to be corrected.
[0151] The required color space may be the color space before conversion to the orthogonal color space, or may be a color space different from the color space before conversion to the orthogonal color space.
[0152] The required color space can be customized by the user or determined based on actual conditions, and this application does not limit it.
[0153] For example, if the image to be corrected is an image in an RGB color space, the image to be corrected is converted to an orthogonal color space for correction, and the corrected image to be corrected is converted back to the RGB color space for subsequent use.
[0154] According to the image correction method provided in the embodiment of the present application, by converting the corrected image to be corrected in the orthogonal color space to the required color space, an image to be corrected that meets subsequent usage requirements is obtained, thereby improving the user experience.
[0155] The image correction method provided in the embodiment of the present application can be executed by an image correction device. In the embodiment of the present application, the image correction device provided in the embodiment of the present application is described by taking the image correction device executing the image correction method as an example.
[0156] The embodiment of the present application also provides an image correction device.
[0157] like Figure 4 As shown, the image correction device includes: a first processing module 410 , a second processing module 420 and a third processing module 430 .
[0158] The first processing module 410 is used to convert the image to be corrected into an orthogonal color space to obtain an orthogonal image to be corrected, and convert the preset image into an orthogonal color space to obtain a preset orthogonal image;
[0159] The second processing module 420 is used to calculate the eigenvalues of the orthogonal image to be corrected in each color channel and the eigenvalues of the preset orthogonal image in each color channel, respectively, to obtain the first eigenvalues of the orthogonal image to be corrected in each color channel and the second eigenvalues of the preset orthogonal image in each color channel; the first eigenvalues of each color channel correspond to the second eigenvalues of each color channel one by one;
[0160] The third processing module 430 is used to correct the image to be corrected based on the first characteristic value of each color channel and the second characteristic value of each color channel.
[0161] According to the image correction device provided by the embodiment of the present application, the orthogonal image to be corrected and the preset orthogonal image are obtained by converting the image to be corrected into an orthogonal color space and converting the preset image into an orthogonal color space, and the eigenvalues of the orthogonal image to be corrected and the preset orthogonal image in the orthogonal color space are calculated respectively. The eigenvalue of the preset orthogonal image is used as a reference, and based on the independent characteristics of each color channel in the orthogonal color space, the image to be corrected is corrected, the correction effect is improved, and the correction method is convenient.
[0162] In some embodiments, the first processing module 410 may also be used to:
[0163] Convert at least part of the correction area of the image to be corrected to the orthogonal color space to obtain the orthogonal image to be corrected; convert at least part of the preset area of the preset image to the orthogonal color space to obtain the preset orthogonal image; at least part of the correction area corresponds to at least part of the preset area.
[0164] In some embodiments, the second processing module 420 may also be used to:
[0165] The characteristic values of at least part of the correction area of the orthogonal image to be corrected in each color channel and the characteristic values of at least part of the preset area of the preset image in each color channel are calculated respectively to obtain the first characteristic value of at least part of the correction area in each color channel and the second characteristic value of at least part of the preset area in each color channel.
[0166] In some embodiments, the third processing module 430 may also be used to:
[0167] Respectively calculate the mapping relationship between the first eigenvalue and the second eigenvalue under the same color channel;
[0168] Based on the mapping relationship, the image to be corrected is corrected.
[0169] In some embodiments, the third processing module 430 may also be used to:
[0170] Based on the mapping relationship between the target color channels in each color channel, the pixel value corresponding to the target pixel position in the target color channel is processed to obtain a corrected pixel value;
[0171] Based on the correction pixel values, the target color channel of the image to be corrected is corrected.
[0172] In some embodiments, the third processing module 430 may also be used to:
[0173] Based on the first eigenvalue of each color channel and the second eigenvalue of each color channel, the image to be corrected is corrected to obtain a corrected image to be corrected in an orthogonal color space;
[0174] Convert the corrected image to the required color space.
[0175] In some embodiments, the first processing module 410 may also be used to:
[0176] Obtaining a conversion relationship between a current color space of an image to be corrected and a current color space of a preset image and an orthogonal color space;
[0177] Based on the conversion relationship, the image to be corrected and the preset image are respectively converted into orthogonal color spaces to obtain the orthogonal image to be corrected and the preset orthogonal image.
[0178] The image correction device in the embodiment of the present application can be an electronic device, or a component in the electronic device, such as an integrated circuit or a chip. The electronic device can be a terminal, or other devices other than the terminal. Exemplarily, the electronic device can be a mobile phone, a tablet computer, a laptop computer, a palmtop computer, a vehicle-mounted electronic device, a mobile Internet device (Mobile Internet Device, MID), an augmented reality (augmented reality, AR) / virtual reality (virtual reality, VR) device, a robot, a wearable device, an ultra-mobile personal computer (ultra-mobile personal computer, UMPC), a netbook or a personal digital assistant (personal digital assistant, PDA), etc., and can also be a server, a network attached storage (Network Attached Storage, NAS), a personal computer (personal computer, PC), a television (television, TV), a teller machine or a self-service machine, etc., and the embodiment of the present application is not specifically limited.
[0179] The image correction device in the embodiment of the present application may be a device having an operating system. The operating system may be an Android operating system, an IOS operating system, or other possible operating systems, which are not specifically limited in the embodiment of the present application.
[0180] The image correction device provided in the embodiment of the present application can achieve Figures 1 to 3 To avoid repetition, the various processes implemented by the method embodiment are not described here.
[0181] In some embodiments, Figure 5 As shown, an embodiment of the present application also provides an electronic device 500, including a processor 501, a memory 502, and a computer program stored in the memory 502 and executable on the processor 501. When the program is executed by the processor 501, each process of the above-mentioned image correction method embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it will not be described here.
[0182] It should be noted that the electronic devices in the embodiments of the present application include the mobile electronic devices and non-mobile electronic devices mentioned above.
[0183] An embodiment of the present application also provides a non-transitory computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the various processes of the above-mentioned image correction method embodiment are implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.
[0184] The processor is the processor in the electronic device described in the above embodiment. The readable storage medium includes a computer readable storage medium, such as a computer read-only memory ROM, a random access memory RAM, a magnetic disk or an optical disk.
[0185] An embodiment of the present application also provides a computer program product, including a computer program, which implements the above-mentioned image correction method when executed by a processor.
[0186] The processor is the processor in the electronic device described in the above embodiment. The readable storage medium includes a computer readable storage medium, such as a computer read-only memory ROM, a random access memory RAM, a magnetic disk or an optical disk.
[0187] An embodiment of the present application further provides a chip, which includes a processor and a communication interface, wherein the communication interface is coupled to the processor, and the processor is used to run programs or instructions to implement the various processes of the above-mentioned image correction method embodiment, and can achieve the same technical effect. To avoid repetition, it will not be repeated here.
[0188] It should be understood that the chip mentioned in the embodiments of the present application can also be called a system-level chip, a system chip, a chip system or a system-on-chip chip, etc.
[0189] It should be noted that, in this article, the terms "comprise", "include" or any other variant thereof are intended to cover non-exclusive inclusion, so that the process, method, article or device including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise one..." do not exclude the presence of other identical elements in the process, method, article or device including the element. In addition, it should be pointed out that the scope of the methods and devices in the embodiments of the present application is not limited to performing functions in the order shown or discussed, and may also include performing functions in a substantially simultaneous manner or in reverse order according to the functions involved, for example, the described method may be performed in an order different from that described, and various steps may also be added, omitted, or combined. In addition, the features described with reference to certain examples may be combined in other examples.
[0190] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the relevant technology, can be embodied in the form of a computer software product, which is stored in a storage medium (such as ROM / RAM, a disk, or an optical disk), and includes a number of instructions for a terminal (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present application.
[0191] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of the present application, ordinary technicians in this field can also make many forms without departing from the purpose of the present application and the scope of protection of the claims, all of which are within the protection of the present application.
[0192] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "illustrative embodiments", "examples", "specific examples", or "some examples" means that the specific features, structures, materials, or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present application. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials, or characteristics described may be combined in any one or more embodiments or examples in a suitable manner.
[0193] Although the embodiments of the present application have been shown and described, those skilled in the art will appreciate that various changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the present application, and that the scope of the present application is defined by the claims and their equivalents.
Claims
1. An image correction method, characterized in that: include: Converting the image to be corrected into an orthogonal color space to obtain an orthogonal image to be corrected, and converting a preset image into the orthogonal color space to obtain a preset orthogonal image; Calculating the characteristic values of the orthogonal image to be corrected in each color channel and the characteristic values of the preset orthogonal image in each color channel respectively, to obtain the first characteristic value of the orthogonal image to be corrected in each color channel and the second characteristic value of the preset orthogonal image in each color channel; The first characteristic value of each color channel corresponds to the second characteristic value of each color channel one by one; The image to be corrected is corrected based on the first characteristic value of each color channel and the second characteristic value of each color channel.
2. The image correction method according to claim 1, characterized in that: The step of converting the image to be corrected into an orthogonal color space to obtain an orthogonal image to be corrected, and converting a preset image into the orthogonal color space to obtain a preset orthogonal image, comprises: Convert at least part of the correction area of the image to be corrected to the orthogonal color space to obtain the orthogonal image to be corrected; convert at least part of the preset area of the preset image to the orthogonal color space to obtain the preset orthogonal image; the at least part of the correction area corresponds to the at least part of the preset area.
3. The image correction method according to claim 2, characterized in that: The step of respectively calculating the characteristic values of the orthogonal image to be corrected in each color channel and the characteristic values of the preset orthogonal image in each color channel to obtain the first characteristic value of the orthogonal image to be corrected in each color channel and the second characteristic value of the preset orthogonal image in each color channel comprises: The characteristic values of the at least part of the corrected area of the orthogonal image to be corrected in each color channel and the characteristic values of the at least part of the preset area of the preset image in each color channel are calculated respectively to obtain the first characteristic value of the at least part of the corrected area in each color channel and the second characteristic value of the at least part of the preset area in each color channel.
4. The image correction method according to any one of claims 1 to 3, characterized in that: The correcting the image to be corrected based on the first characteristic value of each color channel and the second characteristic value of each color channel comprises: Respectively calculating a mapping relationship between the first eigenvalue and the second eigenvalue under the same color channel; Based on the mapping relationship, the image to be corrected is corrected.
5. The image correction method according to claim 4, characterized in that: The correcting the image to be corrected based on the mapping relationship includes: Based on the mapping relationship of the target color channel in each color channel, the pixel value corresponding to the target pixel position in the target color channel is processed to obtain a corrected pixel value; Based on the corrected pixel values, the target color channel of the image to be corrected is corrected.
6. The image correction method according to any one of claims 1 to 3, characterized in that: The correcting the image to be corrected based on the first characteristic value of each color channel and the second characteristic value of each color channel comprises: Based on the first eigenvalues of the color channels and the second eigenvalues of the color channels, the image to be corrected is corrected to obtain a corrected image to be corrected in the orthogonal color space; The corrected image to be corrected is converted into a required color space.
7. The image correction method according to any one of claims 1 to 3, characterized in that: The step of converting the image to be corrected into an orthogonal color space to obtain an orthogonal image to be corrected, and converting a preset image into the orthogonal color space to obtain a preset orthogonal image, comprises: Acquire a conversion relationship between the current color space of the image to be corrected and the current color space of the preset image and the orthogonal color space; Based on the conversion relationship, the image to be corrected and the preset image are respectively converted into the orthogonal color space to obtain the orthogonal image to be corrected and the preset orthogonal image.
8. An image correction device, characterized in that: include: A first processing module, used for converting the image to be corrected into an orthogonal color space to obtain an orthogonal image to be corrected, and converting a preset image into the orthogonal color space to obtain a preset orthogonal image; A second processing module is used to calculate the eigenvalues of the orthogonal image to be corrected in each color channel and the eigenvalues of the preset orthogonal image in each color channel, respectively, to obtain the first eigenvalues of the orthogonal image to be corrected in each color channel and the second eigenvalues of the preset orthogonal image in each color channel; The first characteristic value of each color channel corresponds to the second characteristic value of each color channel one by one; The third processing module is used to correct the image to be corrected based on the first characteristic value of each color channel and the second characteristic value of each color channel.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the image correction method according to any one of claims 1 to 7 is implemented.
10. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the image correction method according to any one of claims 1 to 7 is implemented.