Image processing method, device, terminal and storage medium
By performing inverting the negative film image and value equalization processing, the problem of complex negative film to digital image method and difficult sample collection in the prior art is solved, and a simplified image processing flow and efficient digital image generation are realized.
Patent Information
- Application Number
- CN201910386977.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-05-09
- Publication Date
- 2025-02-28
- Estimated Expiration
- 2039-09-24
AI Technical Summary
When converting negative films into digital images, the methods are complex and require professional and technical personnel, or a large number of negative film images are required for model training, making it difficult to collect samples.
By obtaining the initial color value of the negative image and its pixels in the target color space, performing inverting and value equalization processing, digital color values are obtained, thereby generating digital image data.
The image processing process is simplified, the processing complexity is reduced, and complex darkroom flushing technology or large number of negative image samples is required, which improves the convenience and realization of image processing.
Smart Images

Figure CN110084767B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image processing technology, and in particular to an image processing method, device, terminal and storage medium. Background Art
[0002] Film, also known as negative film, is an imaging device. The most common type of film is negative film, which records the opposite color of the real color of the subject when imaging. At present, the methods of converting negative film into digital images mainly include the following two schemes: the first is to use darkroom development technology to develop the negative film to obtain a paper photo, and then scan the paper photo with a scanner to obtain a digital image. The second is to use a machine learning algorithm to train a neural network model, and call the trained neural network model to restore the color of the negative image to be processed to obtain a digital image.
[0003] In practice, it is found that the entire process of using darkroom developing technology is relatively complicated and requires professional technicians to develop negative films; while the second solution requires a large number of negative film images as sample images. Since negative films are rarely produced, it is difficult to collect sample images. Summary of the invention
[0004] The embodiments of the present invention provide an image processing method, device, terminal and storage medium, which can conveniently obtain digital image data of a negative image and reduce the complexity of image processing.
[0005] In one aspect, an embodiment of the present invention provides an image processing method, comprising:
[0006] Acquire a negative image to be processed and an initial color value of each pixel in the negative image in a target color space;
[0007] Performing inversion processing on the negative image to obtain inverted image data, wherein the inverted color value of each pixel in the inverted image data is determined according to the initial color value of each pixel in the negative image;
[0008] According to the inverted image data, performing value equalization processing on the inverted color value of each pixel within the value range corresponding to the target color space to obtain the digital color value of each pixel;
[0009] The digital image data of the negative image is obtained according to the digital color value of each pixel.
[0010] On the other hand, an embodiment of the present invention provides an image processing method, including:
[0011] Acquire a negative image to be processed and an initial color value of each pixel in the negative image in a first color space;
[0012] Performing inversion processing on the negative image to obtain inverted image data, wherein the inverted color value of each pixel in the inverted image data is determined according to the initial color value of each pixel in the negative image;
[0013] Converting the inverted color value of each pixel in the inverted image data from the first color space to the second color space to obtain a converted color value of each pixel;
[0014] Performing value equalization processing on the converted color values of each pixel within a value range corresponding to the second color space to obtain an equalized color value of each pixel;
[0015] Converting the balanced color value of each pixel from the second color space to the first color space to obtain a digital color value of each pixel;
[0016] The digital image data of the negative image is obtained according to the digital color value of each pixel.
[0017] In another aspect, an embodiment of the present invention provides an image processing device, comprising:
[0018] An acquisition unit, used for acquiring a negative image to be processed and an initial color value of each pixel in the negative image in a target color space;
[0019] A processing unit, configured to perform inversion processing on the negative image to obtain inverted image data, wherein the inverted color value of each pixel in the inverted image data is determined according to the initial color value of each pixel in the negative image;
[0020] The processing unit is used to perform value balancing processing on the inverted color value of each pixel within the value range corresponding to the target color space according to the inverted image data to obtain the digital color value of each pixel;
[0021] The processing unit is used to obtain the digital image data of the negative image according to the digital color value of each pixel.
[0022] In another aspect, an embodiment of the present invention provides an image processing device, comprising:
[0023] An acquisition unit, used for acquiring a negative image to be processed and an initial color value of each pixel in the negative image in a first color space;
[0024] A processing unit, configured to perform inversion processing on the negative image to obtain inverted image data, wherein the inverted color value of each pixel in the inverted image data is determined according to the initial color value of each pixel in the negative image;
[0025] a conversion unit, configured to convert the inverted color value of each pixel in the inverted image data from the first color space to the second color space to obtain a converted color value of each pixel;
[0026] The processing unit is used to perform value equalization processing on the converted color values of each pixel within the value range corresponding to the second color space to obtain the equalized color value of each pixel;
[0027] The conversion unit is used to convert the balanced color value of each pixel from the second color space to the first color space to obtain the digital color value of each pixel;
[0028] The processing unit is used to obtain the digital image data of the negative image according to the digital color value of each pixel.
[0029] On the other hand, an embodiment of the present invention provides an intelligent terminal, including a processor, an input device, an output device and a memory, wherein the processor, input device, output device and memory are interconnected, wherein the memory is used to store a computer program, and the computer program includes program instructions, and the processor is configured to call the program instructions to execute any one of the above-mentioned image processing methods.
[0030] On the other hand, an embodiment of the present invention provides a computer storage medium, which stores computer program instructions, and the computer program instructions are suitable for being loaded by a processor and executing any one of the above-mentioned image processing methods.
[0031] In the embodiment of the present invention, since the negative film records the color opposite to the real color, after obtaining the initial color value of each pixel in the target color space in the negative film image, the negative film image can be firstly inverted to obtain inverted image data, and the inverted image data includes the inverted color value of each pixel. Then, the inverted color value of each pixel can be value-equalized in the value range corresponding to the target color space according to the inverted image data, so that the digital color value of each pixel obtained by the value-equalization can more accurately reflect the real color, thereby improving the accuracy of the digital image data of the negative film obtained according to the digital color value. It can be seen from the above image processing flow that the embodiment of the present invention does not need to use complex darkroom developing technology to develop the negative film, nor does it need to use a large number of negative film images for model training, which can reduce the complexity of image processing to a certain extent and improve the feasibility of image processing. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying any creative work.
[0033] Figure 1a is an application scenario diagram of an image processing function provided by an embodiment of the present invention;
[0034] Figure 1b is an application scenario diagram of an image processing function provided by an embodiment of the present invention;
[0035] Figure 1c is a schematic diagram of an image processing process provided by an embodiment of the present invention;
[0036] Figure 1d is an application scenario diagram of an image processing function provided by an embodiment of the present invention;
[0037] Figure 2 is a flowchart of an image processing method provided by an embodiment of the present invention;
[0038] Figure 3a is a schematic diagram of a color histogram provided by an embodiment of the present invention;
[0039] Figure 3b is a schematic diagram of another color histogram provided by an embodiment of the present invention;
[0040] Figure 4 is a flowchart of an image processing method provided by another embodiment of the present invention;
[0041] Figure 5a is a schematic diagram of determining a first anti-phase component value provided by an embodiment of the present invention;
[0042] Figure 5b is a schematic diagram of determining a second anti-phase component value provided by an embodiment of the present invention;
[0043] Figure 6 is a flowchart of an image processing method provided by another embodiment of the present invention;
[0044] Figure 7 is a structural schematic diagram of an image processing device provided by an embodiment of the present invention;
[0045] Figure 8 is a structural schematic diagram of an image processing device provided by another embodiment of the present invention;
[0046] Fig. 9It is a structural schematic diagram of an intelligent terminal provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0047] In an embodiment of the present invention, a terminal can provide a user with an image processing function; the terminal here can include but is not limited to: portable mobile terminals such as smart phones, tablet computers, laptop computers, and desktop computers, etc. The user can convert the negative image into a digital image through the image processing function, which can save the user the time of taking the negative film to the image processing shop and waiting for professional technicians to use darkroom processing technology to develop the negative film, and can improve the convenience of converting the negative image into a digital image. In one embodiment, the image processing function can be added as an independent function module to any application in the terminal; for example, the image processing function can be added as an independent function module to a camera application, and the user can turn on the image processing function in the setting interface (or shooting interface) of the camera application; for another example, the image processing function can be added as an independent function module to an instant messaging application, and the user can turn on the image processing function in the setting interface (or session interface) of the instant messaging application. In another embodiment, the image processing function can also be added as an independent system function in the terminal to the system function option bar in the terminal, that is, the user can turn on the image processing function in the system function option bar of the terminal. In another embodiment, the image processing function may also be added to the terminal as an independent application APP, that is, the user enables the image processing function by opening the application APP.
[0048] The following takes the example of adding the image processing function as an independent application APP to the mobile terminal to explain the image processing function: when the user wants to convert a negative film into a digital image, the image processing function in the mobile terminal can be turned on. After the mobile terminal detects the user's operation of turning on the image processing function, it can start running the image processing function and output a prompt message in the user interface to prompt the user to take an image of the negative film, such as Figure 1a The user can shoot the negative film according to the prompt information. After the mobile terminal detects the user's shooting operation, it can call the camera component of the mobile terminal to capture the image of the negative film and use the captured image as the negative film image, as shown in FIG. Figure 1b shown.
[0049] After the mobile terminal acquires the negative image, it can perform a series of image processing on the negative image to restore the digital image data of the negative image, thereby converting the negative image into a digital image. The specific process can be referred to in Figure 1cAs shown. Specifically, the mobile terminal may first perform an inversion process on the negative image to obtain inverted image data; the inverted image data may include the inverted color value of each pixel, and the inverted color value of each pixel includes the inverted component value of the pixel under each color channel in the RGB (optical three primary colors) color space. After obtaining the inverted image data, the inverted image data may be color balanced to obtain the digital color value of each pixel under each color channel in the RGB color space; specifically, the color value of each pixel may be value balanced according to the pixel distribution diagram of the inverted image data under each color channel in the RGB color space to obtain the digital color value of each pixel under each color channel in the RGB color space. Then, a color lookup table may be generated according to the digital color value of each pixel under each color channel in the RGB color space, and the color lookup table includes the corresponding relationship between the inverted color value of each pixel and the digital color; finally, image rendering may be performed based on the color lookup table to obtain the digital image corresponding to the negative image. After obtaining the digital image of the negative image, the mobile terminal may also output the digital image on the user interface for the user to view, such as Figure 1d shown.
[0050] It can be seen that the image processing function provided by the embodiment of the present invention enables users to digitize negative films in the terminal, avoiding the complicated process of developing negative films using darkroom developing technology. For any negative film, such as the negative films left by parents or other elders in the past, or the negative films taken by film enthusiasts now, etc.; even users who have no darkroom developing technology foundation can easily and conveniently convert the negative film into a digital image through the image processing function, and can display, store and disseminate the digital image through the terminal, eliminating the process of taking it to an image developing shop to wait for developing, so that the image memory stored in the negative film can be restored in a portable way.
[0051] Based on the above description of the image processing function, in one embodiment, the present invention is Figure 2A schematic flow chart of an image processing method is proposed in the text; the image processing method can be implemented by the terminal mentioned above. The terminal can obtain the negative image to be processed and the initial color value of each pixel in the negative image in the target color space in step S201. Specifically, when the terminal detects the image shooting instruction of the user for the negative film, it can respond to the image shooting instruction and call the camera component to shoot the negative film, thereby obtaining the negative image to be processed. After obtaining the negative image, the terminal can identify each pixel in the negative image and obtain the initial color value of each pixel in the target color space. In one embodiment, the target color space may include an RGB color space, and the initial color value may be an initial RGB value; the initial color value may include the initial component value of the pixel under each color channel in the target color space, that is, the initial RGB value of the pixel may include an initial R value, an initial G value, and an initial B value.
[0052] As can be seen from the above, a negative film is a film that records colors opposite to the real colors of the subject when imaging. Therefore, the initial color value of each pixel in the negative image obtained by photographing the negative film is used to reflect the color opposite to the real color of each pixel. Therefore, after obtaining the inverted image, the negative image can be inverted in step S202 to obtain inverted image data, so that the inverted color value of each pixel in the inverted image data can be used to reflect the real color of each pixel, and the inverted color value can be an inverted RGB value. Among them, the inverted color value of each pixel is determined based on the initial color value of each pixel in the negative image; inversion processing refers to calculating the complementary value of the initial color value of each pixel in the negative image, and using the complementary value of each pixel as the inverted color value of each pixel. Since the initial color value includes the initial component value of the pixel in each color channel in the target color space, during the specific implementation of step S202, the terminal can respectively invert the initial component value of each pixel in the negative image in each channel in the target color space to obtain the inverted component value of each pixel in each color channel in the target color space, and use the inverted component value of each pixel to form the inverted color value of each pixel, thereby obtaining inverted image data.
[0053] Research shows that negative film bases are usually coated with some chemical substances (such as color masks) to prevent light from entering the photosensitive layer and then reflecting back bad light after reaching the base; however, this chemical substance will interfere with the color, resulting in the inverted image corresponding to the inverted image data obtained after the inversion process to have obvious color deviation visually. Figure 3aThe color histogram distribution of the inverted image data in the RGB color space shown in FIG. 1 can intuitively show the color deviation phenomenon, that is, the color histograms corresponding to the three channels of R channel (red channel), G channel (green channel) and B channel (blue channel) are almost staggered. Therefore, in order to make the color histograms corresponding to the three channels of R channel, G channel and B channel coordinated (as shown in FIG. 1 ), the color histograms corresponding to the three channels of R channel, G channel and B channel are almost staggered. Figure 3b As shown) in order to solve the color deviation problem, the embodiment of the present invention can perform color balancing processing on the inverted image corresponding to the inverted image data. Specifically, in step S203, the terminal can perform value balancing processing on the inverted color value of each pixel in the corresponding value range in the target color space according to the inverted image data to obtain the digital color value of each pixel. Among them, the value range corresponding to the target color space may include the value range of each color channel in the target color space, and the value range of the color channel refers to the value range of the color value of the pixel under the color channel. For example, if the target color space is an RGB color space, then the value range corresponding to the target color space includes the value range of the R channel, the value range of the G channel, and the value range of the B channel; taking the R channel as an example, the value range of the color value of the pixel under the R channel is 0-255, so the value range of the R channel is [0, 255].
[0054] In one embodiment, the specific implementation of step S203 may be: first determine the regional range set composed of the maximum inverted color value and the minimum inverted color value in the inverted image data, the regional range set includes the regional range composed of the minimum inverted component value and the maximum inverted component value under each color channel in the target color space; secondly, according to the regional range set, the inverted color value of each pixel can be value-equalized in the value range corresponding to the target color space to obtain the digital color value of each pixel. Specifically, the target regional range composed of the minimum inverted component value and the maximum inverted component value under the target color channel can be obtained from the regional range set, and the target color channel is any channel in the target color space. Calculate the ratio of the value range of the target color channel and the target regional range to obtain the proportional mapping parameter; for example, assuming that the value range of the target color channel is [0, 255], and the value range composed of the minimum inverted component value and the maximum second inverted component value under the target color channel is [5, 56], then the proportional mapping parameter is equal to: (255-0) / (56-5)=5. The proportional mapping parameter is used to calculate the inverted component value of each pixel in the target color channel to obtain the digital component value of each pixel in the target color channel; specifically, the inverted component value of each pixel in the target color channel can be substituted into formula 1.1 for calculation to obtain the digital component value of each pixel in the target color channel.
[0055] F(x)=(x-A1)×Q Formula 1.1
[0056] Wherein, x represents the inverted component value of the target pixel in the target color channel, A1 represents the minimum inverted component value in the target channel, Q represents the proportional mapping parameter value, and F(x) represents the digital component value of the target pixel in the target color channel. After obtaining the digital component value of each pixel in the target color channel, the digital color value of each pixel can be obtained according to the digital component value of each pixel in the target color channel.
[0057] In another embodiment, the specific implementation of step S203 can also be: first obtain a pixel distribution diagram of the inverted image data in the target color space, and the pixel distribution diagram may include but is not limited to: a color histogram, a color curve diagram, etc. Then, according to the pixel distribution diagram, perform value balancing processing on the inverted color value of each pixel in the value range corresponding to the target color space to obtain the digital color value of each pixel; the digital color value of each pixel may be a digital RGB value.
[0058] After obtaining the digital color value of each pixel, the terminal can obtain the digital image data of the negative image according to the digital color value of each pixel in step S204. In one embodiment, the terminal can directly use the digital color value of each pixel as the digital image data of the negative image, so that the digital color value of each pixel can be directly rendered later to obtain the digital image corresponding to the negative image. In another embodiment, the terminal can establish a color lookup table of the inverted image data according to the digital color value of each pixel, and use the inverted image data and the color lookup table as the digital image data of the negative image, so that the color corresponding to the inverted color value of each pixel in the inverted image data can be found in the color lookup table later, thereby rendering to obtain the digital image corresponding to the negative image.
[0059] In the embodiment of the present invention, since the negative film records the color opposite to the real color, after obtaining the initial color value of each pixel in the target color space in the negative film image, the negative film image can be firstly inverted to obtain inverted image data, and the inverted image data includes the inverted color value of each pixel. Then, the inverted color value of each pixel can be value-equalized in the value range corresponding to the target color space according to the inverted image data, so that the digital color value of each pixel obtained by the value-equalization can more accurately reflect the real color, thereby improving the accuracy of the digital image data of the negative film obtained according to the digital color value. It can be seen from the above image processing flow that the embodiment of the present invention does not need to use complex darkroom developing technology to develop the negative film, nor does it need to use a large number of negative film images for model training, which can reduce the complexity of image processing to a certain extent and improve the feasibility of image processing.
[0060] In another embodiment, the embodiment of the present invention is Figure 4A schematic flow chart of another image processing method is proposed in the text; the image processing method can be implemented by the terminal mentioned above. The embodiment of the present invention is mainly explained by taking the target color space as the RGB color space as an example. When the target color space is other color spaces, the specific implementation method can refer to the embodiment of the present invention. The terminal can obtain the negative image to be processed and the initial color value of each pixel in the negative image in the target color space in step S401; and in step S402, the negative image is inverted to obtain inverted image data, and the inverted color value of each pixel in the inverted image data is determined according to the initial color value of each pixel in the negative image. As can be seen from the above, the initial color value includes the initial component value of the pixel under each color channel in the target color space; accordingly, the specific implementation method of step S402 can be: the terminal can first obtain the value range of the target color channel, and the target color channel is any channel in the target color space. Secondly, the difference between the initial component value of each pixel in the negative image under the target color channel and the maximum value of the value range of the target color channel can be calculated to obtain the inverted component value of each pixel under the target color channel; for example, assuming that the maximum value of the value range of the target color channel is 255, then the inverted component value = 255-initial component value. Then, the inverted image data can be obtained according to the inverted component value of each pixel under the target color channel. Specifically, the above method can be used to calculate the inverted component value of each pixel under each color channel in the target color space, thereby obtaining the inverted color value of each pixel in the target color space, and the inverted color value includes the inverted component value of each pixel under each color channel in the target color space; the inverted color value of each pixel in the target color space is added to the inverted image data.
[0061] After obtaining the inverted image data, a pixel distribution map of the inverted image data in the target color space can be obtained in step S403, and the pixel distribution map includes the pixel distribution map of the inverted image data under each color channel in the target color space, and the target color space includes the RGB color space. Specifically, any color channel can be selected from the target color space as the target color channel to obtain the inverted component value of each pixel in the inverted image data under the target color channel; the pixels are arranged in the order of the inverted component value of each pixel under the target color channel from small to large to obtain the pixel distribution map of the inverted image data under the target color channel. After obtaining the pixel distribution map of the inverted image data in the target color space, in step S404, according to the pixel distribution map, the inverted color value of each pixel can be value-equalized within the value range corresponding to the target color space to obtain the digital color value of each pixel. In the specific implementation process, step S404 may include the following steps s11-s13:
[0062] s11, determining the value of the numerical mapping parameter according to the pixel distribution diagram of the inverted image data under the target color channel and the value range of the target color channel.
[0063] The target color channel is any of the following channels: R channel, G channel or B channel; the pixel distribution diagram of the target color channel can be a color histogram, the horizontal axis of the color histogram represents the inverted component value, and the vertical axis represents the frequency of the inverted component value (that is, the number of pixels corresponding to the inverted component value). In the specific implementation process, the terminal can first determine the total area of the color histogram of the inverted image data under the target color channel; specifically, the area of each column in the color histogram can be determined using a rectangular area calculation formula, and the sum of the areas of each column is taken as the total area of the color histogram; or the total area of the color histogram can be obtained by performing an integral operation based on the minimum inverted component value and the maximum inverted component value of the color histogram. Secondly, based on the total area, the first inverted component value and the second inverted component value can be determined from the inverted component value of each pixel under the target color channel. In one embodiment, the specific implementation method of determining the first inverted component value from the inverted component value of each pixel under the target color channel based on the total area can be found in. Figure 5a As shown: a vertical line can be set on the left side of the color histogram corresponding to the target color channel (i.e., at the minimum inverted component value a), and the vertical line is gradually slid from left to right; if the ratio of the local area determined by the inverted component value corresponding to the current position of the vertical line and the minimum inverted component value to the total area meets the proportional condition, the sliding is stopped, and the inverted component value corresponding to the current position of the vertical line is used as the first inverted component value a1, that is, the local area determined by the first inverted component value and the minimum inverted component value (such as Figure 5a The ratio of the black area shown) to the total area satisfies the proportionality condition.
[0064] Similarly, in another embodiment, based on the total area, the second inverted component value is determined from the inverted component value of each pixel under the target color channel. For a specific embodiment, see Figure 5b As shown: a vertical line can be set on the right side of the color histogram corresponding to the target color channel (i.e., at the maximum inverted component value b), and the vertical line is gradually slid from right to left; if the ratio of the local area determined by the inverted component value corresponding to the current position of the vertical line and the maximum inverted component value to the total area meets the proportional condition, the sliding is stopped, and the inverted component value corresponding to the current position of the vertical line is used as the second inverted component value b1, that is, the local area determined by the second inverted component value and the maximum inverted component value (such as Figure 5bThe ratio of the area of the local area to the total area (shown in black) to the total area satisfies the proportional condition. The above-mentioned proportional condition may include the condition that the ratio of the local area to the total area is equal to the proportional threshold, and the proportional threshold may be set to 1% based on empirical values or business needs. It should be noted that if the ratio of the area of the bar chart corresponding to the minimum inverted component value (i.e., the first bar chart from left to right) to the total area is greater than or equal to the proportional threshold, the minimum inverted component value may be determined as the first inverted component value; if the ratio of the area of the bar chart corresponding to the maximum inverted component value (i.e., the first bar chart from right to left) to the total area is greater than or equal to the proportional threshold, the maximum inverted component value may be determined as the second inverted component value.
[0065] After determining the first inverted component value and the second inverted component value, the numerical mapping parameter value can be calculated based on the numerical range formed by the first inverted component value and the second inverted component value, and the value range of the target color channel. Specifically, the terminal can calculate the ratio between the value range of the target color channel and the numerical range, and use the calculated ratio as the numerical mapping parameter value. For example, assuming that the value range of the target color channel is [0, 255], and the numerical range formed by the first inverted component value and the second inverted component value is [5, 92]; then the numerical mapping parameter value is equal to: (255-0) / (92-5)=3.
[0066] s12, calculating the inverted component value of the target pixel in the inverted image data under the target color channel according to the numerical mapping parameter value, and obtaining the digital component value of the target pixel under the target color channel.
[0067] The target pixel includes a pixel whose inverted component value is not less than the first inverted component value and not greater than the second inverted component value under the target color channel, that is, the inverted component value of the target pixel is not less than the first inverted component value and not greater than the second inverted component value. In the specific implementation process, the numerical mapping algorithm can be called to calculate the inverted component value of the target pixel in the inverted image data under the target color channel according to the numerical mapping parameter value to obtain the digital component value of the target pixel under the target color channel. The numerical mapping algorithm is a mapping algorithm based on interpolation calculation, and the specific algorithm can be shown in Formula 1.2:
[0068] f(x)=(x-a1)×q+a Formula 1.2
[0069] Wherein, x represents the inverted component value of the target pixel in the target color channel, a1 represents the first inverted component value, q represents the numerical mapping parameter value, a represents the minimum value of the value range of the target color channel, and f(x) represents the digital component value of the target pixel in the target color channel. Referring to the example in step s11, the value range of the target color channel is [0, 255], the numerical range formed by the first inverted component value and the second inverted component value is [5, 92], then the numerical mapping parameter value q is equal to 3; assuming that the inverted component value of the target pixel in the target color channel is 6, then the digital component value of the target pixel in the target color channel can be calculated using formula 1.1 as follows: (6-5)×3+0=3.
[0070] It should be noted that: if there is a first pixel whose inverted component value under the target color channel is less than the first inverted component value, the digital component value of the first pixel under the target color channel is set to the minimum value of the value range of the target color channel; if there is a second pixel whose inverted component value under the target color channel is greater than the second inverted component value, the digital component value of the second pixel under the target color channel is set to the maximum value of the value range of the target color channel. Continuing from the above example, the value range of the target color channel is [0, 255]; if there is a pixel 1 whose inverted component value under the target color channel is 4, which is less than the first inverted component value 5, then the pixel 1 is the first pixel, and the digital component value of the pixel 1 under the target color channel can be set to 0; if there is a pixel 2 whose inverted component value under the target color channel is 95, which is greater than the second inverted component value 92, then the pixel 2 is the second pixel, and the digital component value of the pixel 2 under the target color channel can be set to 255.
[0071] s13, determining the digital color value of the target pixel according to the digital component value of the target pixel in the target color channel.
[0072] The terminal can add the digital component value of the target pixel in the target color channel to the digital color value of the target pixel. The digital component value of the target pixel in each color channel in the target color space can also be calculated using the above steps s11-s12, and the digital component value of the target pixel in each color channel is used to form the digital color value of the target pixel.
[0073] After obtaining the digital color value of each pixel, the terminal can also obtain the digital color corresponding to the digital color value of each pixel in step S405. Then, in step S406, according to the numerical mapping relationship between the inverted color value and the digital color value of each pixel, a color lookup table of the inverted image data is obtained, and the color lookup table includes the corresponding relationship between the inverted color value and the digital color of each pixel in the inverted image data. Specifically, the terminal can first obtain the numerical mapping relationship between the inverted color value and the digital color value of each pixel, and the pixel corresponding to the inverted color value with the numerical mapping relationship and the pixel corresponding to the digital color value are the same pixel. Secondly, according to the numerical mapping relationship between the inverted color value and the digital color value of each pixel, the corresponding relationship between the inverted color value of each pixel and the digital color value with the mapping relationship can be determined. For example, the inverted color value of pixel a is (128, 128, 128), and the digital color value is (255, 255, 255), then the numerical mapping relationship of pixel a is (128, 128, 128)→(255, 255, 255); and the digital color corresponding to (255, 255, 255) is white, then the inverted color value of pixel a and the white digital color have a corresponding relationship, and the corresponding relationship is (255, 255, 255)→white.
[0074] After obtaining the correspondence between the inverted color value of each pixel and the digital color, the correspondence between the inverted color value of each pixel and the digital color can be used to construct a color lookup table; the color lookup table can be represented in the form of a table or in the form of a two-dimensional image. When the color lookup table is represented in the form of a two-dimensional image, the two-dimensional image can be a LUT (Look Up Table); the LUT is a 512×512 image, and the LUT can be composed of 8×8 large square grids, and each large square grid can be composed of 64×64 small squares. The embodiment of the present invention can use 64×64 small squares to store the R inverted component value and the G inverted component value of the pixel; wherein the horizontal axis of each large square grid can be represented by the R channel value, and the vertical axis can be represented by the G channel value; or the horizontal axis of each large square grid can be represented by the G channel value, and the vertical axis can be represented by the R channel value; for the convenience of explanation, the embodiments of the present invention are explained later by taking the horizontal axis as the R channel value and the vertical axis as the G channel value as an example. Since the value range of the R channel is [0, 255], with a total of 256 values, the width of each small square is 256 / 64=4, and the set of R channel values is [0, 4, 8, 12, 16, ..., 255]; similarly, the height of each small square is also 256 / 64=4, and the set of G channel values is also [0, 4, 8, 12, 16, ..., 255].
[0075] Unlike R and G values, the embodiment of the present invention can use 8×8 large squares to store B inverted component values; since the value range of the B channel is also [0, 255], each large square stores 4 B inverted component values, that is, the B inverted component values stored in the first large square are [0, 4), the B inverted component values stored in the second large square are [4, 8)... and so on. It should be noted that the B inverted component values can be stored in a row-first principle or in a column-first principle; the row-first principle refers to the principle of preferentially using large squares in the same row to store B inverted component values, that is, the first large square and the second large square are located in the same row; the column-first principle refers to the principle of preferentially using large squares in the same column to store B inverted component values, that is, the first large square and the second large square are located in the same column. Taking the storage of the B inverted component value according to the row priority principle as an example, how to construct a color lookup table (such as LUT) using the correspondence between the inverted color value of each pixel and the digital color is described in detail: suppose the inverted color value of pixel b is (5, 5, 1) and the digital color value is (0, 0, 0), then the correspondence between the inverted color value of pixel b and the digital color is (5, 5, 1) → black. First, the first large square can be located according to the B inverted component value 1 of pixel b; secondly, the position indicated by (5, 5) in the first large square can be used as the color drawing position of pixel b, and black is drawn at this color drawing position.
[0076] After obtaining the color lookup table, the inverted image data and the color lookup table can be used as digital image data of the negative image in step S407. If an image display request is received, the color lookup table and the inverted image data can be input into the rendering engine for rendering in response to the image display request in step S408 to obtain a digital image. Specifically, you can select any rendering engine from GPUImage (an image rendering framework), such as GPUImageLookupFilter (a color lookup filter); input the color lookup table and the inverted image data into the GPUImageLookupFilter for rendering to obtain a digital image. The present invention implements the input of the color lookup table and the inverted image data into the rendering engine for rendering, so that the rendering engine can search and render each pixel in parallel, thereby improving the rendering efficiency. After obtaining the digital image, the terminal can also display the rendered digital image in step S409.
[0077] In the embodiment of the present invention, since the negative film records the color opposite to the real color, after obtaining the initial color value of each pixel in the negative image in the target color space, the negative image can be first inverted to obtain inverted image data, which includes the inverted color value of each pixel. Then, according to the pixel distribution diagram of the inverted image data in the target color space, the inverted color value of each pixel can be value-equalized in the value range corresponding to the target color space, so that the digital color value of each pixel obtained by the value-equalization process can more accurately reflect the real color, thereby improving the accuracy of the digital image data of the negative image obtained according to the digital color value. It can be seen from the above image processing flow that the embodiment of the present invention does not need to use complex darkroom developing technology to develop the negative film, nor does it need to use a large number of negative images for model training, which can reduce the complexity of image processing to a certain extent and improve the feasibility of image processing.
[0078] In another embodiment, the embodiment of the present invention can also use a more sophisticated local color balancing processing method to perform color balancing on the inverted image, so as to achieve a better balancing effect. For example, in the HSV color space, the H channel (hue channel) can be stripped, and only the S channel (saturation channel) and the V channel (brightness channel) can be balanced, so that the image can be better satisfied in terms of saturation continuity and brightness continuity. Based on this, the embodiment of the present invention is Figure 6 A schematic flow chart of another image processing method is proposed in the text; the image processing method can be implemented by the terminal mentioned above. The terminal can obtain the negative image to be processed and the initial color value of each pixel in the negative image in the first color space in step S601; and in step S602, the negative image is inverted to obtain inverted image data, and the inverted color value of each pixel in the inverted image data is determined according to the initial color value of each pixel in the negative image. It should be noted that the specific implementation of steps S601-S602 can refer to steps S201-S202 or steps S401-S402 in the aforementioned embodiments, which will not be repeated here.
[0079] After obtaining the inverted image data, the inverted color value of each pixel in the inverted image data can be converted from the first color space to the second color space in step S603 to obtain the converted color value of each pixel. The first color space is the RGB color space, and the second color space is the HSV color space. Then, in S604, the converted color value of each pixel can be subjected to value balancing processing in the value range corresponding to the second color space to obtain the balanced color value of each pixel; the value range corresponding to the second color space can include the value range of each color channel in the second color space. In one embodiment, the specific implementation of step S604 can be: first, determine the regional range set composed of the maximum converted color value and the minimum converted color value from the converted color value of each pixel, and the regional range set includes the regional range composed of the minimum conversion component value and the maximum conversion component value under each color channel in the second color space; secondly, according to the regional range set, the converted color value of each pixel can be subjected to value balancing processing in the value range corresponding to the second color space to obtain the balanced color value of each pixel. Specifically, the target area range formed by the minimum conversion component value and the maximum conversion component value under the target color channel can be obtained from the area range set, and the target color channel is the S channel or the V channel in the second color space. Calculate the ratio of the value range of the target color channel and the target area range to obtain a proportional mapping parameter; use the proportional mapping parameter to calculate the conversion component value of each pixel under the target color channel to obtain the balanced component value of each pixel under the target color channel; obtain the balanced color value of each pixel according to the balanced component value of each pixel under the target color channel. It should be noted that the value range of the target color channel mentioned in the embodiment of the present invention is [0, 1]. The specific implementation process under this embodiment can refer to the relevant description of step S203 in the above-mentioned invention embodiment, which will not be repeated here.
[0080] In another embodiment, the specific implementation of step S604 can also be: first determine the pixel distribution map of the inverted image data in the second color space according to the converted color value of each pixel; specifically, for any color channel in the second color space, obtain the conversion component value of each pixel under the color channel; arrange each pixel in the order of the conversion component value of each pixel under the color channel from small to large to obtain the pixel distribution map of the inverted image data under the color channel. Repeat the above steps to obtain the pixel distribution map of the inverted image data in the second color space, that is, the pixel distribution map of the inverted image data in the second color space may include the pixel distribution map of the inverted image data under each color channel in the second color space. Secondly, according to the pixel distribution map, the inverted color value of each pixel is value-equalized within the value range corresponding to the second color space to obtain the balanced color value of each pixel. Specifically, the terminal can first determine the value of the numerical mapping parameter according to the pixel distribution map of the inverted image data under the target color channel and the value range of the target color channel, and the target color channel is the S channel or the V channel in the second color space. Then, according to the numerical mapping parameter value, the conversion component value of the target pixel in the target color channel is calculated to obtain the balanced component value of the target pixel in the target color channel; the balanced color value of the target pixel is determined according to the balanced component value of the target pixel in the target color channel. It should be noted that the value range of the target color channel mentioned in the embodiment of the present invention is [0, 1]. The specific implementation process under this embodiment can refer to the relevant description of step S203 or step S404 in the above-mentioned embodiment of the invention, which will not be repeated here.
[0081] After obtaining the balanced color value of each pixel, the balanced color value of each pixel can be converted from the second color space to the first color space in step S605 to obtain the digital color value of each pixel; and in step S606, the digital image data of the negative image is obtained according to the digital color value of each pixel.
[0082] In the embodiment of the present invention, since the negative film records the color opposite to the real color, after the negative film image is obtained, the negative film image can be firstly inverted to obtain inverted image data, and the inverted image data includes the inverted color value of each pixel. Then, the inverted color value of each pixel can be converted from the first color space to the second color space to obtain the converted color value of each pixel. The converted color value of each pixel is value-equalized within the value range corresponding to the second color space to obtain the balanced color value of each pixel; and the balanced color value of each pixel is converted from the second color space to the first color space to obtain the digital color value of each pixel, which can more accurately reflect the real color, thereby improving the accuracy of the digital image data of the negative film image obtained according to the digital color value. It can be seen from the above image processing flow that the embodiment of the present invention does not need to use complex darkroom developing technology to develop the negative film, nor does it need to use a large number of negative film images for model training, which can reduce the complexity of image processing to a certain extent and improve the feasibility of image processing.
[0083] Based on the description of the above method embodiment, in one embodiment, the present invention also provides a method as follows: Figure 7 The structural diagram of the image processing device shown in FIG. The image processing device can be run in a smart terminal, and the image processing device can be a computer program (including program code) running in the smart terminal. Figure 7 As shown, the image processing device in the embodiment of the present invention may include:
[0084] An acquisition unit 101 is used to acquire a negative image to be processed and an initial color value of each pixel in the negative image in a target color space;
[0085] A processing unit 102, configured to perform inversion processing on the negative image to obtain inverted image data, wherein the inverted color value of each pixel in the inverted image data is determined according to the initial color value of each pixel in the negative image;
[0086] The processing unit 102 is used to perform value equalization processing on the inverted color value of each pixel within the value range corresponding to the target color space according to the inverted image data to obtain the digital color value of each pixel;
[0087] The processing unit 102 is used to obtain digital image data of the negative image according to the digital color value of each pixel.
[0088] In one embodiment, the initial color value includes the initial component value of the pixel in each color channel in the target color space; accordingly, when the negative image is inverted to obtain inverted image data, the processing unit 102 can be specifically used to: obtain the value range of the target color channel, and the target color channel is any color channel in the target color space; perform difference calculation on the initial component value of each pixel in the negative image in the target color channel and the maximum value of the value range of the target color channel to obtain the inverted component value of each pixel in the target color channel; and obtain the inverted image data according to the inverted component value of each pixel in the target color channel.
[0089] In another embodiment, when performing value equalization processing on the inverted color values of each pixel within the value range corresponding to the target color space based on the inverted image data to obtain the digital color value of each pixel, the processing unit 102 can be specifically used to: obtain a pixel distribution map of the inverted image data in the target color space; and perform value equalization processing on the inverted color values of each pixel within the value range corresponding to the target color space based on the pixel distribution map to obtain the digital color value of each pixel.
[0090] In another embodiment, the pixel distribution map includes a pixel distribution map of the inverted image data in each color channel in the target color space, and the target color space includes an RGB color space; accordingly, when performing value equalization processing on the inverted color value of each pixel within a value range corresponding to the target color space according to the pixel distribution map to obtain a digital color value of each pixel, the processing unit 102 can be specifically used to: determine a numerical mapping parameter value according to the pixel distribution map of the inverted image data in the target color channel and the value range of the target color channel, and the target color channel is any one of the following channels: R channel, G channel or B channel; calculate the inverted component value of the target pixel in the inverted image data in the target color channel according to the numerical mapping parameter value to obtain the digital component value of the target pixel in the target color channel; determine the digital color value of the target pixel according to the digital component value of the target pixel in the target color channel.
[0091] In another embodiment, the pixel distribution diagram is a color histogram; accordingly, when determining the numerical mapping parameter value according to the pixel distribution diagram of the inverted image data under the target color channel and the value range of the target color channel, the processing unit 102 can be specifically used to: determine the total area of the color histogram of the inverted image data under the target color channel; based on the total area, determine the first inverted component value and the second inverted component value from the inverted component values of each pixel under the target color channel, the ratio of the local area determined by the first inverted component value and the minimum inverted component value to the total area satisfies the proportional condition, and the ratio of the local area determined by the second inverted component value and the maximum inverted component value to the total area satisfies the proportional condition; calculate the numerical mapping parameter value according to the numerical range formed by the first inverted component value and the second inverted component value, and the value range of the target color channel.
[0092] In another embodiment, the inverted component value of the target pixel is not less than the first inverted component value and not greater than the second inverted component value; when the inverted color values of each pixel are value-equalized within the value range corresponding to the target color space according to the pixel distribution map to obtain the digital color value of each pixel, the processing unit 102 can also be used to: if there is a first pixel whose inverted component value under the target color channel is less than the first inverted component value, the digital component value of the first pixel under the target color channel is set to the minimum value of the value range of the target color channel; if there is a second pixel whose inverted component value under the target color channel is greater than the second inverted component value, the digital component value of the second pixel under the target color channel is set to the maximum value of the value range of the target color channel.
[0093] In another embodiment, when the digital image data of the negative image is obtained according to the digital color value of each pixel, the processing unit 102 can be specifically used to: obtain the digital color corresponding to the digital color value of each pixel; obtain a color lookup table of the inverted image data according to the numerical mapping relationship between the inverted color value of each pixel and the digital color value, the color lookup table including the correspondence between the inverted color value of each pixel in the inverted image data and the digital color; use the inverted image data and the color lookup table as the digital image data of the negative image.
[0094] In another embodiment, the processing unit 102 may also be used to: in response to an image display request, input the color lookup table and the inverted image data into a rendering engine for rendering to obtain a digital image; and display the rendered digital image.
[0095] In the embodiment of the present invention, since the negative film records the color opposite to the real color, after obtaining the initial color value of each pixel in the target color space in the negative film image, the negative film image can be firstly inverted to obtain inverted image data, and the inverted image data includes the inverted color value of each pixel. Then, the inverted color value of each pixel can be value-equalized in the value range corresponding to the target color space according to the inverted image data, so that the digital color value of each pixel obtained by the value-equalization can more accurately reflect the real color, thereby improving the accuracy of the digital image data of the negative film obtained according to the digital color value. It can be seen from the above image processing flow that the embodiment of the present invention does not need to use complex darkroom developing technology to develop the negative film, nor does it need to use a large number of negative film images for model training, which can reduce the complexity of image processing to a certain extent and improve the feasibility of image processing.
[0096] In another embodiment, the present invention also provides a Figure 8 The structural diagram of the image processing device shown in FIG. The image processing device can be run in a smart terminal, and the image processing device can be a computer program (including program code) running in the smart terminal. Figure 8 As shown, the image processing device in the embodiment of the present invention may include:
[0097] An acquisition unit 201 is used to acquire a negative image to be processed and an initial color value of each pixel in the negative image in a first color space;
[0098] A processing unit 202 is used to perform inversion processing on the negative image to obtain inverted image data, wherein the inverted color value of each pixel in the inverted image data is determined according to the initial color value of each pixel in the negative image;
[0099] A conversion unit 203, configured to convert the inverted color value of each pixel in the inverted image data from the first color space to the second color space to obtain a converted color value of each pixel;
[0100] The processing unit 202 is used to perform value equalization processing on the converted color values of each pixel within the value range corresponding to the second color space to obtain the equalized color value of each pixel;
[0101] The conversion unit 203 is used to convert the balanced color value of each pixel from the second color space to the first color space to obtain the digital color value of each pixel;
[0102] The processing unit 202 is used to obtain digital image data of the negative image according to the digital color value of each pixel.
[0103] In one implementation, the first color space is an RGB color space, and the second color space is an HSV color space.
[0104] In another embodiment, when performing value equalization processing on the converted color values of each pixel within the value range corresponding to the second color space to obtain the balanced color values of each pixel, the processing unit 202 can be specifically used to: determine the pixel distribution map of the inverted image data in the second color space according to the converted color values of each pixel; and perform value equalization processing on the converted color values of each pixel within the value range corresponding to the second color space according to the pixel distribution map to obtain the balanced color values of each pixel.
[0105] In another embodiment, the pixel distribution map includes a pixel distribution map of the inverted image data in each color channel in the second color space, and the second color space is an HSV color space; accordingly, when value equalization processing is performed on the converted color values of each pixel within a value range corresponding to the second color space according to the pixel distribution map to obtain the balanced color values of each pixel, the processing unit 202 can be specifically used to: determine a numerical mapping parameter value according to the pixel distribution map of the inverted image data in the target color channel and the value range of the target color channel, and the target color channel is an S channel or a V channel in the second color space; calculate the converted component value of the target pixel in the target color channel according to the numerical mapping parameter value to obtain the balanced component value of the target pixel in the target color channel; determine the balanced color value of the target pixel according to the balanced component value of the target pixel in the target color channel.
[0106] In the embodiment of the present invention, since the negative film records the color opposite to the real color, after the negative film image is obtained, the negative film image can be firstly inverted to obtain inverted image data, and the inverted image data includes the inverted color value of each pixel. Then, the inverted color value of each pixel can be converted from the first color space to the second color space to obtain the converted color value of each pixel. The converted color value of each pixel is value-equalized within the value range corresponding to the second color space to obtain the balanced color value of each pixel; and the balanced color value of each pixel is converted from the second color space to the first color space to obtain the digital color value of each pixel, which can more accurately reflect the real color, thereby improving the accuracy of the digital image data of the negative film image obtained according to the digital color value. It can be seen from the above image processing flow that the embodiment of the present invention does not need to use complex darkroom developing technology to develop the negative film, nor does it need to use a large number of negative film images for model training, which can reduce the complexity of image processing to a certain extent and improve the feasibility of image processing.
[0107] Based on the above description, the embodiments of the present invention are also Fig. 9 A structural diagram of an intelligent terminal is proposed in FIG. Fig. 9 As shown, the intelligent terminal may include one or more processors 301; one or more input devices 302, one or more output devices 303 and a memory 304. The processor 301, the input device 302, the output device 303 and the memory 304 are connected via a bus 305. The memory 304 is used to store a computer program, the computer program includes a first program instruction, and the processor 301 is used to execute the first program instruction stored in the memory 304 to execute the above Figure 2 or Figure 4 Alternatively, the computer program includes a second program instruction, and the processor 301 is used to execute the second program instruction stored in the memory 304 to perform the above Figure 6 The image processing method shown.
[0108] In one embodiment, the processor 301 may be a central processing unit (CPU), or other general-purpose processors, i.e., a microprocessor or any conventional processor. The memory 304 may include a read-only memory and a random access memory, and provide instructions and data to the processor 301. Therefore, the processor 301 and the memory 304 are not limited herein.
[0109] The embodiment of the present invention further provides a computer storage medium, wherein the computer storage medium stores computer program instructions, and the processor 301 loads and executes one or more computer program instructions stored in the computer storage medium to implement the above Figure 2 , Figure 4 or Figure 6 In one embodiment, the computer storage medium stores a first computer program instruction, which can be loaded by the processor 301 and execute the following steps:
[0110] Acquire a negative image to be processed and an initial color value of each pixel in the negative image in a target color space;
[0111] Performing inversion processing on the negative image to obtain inverted image data, wherein the inverted color value of each pixel in the inverted image data is determined according to the initial color value of each pixel in the negative image;
[0112] According to the inverted image data, performing value equalization processing on the inverted color value of each pixel within the value range corresponding to the target color space to obtain the digital color value of each pixel;
[0113] The digital image data of the negative image is obtained according to the digital color value of each pixel.
[0114] In one embodiment, the initial color value includes the initial component value of the pixel in each color channel in the target color space; accordingly, when the negative image is inverted to obtain inverted image data, the first computer program instruction can be loaded and specifically executed by the processor 301: obtaining the value range of the target color channel, the target color channel is any color channel in the target color space; performing a difference calculation between the initial component value of each pixel in the negative image in the target color channel and the maximum value of the value range of the target color channel to obtain the inverted component value of each pixel in the target color channel; and obtaining the inverted image data according to the inverted component value of each pixel in the target color channel.
[0115] In another embodiment, when performing value equalization processing on the inverted color values of each pixel within the value range corresponding to the target color space based on the inverted image data to obtain the digital color value of each pixel, the first computer program instruction can be loaded by the processor 301 and specifically executed: obtaining a pixel distribution map of the inverted image data in the target color space; performing value equalization processing on the inverted color values of each pixel within the value range corresponding to the target color space based on the pixel distribution map to obtain the digital color value of each pixel.
[0116] In another embodiment, the pixel distribution map includes a pixel distribution map of the inverted image data in each color channel in the target color space, and the target color space includes an RGB color space; accordingly, when, according to the pixel distribution map, the inverted color value of each pixel is value-equalized within a value range corresponding to the target color space to obtain a digital color value of each pixel, the first computer program instruction can be loaded and specifically executed by the processor 301: a numerical mapping parameter value is determined according to the pixel distribution map of the inverted image data in the target color channel and the value range of the target color channel, and the target color channel is any one of the following channels: R channel, G channel or B channel; according to the numerical mapping parameter value, an inverted component value of a target pixel in the inverted image data in the target color channel is calculated to obtain a digital component value of the target pixel in the target color channel; and the digital color value of the target pixel is determined according to the digital component value of the target pixel in the target color channel.
[0117] In another embodiment, the pixel distribution diagram is a color histogram; accordingly, when determining the numerical mapping parameter value according to the pixel distribution diagram of the inverted image data under the target color channel and the value range of the target color channel, the first computer program instruction can be loaded by the processor 301 and specifically executed: determining the total area of the color histogram of the inverted image data under the target color channel; based on the total area, determining the first inverted component value and the second inverted component value from the inverted component values of each pixel under the target color channel, the ratio of the local area determined by the first inverted component value and the minimum inverted component value to the total area satisfies the proportional condition, and the ratio of the local area determined by the second inverted component value and the maximum inverted component value to the total area satisfies the proportional condition; and calculating the numerical mapping parameter value according to the numerical range formed by the first inverted component value and the second inverted component value, and the value range of the target color channel.
[0118] In another embodiment, the inverted component value of the target pixel is not less than the first inverted component value and not greater than the second inverted component value; accordingly, when the inverted color values of each pixel are value-equalized within the value range corresponding to the target color space according to the pixel distribution map to obtain the digital color values of each pixel, the first computer program instruction can also be loaded and executed by the processor 301: if there is a first pixel whose inverted component value under the target color channel is less than the first inverted component value, the digital component value of the first pixel under the target color channel is set to the minimum value of the value range of the target color channel; if there is a second pixel whose inverted component value under the target color channel is greater than the second inverted component value, the digital component value of the second pixel under the target color channel is set to the maximum value of the value range of the target color channel.
[0119] In another embodiment, when the digital image data of the negative image is obtained according to the digital color value of each pixel, the first computer program instruction can be loaded by the processor 301 and specifically executed: obtaining the digital color corresponding to the digital color value of each pixel; obtaining a color lookup table of the inverted image data according to the numerical mapping relationship between the inverted color value of each pixel and the digital color value, the color lookup table including the correspondence between the inverted color value of each pixel in the inverted image data and the digital color; using the inverted image data and the color lookup table as the digital image data of the negative image.
[0120] In another embodiment, the first computer program instruction can also be loaded and executed by the processor 301: in response to an image display request, input the color lookup table and the inverted image data into a rendering engine for rendering to obtain a digital image; and display the rendered digital image.
[0121] In another embodiment, the computer storage medium stores second computer program instructions, and the second computer program instructions can be loaded by the processor 301 and execute the following steps:
[0122] Acquire a negative image to be processed and an initial color value of each pixel in the negative image in a first color space;
[0123] Performing inversion processing on the negative image to obtain inverted image data, wherein the inverted color value of each pixel in the inverted image data is determined according to the initial color value of each pixel in the negative image;
[0124] Converting the inverted color value of each pixel in the inverted image data from the first color space to the second color space to obtain a converted color value of each pixel;
[0125] Performing value equalization processing on the converted color values of each pixel within a value range corresponding to the second color space to obtain an equalized color value of each pixel;
[0126] Converting the balanced color value of each pixel from the second color space to the first color space to obtain a digital color value of each pixel;
[0127] The digital image data of the negative image is obtained according to the digital color value of each pixel.
[0128] In one implementation, the first color space is an RGB color space, and the second color space is an HSV color space.
[0129] In another embodiment, when the converted color values of each pixel are value-equalized within the value range corresponding to the second color space to obtain the balanced color values of each pixel, the second computer program instructions can be loaded and specifically executed by the processor 301: determining the pixel distribution map of the inverted image data in the second color space according to the converted color values of each pixel; and performing value-equalization processing on the converted color values of each pixel within the value range corresponding to the second color space according to the pixel distribution map to obtain the balanced color values of each pixel.
[0130] In another embodiment, the pixel distribution map includes a pixel distribution map of the inverted image data in each color channel in the second color space, and the second color space is an HSV color space; accordingly, when, according to the pixel distribution map, the converted color value of each pixel is value-equalized within the value range corresponding to the second color space to obtain the balanced color value of each pixel, the second computer program instruction can be loaded and specifically executed by the processor 301: determine a numerical mapping parameter value according to the pixel distribution map of the inverted image data in the target color channel and the value range of the target color channel, and the target color channel is the S channel or the V channel in the second color space; calculate the converted component value of the target pixel in the target color channel according to the numerical mapping parameter value to obtain the balanced component value of the target pixel in the target color channel; determine the balanced color value of the target pixel according to the balanced component value of the target pixel in the target color channel.
[0131] In the embodiment of the present invention, since the negative film records the color opposite to the real color, after obtaining the initial color value of each pixel in the target color space in the negative film image, the negative film image can be firstly inverted to obtain inverted image data, and the inverted image data includes the inverted color value of each pixel. Then, the inverted color value of each pixel can be value-equalized in the value range corresponding to the target color space according to the inverted image data, so that the digital color value of each pixel obtained by the value-equalization can more accurately reflect the real color, thereby improving the accuracy of the digital image data of the negative film obtained according to the digital color value. It can be seen from the above image processing flow that the embodiment of the present invention does not need to use complex darkroom developing technology to develop the negative film, nor does it need to use a large number of negative film images for model training, which can reduce the complexity of image processing to a certain extent and improve the feasibility of image processing.
[0132] It should be noted that the specific working process of the terminal and the unit described above can refer to the relevant description in the aforementioned embodiments, which will not be repeated here.
[0133] A person skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program, and the program can be stored in a computer-readable storage medium, and when the program is executed, it can include the processes of the embodiments of the above-mentioned methods. The storage medium can be a disk, an optical disk, a read-only memory (ROM) or a random access memory (RAM), etc.
[0134] The above disclosure is only part of the embodiments of the present invention, which certainly cannot be used to limit the scope of the rights of the present invention. Ordinary technicians in this field can understand that all or part of the processes of the above embodiments and equivalent changes made according to the claims of the present invention are still within the scope of the invention.
Claims
1. An image processing method, characterized in that: Applied to smart terminals, including: When detecting a user's opening operation for the image processing function, starting to run the image processing function; Taking an image of the negative film to be processed to obtain a negative film image to be processed, identifying each pixel in the negative film image to obtain an initial color value of each pixel in a target color space; Performing inversion processing on the negative image to obtain inverted image data, wherein the inverted color value of each pixel in the inverted image data is determined according to the initial color value of each pixel in the negative image; the inversion processing refers to calculating the complement value of the initial color value of each pixel in the negative image, and using the complement value of each pixel as the inverted color value of each pixel; Acquire a pixel distribution map of the inverted image data in the target color space, wherein the pixel distribution map includes pixel distribution maps of the inverted image data in each color channel in the target color space, and the target color space includes an RGB color space; Performing value equalization processing on the inverted color value of each pixel in the value range corresponding to the target color space according to the pixel distribution map to obtain the digital color value of each pixel; including: determining the value of the numerical mapping parameter according to the pixel distribution map of the inverted image data under the target color channel and the value range of the target color channel, wherein the target color channel is any one of the following channels: R channel, G channel or B channel; calculating the inverted component value of the target pixel in the inverted image data under the target color channel according to the numerical mapping parameter value to obtain the digital component value of the target pixel under the target color channel; determining the digital color value of the target pixel according to the digital component value of the target pixel under the target color channel; The digital image data of the negative image is obtained according to the digital color value of each pixel.
2. The method according to claim 1, characterized in that The initial color value includes the initial component value of the pixel in each color channel in the target color space; the inverting process of the negative image to obtain the inverted image data includes: Obtain a value range of a target color channel, where the target color channel is any color channel in the target color space; Performing difference calculation on the initial component value of each pixel in the negative image under the target color channel and the maximum value of the value range of the target color channel to obtain the inverted component value of each pixel under the target color channel; The inverted image data is obtained according to the inverted component value of each pixel in the target color channel.
3. The method according to claim 1, characterized in that The pixel distribution diagram is a color histogram; the determining of the value mapping parameter value according to the pixel distribution diagram of the inverted image data in the target color channel and the value range of the target color channel comprises: Determine the total area of the color histogram of the inverted image data under the target color channel; Based on the total area, determining a first inverted component value and a second inverted component value from the inverted component values of each pixel under the target color channel, a ratio of a local area determined by the first inverted component value and a minimum inverted component value to the total area satisfies a proportional condition, and a ratio of a local area determined by the second inverted component value and a maximum inverted component value to the total area satisfies the proportional condition; The value mapping parameter value is calculated based on the value range formed by the first inverted component value and the second inverted component value and the value range of the target color channel.
4. The method according to claim 3, characterized in that The inverted component value of the target pixel is not less than the first inverted component value and not greater than the second inverted component value; The method further comprises: performing value balancing processing on the inverted color values of each pixel within the value range corresponding to the target color space according to the pixel distribution map to obtain the digital color value of each pixel. If there is a first pixel whose inverted component value under the target color channel is less than the first inverted component value, the digital component value of the first pixel under the target color channel is set to the minimum value of the value range of the target color channel; If there is a second pixel whose inverted component value under the target color channel is greater than the second inverted component value, the digital component value of the second pixel under the target color channel is set to the maximum value of the value range of the target color channel.
5. The method according to claim 1, characterized in that The step of obtaining the digital image data of the negative image according to the digital color value of each pixel comprises: Obtaining the digital color corresponding to the digital color value of each pixel; According to the numerical mapping relationship between the inverted color value of each pixel and the digital color value, a color lookup table of the inverted image data is obtained, wherein the color lookup table includes the corresponding relationship between the inverted color value of each pixel in the inverted image data and the digital color; The inverted image data and the color lookup table are used as digital image data of the negative image.
6. The method according to claim 5, characterized in that The method further comprises: In response to an image display request, the color lookup table and the inverted image data are input into a rendering engine for rendering to obtain a digital image; Displays the rendered digital image.
7. An image processing method, characterized in that: Applied to smart terminals, including: When detecting a user's opening operation for the image processing function, starting to run the image processing function; Taking an image of the negative film to be processed to obtain a negative film image to be processed, identifying each pixel in the negative film image to obtain an initial color value of each pixel in a first color space; Performing inversion processing on the negative image to obtain inverted image data, wherein the inverted color value of each pixel in the inverted image data is determined according to the initial color value of each pixel in the negative image; the inversion processing refers to calculating the complement value of the initial color value of each pixel in the negative image, and using the complement value of each pixel as the inverted color value of each pixel; Converting the inverted color value of each pixel in the inverted image data from the first color space to the second color space to obtain a converted color value of each pixel; the first color space is an RGB color space, and the second color space is an HSV color space; Determine a pixel distribution map of the inverted image data in the second color space according to the converted color values of each pixel, wherein the pixel distribution map includes a pixel distribution map of the inverted image data in each color channel in the second color space; Performing value equalization processing on the converted color values of each pixel in the value range corresponding to the second color space according to the pixel distribution map to obtain the balanced color value of each pixel; including: determining the value of the numerical mapping parameter according to the pixel distribution map of the inverted image data in the target color channel and the value range of the target color channel, the target color channel being the S channel or the V channel in the second color space; calculating the converted component value of the target pixel in the target color channel according to the numerical mapping parameter value to obtain the balanced component value of the target pixel in the target color channel; determining the balanced color value of the target pixel according to the balanced component value of the target pixel in the target color channel; Converting the balanced color value of each pixel from the second color space to the first color space to obtain a digital color value of each pixel; The digital image data of the negative image is obtained according to the digital color value of each pixel.
8. An intelligent terminal, characterized in that: The method comprises a processor, an input device, an output device and a memory, wherein the processor, the input device, the output device and the memory are interconnected, wherein the memory is used to store a computer program, the computer program comprises a first program instruction, the processor is configured to call the first program instruction and execute the image processing method as described in any one of claims 1 to 6; or, the computer program comprises a second program instruction, the processor is configured to call the second program instruction and execute the image processing method as described in claim 7.
9. A computer storage medium, characterized in that: The computer storage medium stores first computer program instructions, which are suitable for being loaded by a processor and executing the image processing method as described in any one of claims 1 to 6; or, the computer storage medium stores second computer program instructions, which are suitable for being loaded by a processor and executing the image processing method as described in claim 7.
Citation Information
Patent Citations
Digital processing of scanned negative films
US6204940B1
Producing an optimized color image from a negative image and its developed print image
US6295115B1
Method and apparatus for the conversion of color values
US6433898B1