Image processing method and device, electronic equipment, storage medium and product
By identifying and analyzing pixel areas that may lead to year-on-year illusions in the image, and adjusting their grayscale values according to the surrounding background colors, the problem of inconsistent color perception in the human eye is solved, and the consistency of color perception is improved.
Patent Information
- Application Number
- CN202411746947.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-29
- Publication Date
- 2025-03-11
AI Technical Summary
In the prior art, year-on-year illusion causes the human eye to perceive different effects of images of the same color under different background colors, resulting in color perception illusion.
By determining the pixel areas in the image where the year-on-year illusion may occur and analyzing them according to the surrounding background colors of these areas, the grayscale values of these pixel areas are adjusted to weaken or eliminate the year-on-year illusion.
Effectively weaken or eliminate the illusion of the human eye year-on-year, and improve the perceived consistency of the human eye for color.
Smart Images

Figure CN119599929A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of image processing technology, and in particular to an image processing method, device, electronic device, storage medium and product. Background Art
[0002] Due to the structure of the human eye, there are many illusions when perceiving colors. One of them is the same-color illusion, which refers to the difference in brightness or saturation of a certain color caused by the influence of the surrounding colors. For example, an image with the same grayscale value will appear brighter against a dark background and darker against a light background. Similarly, when a display device displays an image or video, some parts of the screen will appear different in the human eye due to the difference in background color, even images of the same color, thus causing color perception illusions. Summary of the invention
[0003] The embodiments of the present application provide an image processing method, device, electronic device, computer-readable storage medium, and computer program product to alleviate or solve one or more technical problems existing in the prior art.
[0004] In a first aspect, an embodiment of the present application provides an image processing method, comprising:
[0005] Determine a first pixel region and a second pixel region in the original image, wherein the first pixel region and the second pixel region are not connected, and an absolute value of a difference between a grayscale value of the first pixel region and a grayscale value of the second pixel region is less than a first preset value;
[0006] Determine a first adjacent region adjacent to the first pixel region, and a second adjacent region adjacent to the second pixel region, wherein each of the first adjacent region and the second adjacent region includes at least one pixel region;
[0007] The grayscale value of the first pixel region and / or the second pixel region is adjusted according to the grayscale value of each pixel region in the first adjacent region and the grayscale value of each pixel region in the second adjacent region.
[0008] In a second aspect, an embodiment of the present application provides an image processing device, including:
[0009] A first determination module is used to determine a first pixel region and a second pixel region in the original image, wherein the first pixel region and the second pixel region are not connected, and an absolute value of a difference between a grayscale value of the first pixel region and a grayscale value of the second pixel region is less than a first preset value;
[0010] A second determining module, configured to determine a first adjacent region adjacent to the first pixel region and a second adjacent region adjacent to the second pixel region, wherein each of the first adjacent region and the second adjacent region includes at least one pixel region;
[0011] The grayscale value adjustment module is used to adjust the grayscale value of the first pixel area and / or the second pixel area according to the grayscale value of each pixel area in the first adjacent area and the grayscale value of each pixel area in the second adjacent area.
[0012] In a third aspect, an embodiment of the present application provides an electronic device, including a memory, a processor, and a computer program stored in the memory, and the processor implements any method of the embodiment of the present application when executing the computer program.
[0013] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, the method of any one of the embodiments of the present application is implemented.
[0014] In a fifth aspect, an embodiment of the present application provides a computer program product, including a computer program, which implements any method of the embodiments of the present application when executed by a processor.
[0015] Based on the method of the embodiment of the present application, one or more pairs of pixel areas where the year-on-year illusion may occur can be determined in the image, and the surrounding background colors of these pixel areas can be analyzed, and then the grayscale values of these pixel areas can be adjusted based on the analysis results to weaken or eliminate the year-on-year illusion of the human eye and improve the consistency between the color perceived by the human eye and the actual color.
[0016] The above description is only an overview of the technical solution of the present application. In order to more clearly understand the technical means of the present application, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present application more obvious and easy to understand, the specific implementation methods of the present application are listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] The accompanying drawings are used to better understand the present solution and do not constitute a limitation of the present application.
[0018] Figure 1 is a schematic diagram of a year-on-year illusion effect according to an embodiment of the present application;
[0019] Figure 2 is a schematic diagram of an exemplary hardware structure according to an embodiment of the present application;
[0020] Figure 3 is a flowchart of an image processing method according to an embodiment of the present application;
[0021] Figure 4 This is a schematic diagram of the effect after the first pixel traversal according to an embodiment of the present application;
[0022] Figure 5This is a schematic diagram of the effect after the second pixel traversal according to an embodiment of the present application;
[0023] Figure 6 is with Figure 1 A corresponding schematic diagram of an image effect after adjusting the grayscale value according to the image processing method of an embodiment of the present application;
[0024] Figure 7 is a schematic diagram of an image processing device according to an embodiment of the present application;
[0025] Figure 8 It is a block diagram of an electronic device used to implement the embodiment of the present application. DETAILED DESCRIPTION
[0026] In the following, only some exemplary embodiments are briefly described. As those skilled in the art will appreciate, the described embodiments may be modified in various ways without departing from the concept or scope of the present application. Therefore, the drawings and descriptions are considered to be exemplary in nature and not restrictive.
[0027] To facilitate understanding of the technical solutions of the embodiments of the present application, the following describes the related technologies of the embodiments of the present application. The following related technologies can be combined with the technical solutions of the embodiments of the present application as optional solutions, and they all belong to the protection scope of the embodiments of the present application.
[0028] Figure 1 A schematic diagram of the same-color illusion effect is provided. In the figure, the colors of the B area and the G area are consistent, but because the grayscale value of the area adjacent to the B area is lower (the color is darker), and the grayscale value of the area adjacent to the G area is higher (the color is brighter), the human eye has a same-color illusion when observing the image, causing the human eye to feel that the B area is brighter than the G area.
[0029] Based on this, in order to alleviate or eliminate the "difference in color perception of different areas of the same color or brightness by the human eye" caused by different background brightness, the present application proposes an image processing method, which can determine one or more pairs of pixel areas in the image where the same color illusion may occur, and analyze the surrounding background colors of these pixel areas, and then adjust the grayscale values of these pixel areas based on the analysis results, thereby weakening or eliminating the same color illusion of the human eye and improving the consistency between the color perceived by the human eye and the actual color.
[0030] The image processing method provided in the embodiments of the present application can be applied to electronic devices such as mobile phones, tablet computers, wearable devices, vehicle-mounted devices, augmented reality (AR) / virtual reality (VR) devices, laptops, ultra-mobile personal computers (UMPC), netbooks, personal digital assistants (PDA), and can also be applied to databases, servers, and terminal artificial intelligence-based service response systems. The embodiments of the present application do not impose any restrictions on the specific types of electronic devices.
[0031] In some embodiments, the electronic device may be a device having Figure 2 The exemplary hardware structure of the exemplary mobile phone 200 shown in FIG. Figure 2 As shown, the mobile phone 200 may specifically include: a radio frequency (RF) circuit 210, a memory 220, an input unit 230, a display unit 240, a sensor 250, an audio circuit 260, a short-range wireless communication module 270, a processor 280, and a power supply 290. Those skilled in the art will appreciate that Figure 2 The structure of the mobile phone 200 shown in the figure does not constitute a limitation on the electronic device, and the electronic device may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.
[0032] Combine the following Figure 2 The various components of the mobile phone 200 are introduced in detail:
[0033] The RF circuit 210 can be used for receiving and sending signals during the process of sending and receiving information or making calls. In particular, after receiving the downlink information of the base station, it is sent to the processor 280 for processing; in addition, the data related to the uplink is sent to the base station. Generally, the RF circuit includes but is not limited to an antenna, at least one amplifier, a transceiver, a coupler, a low noise amplifier (Low Noise Amplifier, LNA), a duplexer, etc. In addition, the RF circuit 210 can also communicate with the network and other devices through wireless communication. The above-mentioned wireless communication can use any communication standard or protocol, and the wireless communication can include Global System For Mobile Communications (Global System For Mobile Communications, GSM), General Packet Radio Service (General Packet Radio Service, GPRS), Code Division Multiple Access (Code Division Multiple Access, CDMA), Wideband Code Division Multiple Access (Wideband Code Division Multiple Access, WCDMA), Time Division Code Division Multiple Access (Time-Division Code Division Multiple Access, TD-SCDMA), Long Term Evolution (Long Term Evolution, LTE), New Radio (New Radio, NR), GNSS, FM, low-orbit satellite connection and / or IR technology, etc. GNSS may include the Global Positioning System (GPS), the Global Navigation Satellite System (GLONASS), the BeiDou Navigation Satellite System (BDS), the Quasi-Zenith Satellite System (QZSS) and / or the Satellite Based Augmentation System (SBAS), etc.
[0034] The memory 220 can be used to store software programs and modules. The processor 280 executes various functional applications and data processing of the mobile phone by running the software programs and modules stored in the memory 220. The memory 220 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area may store data created according to the use of the mobile phone (such as pictures, audio data, phone books, etc.), etc. In addition, the memory 220 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices. Specifically, the memory 220 may store pictures taken by an electronic device or downloaded via a wireless network.
[0035] The input unit 230 can be used to receive input digital or character information, and to generate key signal input related to the user settings and function control of the mobile phone 200. Specifically, the input unit 230 may include a touch panel 231 and other input devices 232. The touch panel 231, also known as a touch screen, can collect the user's touch operation on or near it (such as the user using a finger (such as a single finger or multiple fingers), a stylus, or any other suitable object or accessory on the touch panel 231 or near the touch panel 231), and drive the corresponding connection device according to a pre-set program. Optionally, the touch panel 231 may include a touch detection device and a touch controller. Among them, the touch detection device detects the user's touch orientation, detects the signal brought by the touch operation, and transmits the signal to the touch controller; the touch controller receives the touch information from the touch detection device, converts it into the touch point coordinates, and then sends it to the processor 280, and can receive and execute the command sent by the processor 280. In addition, the touch panel 231 can be implemented in various types such as resistive, capacitive, infrared, and surface acoustic waves. In addition to the touch panel 231, the input unit 230 may also include other input devices 232. Specifically, the other input devices 232 may include but are not limited to one or more of a physical keyboard, function keys (such as volume control keys, switch keys, etc.), a trackball, a mouse, a joystick, etc.
[0036] The display unit 240 can be used to display information input by the user or information provided to the user and various menus of the mobile phone. The display unit 240 may include a display panel 241. Optionally, the display panel 241 may be configured in the form of a liquid crystal display (LCD), a light emitting diode (LED), an organic light emitting diode (OLED), an active-matrix organic light emitting diode (AMOLED), etc. Further, the touch panel 231 may cover the display panel 241. When the touch panel 231 detects a touch operation on or near it, it is transmitted to the processor 280 to determine the type of touch event. Subsequently, the processor 280 provides a corresponding visual output on the display panel 241 according to the type of touch event. Although in Figure 2 In the embodiment, the touch panel 231 and the display panel 241 are used as two independent components to implement the input and output functions of the mobile phone, but in some embodiments, the touch panel 231 and the display panel 241 can be integrated to implement the input and output functions of the mobile phone. In at least one embodiment, the display panel 241 can be configured to display the wallpaper or dynamic wallpaper described in any embodiment of the present application.
[0037] The mobile phone 200 may also include at least one sensor 250, such as a light sensor, a motion sensor, and other sensors. Specifically, the light sensor may include an ambient light sensor and a proximity sensor, wherein the ambient light sensor may adjust the brightness of the display panel 241 according to the brightness of the ambient light, and the proximity sensor may turn off the display panel 241 and / or the backlight when the mobile phone is moved to the ear. As a type of motion sensor, the accelerometer sensor can detect the magnitude of acceleration in each direction (generally three axes), and can detect the magnitude and direction of gravity when stationary. It can be used for applications that identify the posture of the mobile phone (such as horizontal and vertical screen switching, related games, magnetometer posture calibration), vibration recognition related functions (such as pedometer, tapping), etc.; as for other sensors that can be configured in the mobile phone, such as gyroscopes, barometers, hygrometers, thermometers, infrared sensors, etc., they will not be repeated here.
[0038] The audio circuit 260, the speaker 261, and the microphone 262 can provide an audio interface between the user and the mobile phone. The audio circuit 260 can transmit the received audio data to the speaker 261 after converting the electrical signal, which is converted into a sound signal for output; on the other hand, the microphone 262 converts the collected sound signal into an electrical signal, which is received by the audio circuit 260 and converted into audio data, and then the audio data is output to the processor 280 for processing, and then sent to another electronic device through the RF circuit 210, or the audio data is output to the memory 220 for further processing.
[0039] Communication technologies such as Wi-Fi, Bluetooth, Near Field Communication (NFC) and Ultra Wide Band (UWB) belong to short-range wireless transmission technologies. The mobile phone can help users send and receive emails, browse web pages and access streaming media through the short-range wireless module 270, which provides users with wireless broadband Internet access. The above-mentioned short-range wireless module 270 may include a Wi-Fi chip, a Bluetooth chip, an NFC chip and a UWB chip. Through the Wi-Fi chip, the mobile phone 200 can achieve the function of Wi-Fi Direct connection with other electronic devices, and can also make the mobile phone 200 work in an AP mode (Access Point mode) that can provide wireless access services and allow other wireless devices to access, or work in a STA mode (Station mode) that can connect to an AP but does not accept wireless devices to access, thereby establishing point-to-point communication between the mobile phone 200 and other Wi-Fi devices.
[0040] The processor 280 is the control center of the mobile phone. It uses various interfaces and lines to connect various parts of the entire mobile phone. By running or executing software programs and / or modules stored in the memory 220, and calling data stored in the memory 220, it executes various functions of the mobile phone and processes data, thereby monitoring the mobile phone as a whole. Optionally, the processor 280 may include one or more processing units; optionally, the processor 280 may include, for example, an application processor (Application Processor, AP), a modem processor, a graphics processor (Graphics Processing Unit, GPU), an image signal processor (Image Signal Processor, ISP), a controller, a video codec, a digital signal processor (Digital Signal Processor, DSP), a baseband processor, and / or a neural network processor (Neural-Network Processing Unit, NPU), etc. Among them, different processing units can be independent devices or integrated in one or more processors.
[0041] The mobile phone 200 also includes a power source 290 (such as a battery) for supplying power to various components. Preferably, the power source can be logically connected to the processor 280 through a power management system, so that the power management system can manage charging, discharging, power consumption and other functions.
[0042] The mobile phone 200 may also include a camera. Optionally, the position of the camera on the mobile phone may be front-mounted or rear-mounted, which is not limited in the embodiments of the present application. In at least one embodiment, the mobile phone may collect a scene image of the current scene through the camera, and process the collected image through the image processing method provided in the embodiments of the present application.
[0043] Figure 3 is a flowchart of an image processing method according to an embodiment of the present application, comprising:
[0044] Step S310, determining a first pixel region and a second pixel region in the original image, wherein the first pixel region and the second pixel region are not connected, and an absolute value of a difference between a grayscale value of the first pixel region and a grayscale value of the second pixel region is less than a first preset value.
[0045] Here, since conventional video images are divided into 256 grayscale values, but the number of grayscale values that can be distinguished by the human eye is 20 to 30, it is difficult for the human eye to distinguish the brightness difference between images with too small a difference in grayscale values. On the contrary, when the pixel difference between two pixel areas is greater than a certain value, the human eye can clearly distinguish the brightness difference between the two. Therefore, taking into account the differences in visual abilities between different individuals, the value range of the first preset value in step S310 can be limited to integers between 9 and 13. When two pixel areas are not connected and the absolute values of their grayscale values are less than the first preset value, the two pixel areas can be preliminarily judged as a pair of pixel areas that may cause a year-on-year illusion. Preferably, the first preset value is 10.
[0046] Step S320: determining a first adjacent region adjacent to the first pixel region and a second adjacent region adjacent to the second pixel region, wherein each of the first adjacent region and the second adjacent region includes at least one pixel region.
[0047] Here, the adjacent region of a pixel region refers to a region that is adjacent to the pixel region and whose absolute value of the grayscale value difference is greater than a first preset value. Based on the position of the pixel region in the image and the image features, a pixel region may have one or more adjacent regions, such as Figure 1 The adjacent areas of area B include area A and area C, while the adjacent areas of area G include area D, area E and area F.
[0048] Step S330 , adjusting the grayscale value of the first pixel region and / or the second pixel region according to the grayscale value of each pixel region in the first adjacent region and the grayscale value of each pixel region in the second adjacent region.
[0049] Here, in step S330, the grayscale value of the first pixel area and / or the second pixel area is adjusted according to the grayscale value of each pixel area in the first adjacent area and the grayscale value of each pixel area in the second adjacent area. This can be understood as adjusting the grayscale value of at least one of the two pixel areas based on the brightness of the adjacent areas of the first pixel area and the brightness of the adjacent areas of the second pixel area, thereby weakening or eliminating the year-on-year illusion produced by the human eye on the two pixel areas.
[0050] Specifically, in step S330, a grayscale value threshold can be set, so that the pixel areas in the first adjacent area and the second adjacent area that are higher than the grayscale value threshold are considered to be areas with higher brightness. The proportions of the higher brightness areas in the first adjacent area and the second adjacent area can be compared, respectively, to determine the adjacent area where the proportion of the higher brightness area is lower, so that it is considered that the pixel area (the first pixel area or the second pixel area) corresponding to the adjacent area will be higher in brightness than the other pixel area in human eye perception, that is, the background brightness of the pixel area corresponding to the adjacent area is lower, while the background brightness of the other pixel area is higher. The same-year illusion problem can be solved by lowering the grayscale value of the pixel area with lower background brightness, or by lowering the grayscale value of the pixel area with higher background brightness, or by using both methods in parallel.
[0051] It can be understood that by determining the proportion of areas with higher brightness in the adjacent areas of the first pixel area and the second pixel area, and adjusting the grayscale value of the first pixel area and / or the second pixel area, when the number of pixel areas included in the adjacent areas is small, it will affect the determination of the actual background brightness of the first pixel area and the second pixel area, thereby affecting the adjustment effect.
[0052] Exemplarily, in order to achieve more accurate grayscale value adjustment, in step S330, adjusting the grayscale value of the first pixel area and / or the second pixel area according to the grayscale value of each pixel area in the first adjacent area and the grayscale value of each pixel area in the second adjacent area includes:
[0053] Determine a first grayscale average value corresponding to the first adjacent area based on the grayscale values corresponding to each pixel area in the first adjacent area; and determine a second grayscale average value corresponding to the second adjacent area based on the grayscale values corresponding to each pixel area in the second adjacent area; determine a grayscale difference between the first grayscale average value and the second grayscale average value; and adjust the grayscale value of the first pixel area and / or the second pixel area based on the grayscale difference.
[0054] Here, since the grayscale values of the pixels in the same pixel area are the same, the grayscale value of the pixel area is also the grayscale value of each pixel in the pixel area. The grayscale values of the pixel areas in the first adjacent area can be summed and averaged to obtain the first grayscale average value, and the grayscale values of the pixel areas in the second adjacent area can be summed and averaged to obtain the second grayscale average value; or, the color scale values of the pixel points in the first adjacent area can be summed and averaged to obtain the first grayscale average value, and the color scale values of the pixel points in the second adjacent area can be summed and averaged to obtain the second grayscale average value. The grayscale average value calculation results obtained by the two grayscale average value calculation methods may be different due to the different areas of the pixel areas in the adjacent areas, but the grayscale difference between the grayscale average values obtained by the two methods can guide the adjustment of the grayscale value of the first pixel area and / or the second pixel area.
[0055] Exemplarily, when the grayscale value of the first pixel area and / or the second pixel area is adjusted according to the grayscale difference, since there is a small difference in the background brightness of the two pixel areas, in this case, the same-year illusion will not be generated or the effect of the same-year illusion can be ignored. Based on this, a second preset value can be set, and the size relationship between the grayscale difference and the second preset value can be determined. Only when the grayscale difference is not less than the second preset value, it is determined that the grayscale value of the first pixel area and / or the second pixel area needs to be adjusted, and in response to the grayscale difference being less than the second preset value, the grayscale value of the first pixel area and the second pixel area is not adjusted.
[0056] Specifically, in response to the grayscale difference being not less than a second preset value, the grayscale value of the first pixel area and / or the second pixel area is adjusted according to the grayscale difference, including: determining a grayscale value adjustment strategy according to a size relationship between the first grayscale average value and the second grayscale average value; and adjusting the grayscale value of the first pixel area and / or the second pixel area according to the grayscale value adjustment strategy.
[0057] It can be understood that when the first grayscale average value is less than the second grayscale average value, it means that the average brightness of the first adjacent area is lower than that of the second adjacent area, that is, the background brightness of the first pixel area is lower than the background brightness of the second pixel area. In this case, determining the grayscale value adjustment strategy includes lowering the grayscale value of the first pixel area and / or increasing the grayscale value of the second pixel area.
[0058] When the first grayscale average value is greater than the second grayscale average value, it means that the average brightness of the first adjacent area is higher than that of the second adjacent area, that is, the background brightness of the first pixel area is higher than the background brightness of the second pixel area. In this case, determining the grayscale value adjustment strategy includes increasing the grayscale value of the first pixel area and / or lowering the grayscale value of the second pixel area.
[0059] The above grayscale value adjustment strategy shows the adjustment direction of the grayscale value. The present application also provides an embodiment for specifically calculating the grayscale adjustment value, including:
[0060] According to the relationship between the first grayscale average value and the second grayscale average value, the pixel area to be adjusted is determined from the first pixel area and the second pixel area; the pixel area to be adjusted is the pixel area corresponding to the adjacent area of the smaller value of the first grayscale average value and the second grayscale average value; the absolute value of the difference between the first grayscale average value and the second grayscale average value is determined; the grayscale correction value is determined according to the absolute value and the correction coefficient; the grayscale value of the area to be adjusted is adjusted according to the grayscale correction value.
[0061] Among them, adjusting the grayscale value of the area to be adjusted according to the grayscale correction value includes: determining the difference between the grayscale value of the area to be adjusted and the grayscale correction value, and using the difference as the adjusted grayscale value of the area to be adjusted.
[0062] Here, the pixel area to be adjusted is also the pixel area with a lower grayscale average value in the adjacent area, and the correction coefficient is 0.1 to 0.4. Figure 1 The average grayscale value of the adjacent area of area B is 55, and the average grayscale value of the adjacent area of area G is 227. The absolute value of the difference between the two is 172. The correction coefficient is 0.2, and the grayscale correction value is 34.4. Assuming that the original grayscale values of area B and area G are both 166, the original grayscale value of area B is subtracted from the grayscale correction value and rounded to the integer, and the adjusted grayscale value of area B is 132.
[0063] Exemplarily, in step S310, determining a first pixel region and a second pixel region in the original image includes:
[0064] Grayscale processing is performed on the original image to obtain a grayscale image corresponding to the original image; pixel areas are divided in the original image according to a first preset value and the grayscale value of each pixel point in the original image in the grayscale image; and a first pixel area and a second pixel area are determined in each divided pixel area.
[0065] Here, grayscale processing of the original image can simplify the color image of the three RGB color channels into a single-channel grayscale image for processing. The grayscale processing methods include the average method (average of the grayscale values of the three RGB channels), the weighted average method, the maximum method, and the minimum method. Since the human eye is most sensitive to green and least sensitive to blue, the weighted average method is generally used to perform weighted average of the grayscale values of the three RGB color channels to obtain a more reasonable grayscale image, in which the grayscale value of each pixel is Gray = 0.299R + 0.587G + 0.114B.
[0066] Exemplarily, pixel areas are divided in the original image according to a first preset value and the grayscale value of each pixel in the original image in a grayscale image, including: taking the first preset value as an integer divisor, rounding the grayscale value of each pixel to obtain a grayscale mark value of each pixel; traversing each pixel in the original image and generating a label for each pixel, the label including a grayscale mark value and an area mark value of the pixel; dividing the pixel area in the original image according to the label of each pixel, wherein the grayscale mark value and the area mark value of each pixel in the same pixel area are the same.
[0067] Here, since it is difficult for the human eye to distinguish image differences within the first preset value (9 to 13), in order to simplify the calculation, the first preset value can be taken as an integer divisor, and the original grayscale value of each pixel is divided by the first preset value and rounded to obtain the grayscale mark value of each pixel. Then, each pixel is traversed through the grayscale mark value of each pixel, and a label including a grayscale mark value and an area mark value is generated for each pixel, thereby dividing the pixel area in the original image.
[0068] Exemplarily, traversing each pixel in the original image and establishing a label for each pixel includes: for the traversed pixel N, determining whether there is a target pixel in the adjacent area of the pixel N that has a generated label and whose grayscale label value is the same as the grayscale label value of the pixel N; if there is a target pixel, determining that the area label value of the pixel N is the same as the area label value of the target pixel; if there is no target pixel, determining the largest area label value n among the pixels with the same grayscale label value as the pixel N, and determining the area label value of the pixel N as n+1, wherein if there is no pixel with the same grayscale label value as the pixel N, the value of n is 0.
[0069] Specifically, the traversal of each pixel in the original image may include two traversals, and the first traversal includes:
[0070] Starting from the first row of the image pixel area, traverse the grayscale values of each pixel from left to right, and reassign a label value label(a,b) to each pixel area, where a is the grayscale mark value at the pixel point, and b is the area mark value at the pixel point. The initial values of a and b are both set to 0. Starting from the first pixel point, if the grayscale mark value of the first pixel point is x0, then this pixel area is recorded as label(x0,0). Then traverse the second point. If the second grayscale mark value is x1, if x1=x0, then the second point is uniformly marked as label(x0,0). If there is no grayscale mark value equal to x1 in the neighborhood of the second pixel point, the second point is uniformly marked as label(x1,0), and so on. Traverse points step by step. When traversing to the nth point, if the grayscale mark value of point n is xn, if there are one or more pixel points in its neighborhood with the same grayscale mark value as xn, then the mark value b of this pixel point is assigned to the grayscale mark in the neighborhood. The minimum value among the label values of pixels whose values are all xn is label(xn,min(b(xn))). If the grayscale label value of n points is xn, and its neighborhood values are not equal to xn, then the label value b of this pixel is assigned label(xn,max(b(xn)+1)), where max(b(xn)+1) means the maximum value of the label value of the area with the grayscale label value xn in the existing labels plus 1. Repeat this operation so that each pixel has a label value label(a,b).
[0071] It is understandable that after the first pixel traversal, the label values of the labels of the adjacent pixels of the same color level on the left and right may be different, so a second traversal is required: re-traverse the image, start from the last row of the image pixel area, traverse the grayscale values of each pixel from right to left, and re-assign a label value label to each pixel area. At this time, the grayscale label value in the label is still consistent with the grayscale label value in the first traversal, but its area label value is the minimum value of the label values of the adjacent pixels of the pixel with the same grayscale value. Through the second pixel traversal, all pixels in the image are re-assigned label values, where the label values of the pixels of the same color level and adjacent pixels are the same.
[0072] Based on this, the pixel area can be divided according to the label of each pixel point, and according to whether there are labels with the same grayscale label value but different regional label values, it can be judged whether there are one or more pairs of pixel areas that may cause the same-year illusion. Determining the first pixel area and the second pixel area in each divided pixel area includes: in each divided pixel area, determining two pixel areas with the same grayscale label value but different regional label values as the first pixel area and the second pixel area respectively.
[0073] The above pixel area division method is only an example. In actual application, any existing technology can be used to identify the grayscale value of each pixel in the original image and divide the pixel area. The present application is not limited to this.
[0074] In order to facilitate understanding of the image processing method of the present application, the processing steps of the image processing method of the present application are explained below by way of examples in combination with the accompanying drawings.
[0075] Assumptions Figure 1 The grayscale value of area A is 38, the grayscale value of area B is 166, the grayscale value of area C is 89, the grayscale value of area D is 242, the grayscale value of area E is 217, the grayscale value of area F is 230, and the grayscale value of area G is the same as that of area B, which is 166.
[0076] Step (1): Figure 1 Each pixel in the image is traversed one by one. The first traversal starts from the pixel coordinate (1, 1) (first row, first column), and traverses from left to right and from top to bottom to the pixel (12, 12). For the point (1, 1), the first preset value is 10, and its grayscale mark value is 3, so the label value label (3, 0) is assigned to the point (1, 1). For the point (1, 2) (first row, second column), its grayscale mark value is also 3, and there are already pixels with the same grayscale mark value in the neighborhood of point (1, 2) and are assigned a regional mark value of 0. Therefore, point (1, 2) is also assigned label (3, 0). Similarly, each pixel is assigned a label value. For the coordinate point (3, 2), its grayscale mark value is 16. There is no point with a grayscale mark value of 16 in its neighborhood, and the point with a current color scale value of 16 is assigned a maximum regional mark value of 0. Therefore, the regional mark value of the coordinate point (3, 2) is assigned 0+1, and its label value is label (16, 1). Similarly, after traversing all points, we get the following Figure 4 The label values of each point after the first traversal are shown. Figure 4 As shown, the coordinate points (3, 2), (4, 6), (7, 6), (7, 7) (10, 6), (11, 10) Figure 4 The area marking value of the point with the same grayscale marking value in the neighborhood is larger, so the image is traversed for the second time.
[0077] Step (2): The second pixel traversal starts from the coordinate point (12, 12), and traverses the grayscale values of each pixel from right to left and from bottom to top, and reassigns a label value label to each pixel area. At this time, the grayscale value in the label is still consistent with the grayscale of the pixel itself, but its label value is the minimum value of the label values of the same pixel with the same grayscale value in the neighborhood of the pixel. After the second traversal, the label values of the coordinate points (3, 2), (4, 6), (7, 6), (7, 7) (10, 6), and (11, 10) are corrected to (16, 0), (8, 0), (24, 0), (24, 0), (16, 2), and (21, 0), as shown in the figure. Figure 5 shown.
[0078] Step (3): Find the adjacent areas of the grayscale label values of each pixel area, traverse the image pixels one by one, and list the labels of the neighborhood points of each pixel. For example, the pixel with coordinates (1, 1) has its own label value label(3,0), and there are three neighborhood points, all with label values of label(3,0). The record is label(3,0)-near(label(3,0), label(3,0), label(3,0)). For example, the pixel with coordinates (3, 1) has its own label value label(16,0), and there are 8 neighborhood points. The record is label(16,0)-near(label(3,0), label(3,0), label(3,0), label(8,0), label(16,0), label(16,0), label(16,0), label(16,0)).
[0079] Step (4): Then integrate and simplify the neighborhood labels of the pixels on the same label paper to obtain label(3,0)-near(label(8,0), label(16,0), label(23,0), label(24,0)), indicating that the label(3,0) area is connected to four areas, and the grayscale values of the four areas are 8, 16, 23, and 24 respectively. Similarly, the adjacent areas of other areas can be obtained: label(16,0)-near(label(3,0), label(8,0)); label(8,0)-near(label(3,0), label(16,0), label(21,0), label(24,0)); label(21,0)-near(label(8,0), label(16,2), label(24,0));
[0080] label(24,0)-near(label(3,0),label(16,2),label(21,0),label(24,0)); label(23,0)-near(label(3,0),label(16,2),label(24,0)); label(16,2)-near(label(21,0),label(23,0),label(24,0)).
[0081] Step (5): Adjust the grayscale value of the pixel area that may cause the same-year illusion. It can be seen that label (16, 0) and label (16, 2) are two different areas (i.e., area B and area G) with the same grayscale mark value. The average grayscale mark value of the area around the label (16, 0) area is 5.5. The average grayscale mark value of the area around the label (16, 2) area is 22.7. The absolute value of the difference is 17.2, and the correction coefficient is 0.2, so the correction value is 3.44. Therefore, the grayscale mark value of the label (16, 0) area is uniformly lowered by 3.44 / 16. The original grayscale value of the label (16, 0) area is 166, and the adjusted grayscale value is 132.
[0082] Figure 6 The schematic diagram shows the effect of adjusting the grayscale value of area B. Figure 1 compared to, Figure 6 After the adjustment, the colors of area B and area G are closer when perceived by the human eye.
[0083] The above describes the specific settings and implementation methods of the embodiments of the present application from different perspectives. Using the method provided in the above embodiments, one or more pairs of pixel areas where the same-year illusion may occur can be determined in the image, and the surrounding background colors of these pixel areas can be analyzed, and then the grayscale values of these pixel areas can be adjusted based on the analysis results to reduce or eliminate the same-year illusion of the human eye and improve the consistency between the color perceived by the human eye and the actual color.
[0084] As the implementation of the above methods, Figure 7 As shown, the embodiment of the present application further provides an image processing device, which can be applied to a display device, and the device may include:
[0085] A first determining module 710 is used to determine a first pixel region and a second pixel region in the original image, wherein the first pixel region and the second pixel region are not connected, and an absolute value of a difference between a grayscale value of the first pixel region and a grayscale value of the second pixel region is less than a first preset value;
[0086] A second determining module 720, configured to determine a first adjacent region adjacent to the first pixel region and a second adjacent region adjacent to the second pixel region, wherein each of the first adjacent region and the second adjacent region includes at least one pixel region;
[0087] The grayscale value adjustment module 730 is used to adjust the grayscale value of the first pixel area and / or the second pixel area according to the grayscale value of each pixel area in the first adjacent area and the grayscale value of each pixel area in the second adjacent area.
[0088] The functions of each unit, module or sub-module in each device in the embodiments of the present application can refer to the corresponding description in the above method embodiments, and have corresponding beneficial effects, which will not be repeated here.
[0089] According to an embodiment of the present application, the present application also provides an electronic device, a computer-readable storage medium and a computer program product.
[0090] Figure 8 FIG. 1 is a block diagram of an electronic device used to implement an embodiment of the present application. Figure 8 As shown, the electronic device includes: a memory 801 and a processor 802. The memory 801 stores a computer program that can be run on the processor 802. When the processor 802 executes the computer program, the method in the above embodiment is implemented. The number of the memory 801 and the processor 802 can be one or more.
[0091] The electronic device also includes:
[0092] The communication interface 803 is used to communicate with external devices and perform data exchange transmission.
[0093] If the memory 801, the processor 802 and the communication interface 803 are implemented independently, the memory 801, the processor 802 and the communication interface 803 can be connected to each other through a bus and communicate with each other. The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 8 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0094] Optionally, in a specific implementation, if the memory 801, the processor 802 and the communication interface 803 are integrated on a chip, the memory 801, the processor 802 and the communication interface 803 can communicate with each other through an internal interface.
[0095] An embodiment of the present application also provides a chip, which includes a processor for calling and executing instructions stored in the memory from the memory, so that a communication device equipped with the chip executes the method provided by the embodiment of the present application.
[0096] An embodiment of the present application also provides a chip, including: an input interface, an output interface, a processor and a memory, wherein the input interface, the output interface, the processor and the memory are connected via an internal connection path, and the processor is used to execute the code in the memory. When the code is executed, the processor is used to execute the method provided in the embodiment of the present application.
[0097] It should be understood that the processor may be a CPU, or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), FPGAs or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc. It is worth noting that the processor may be a processor supporting the Advanced RISC Machines (ARM) architecture.
[0098] Further, optionally, the above-mentioned memory may include a read-only memory and a random access memory. The memory may be a volatile memory or a non-volatile memory, or may include both volatile and non-volatile memory. Among them, the non-volatile memory may include a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may include a random access memory (RAM), which is used as an external cache. By way of exemplary but not limiting description, many forms of RAM are available. For example, static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM) and direct memory bus random access memory (DR RAM).
[0099] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function according to the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another computer-readable storage medium.
[0100] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example" or "some examples" etc. 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. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine different embodiments or examples described in this specification and the features of different embodiments or examples, unless they are contradictory.
[0101] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Therefore, a feature defined as "first" or "second" may explicitly or implicitly include at least one of the features. In the description of this application, the meaning of "plurality" is two or more, unless otherwise clearly and specifically defined.
[0102] Any process or method described in the flow chart or otherwise described herein can be understood as a module, fragment or portion of a code representing one or more executable instructions for implementing the steps of a specific logical function or process. And the scope of the preferred embodiment of the present application includes other implementations, in which the functions may not be performed in the order shown or discussed, including in a substantially simultaneous manner or in a reverse order according to the functions involved.
[0103] The logic and / or steps described in the flowchart or otherwise described herein, for example, can be considered as an ordered list of executable instructions for implementing logical functions, which can be specifically implemented in any computer-readable medium for use by an instruction execution system, device or apparatus (such as a computer-based system, a system including a processor, or other system that can fetch instructions from an instruction execution system, device or apparatus and execute instructions), or used in combination with these instruction execution systems, devices or apparatuses.
[0104] It should be understood that the various parts of the present application can be implemented with hardware, software, firmware or a combination thereof. In the above embodiments, multiple steps or methods can be implemented with software or firmware stored in a memory and executed by a suitable instruction execution system. All or part of the steps of the above embodiment method can be completed by instructing the relevant hardware through a program, which can be stored in a computer-readable storage medium, and when the program is executed, it includes one of the steps of the method embodiment or a combination thereof.
[0105] In addition, each functional unit in each embodiment of the present application can be integrated into a processing module, or each unit can exist physically separately, or two or more units can be integrated into one module. The above-mentioned integrated module can be implemented in the form of hardware or in the form of a software functional module. If the above-mentioned integrated module is implemented in the form of a software functional module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. The storage medium can be a read-only memory, a disk or an optical disk, etc.
[0106] The above is only an exemplary embodiment of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of various changes or substitutions within the technical scope recorded in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application shall be based on the protection scope of the claims.
Claims
1. An image processing method, comprising: Determining a first pixel region and a second pixel region in the original image, wherein the first pixel region and the second pixel region are not connected, and an absolute value of a difference between a grayscale value of the first pixel region and a grayscale value of the second pixel region is less than a first preset value; Determine a first adjacent region adjacent to the first pixel region, and a second adjacent region adjacent to the second pixel region, wherein the first adjacent region and the second adjacent region each include at least one pixel region; The grayscale value of the first pixel area and / or the second pixel area is adjusted according to the grayscale value of each pixel area in the first adjacent area and the grayscale value of each pixel area in the second adjacent area.
2. The method according to claim 1, wherein: According to the grayscale values of each pixel area in the first adjacent area and the grayscale values of each pixel area in the second adjacent area, adjusting the grayscale values of the first pixel area and / or the second pixel area includes: Determine a first grayscale average value corresponding to the first adjacent area according to the grayscale values corresponding to each pixel area in the first adjacent area; and determine a second grayscale average value corresponding to the second adjacent area according to the grayscale values corresponding to each pixel area in the second adjacent area; Determining a grayscale difference between the first grayscale average value and the second grayscale average value; The grayscale value of the first pixel region and / or the second pixel region is adjusted according to the grayscale difference.
3. The method according to claim 2, wherein: Adjusting the grayscale value of the first pixel region and / or the second pixel region according to the grayscale difference includes: In response to the grayscale difference being less than a second preset value, the grayscale values of the first pixel region and the second pixel region are not adjusted.
4. The method according to claim 2, wherein: Adjusting the grayscale value of the first pixel region and / or the second pixel region according to the grayscale difference includes: In response to the grayscale difference being not less than a second preset value, determining a grayscale value adjustment strategy according to a magnitude relationship between the first grayscale average value and the second grayscale average value; The grayscale value of the first pixel region and / or the second pixel region is adjusted according to the grayscale value adjustment strategy.
5. The method according to claim 4, wherein: Determining a grayscale value adjustment strategy according to a magnitude relationship between the first grayscale average value and the second grayscale average value includes: In response to the first grayscale average value being less than the second grayscale average value, determining the grayscale value adjustment strategy includes lowering the grayscale value of the first pixel region and / or raising the grayscale value of the second pixel region.
6. The method according to claim 4, wherein: Determining a grayscale value adjustment strategy according to a magnitude relationship between the first grayscale average value and the second grayscale average value includes: In response to the first grayscale average being greater than the second grayscale average, determining the grayscale value adjustment strategy includes increasing the grayscale value of the first pixel region and / or decreasing the grayscale value of the second pixel region.
7. The method according to claim 4, wherein: Determining a grayscale value adjustment strategy according to a magnitude relationship between the first grayscale average value and the second grayscale average value includes: According to the magnitude relationship between the first grayscale average value and the second grayscale average value, determining a pixel region to be adjusted from the first pixel region and the second pixel region; the pixel region to be adjusted is a pixel region corresponding to an adjacent region of a smaller value between the first grayscale average value and the second grayscale average value; Determining an absolute value of a difference between the first grayscale average value and the second grayscale average value; Determining a grayscale correction value according to the absolute value and the correction coefficient; The grayscale value of the area to be adjusted is adjusted according to the grayscale correction value.
8. The method according to claim 7, wherein: Adjusting the grayscale value of the area to be adjusted according to the grayscale correction value includes: The difference between the grayscale value of the area to be adjusted and the grayscale correction value is determined, and the difference is used as the adjusted grayscale value of the area to be adjusted.
9. The method according to claim 7, wherein: The correction coefficient ranges from 0.1 to 0.
4.
10. The method according to claim 1, wherein: The first preset value is in the range of an integer from 9 to 13, and the first pixel region and the second pixel region are determined in the original image, including: Performing grayscale processing on the original image to obtain a grayscale image corresponding to the original image; Dividing pixel areas in the original image according to the first preset value and the grayscale value of each pixel in the original image in the grayscale image; The first pixel region and the second pixel region are determined in each divided pixel region.
11. The method according to claim 10, wherein: Dividing pixel areas in the original image according to the first preset value and the grayscale value of each pixel in the original image in the grayscale image includes: Taking the first preset value as an integer divisor, performing a rounding operation on the grayscale value of each pixel point, to obtain a grayscale mark value of each pixel point; Traversing each pixel in the original image and generating a label for each pixel, wherein the label includes a grayscale label value and an area label value of the pixel; According to the labels of the pixels, pixel regions are divided in the original image, wherein the grayscale label value and the region label value of each pixel in the same pixel region are the same.
12. The method according to claim 11, wherein: Traversing each pixel point in the original image and establishing a label for each pixel point includes: For the traversed pixel point N, determine whether there is a target pixel point in the adjacent area of the pixel point N that has a generated label and whose grayscale mark value is the same as the grayscale mark value of the pixel point N; If the target pixel exists, determine that the region mark value of the pixel N is the same as the region mark value of the target pixel; If the target pixel does not exist, determine the maximum area mark value n among the pixel points with the same generated label as the grayscale mark value of the pixel point N, and determine the area mark value of the pixel point N as n+1, where if there is no pixel point with the same generated label as the grayscale mark value of the pixel point N, the value of n is 0.
13. The method according to claim 12, wherein: Determining the first pixel region and the second pixel region in each divided pixel region includes: In each of the divided pixel regions, two pixel regions with the same grayscale label value but different region label values are determined as the first pixel region and the second pixel region respectively.
14. An image processing device, comprising: A first determining module, configured to determine a first pixel region and a second pixel region in an original image, wherein the first pixel region and the second pixel region are not connected, and an absolute value of a difference between a grayscale value of the first pixel region and a grayscale value of the second pixel region is less than a first preset value; A second determining module, configured to determine a first adjacent region adjacent to the first pixel region and a second adjacent region adjacent to the second pixel region, wherein the first adjacent region and the second adjacent region each include at least one pixel region; The grayscale value adjustment module is used to adjust the grayscale value of the first pixel area and / or the second pixel area according to the grayscale value of each pixel area in the first adjacent area and the grayscale value of each pixel area in the second adjacent area.
15. An electronic device comprising a memory, a processor and a computer program stored in the memory, wherein the processor implements the method according to any one of claims 1 to 13 when executing the computer program.
16. A computer-readable storage medium, wherein a computer program is stored in the computer-readable storage medium, and when the computer program is executed by a processor, the method according to any one of claims 1 to 13 is implemented.
17. A computer program product comprising a computer program, which, when executed by a processor, implements the method according to any one of claims 1 to 13.