Image processing method and device, electronic equipment and storage medium
By selecting key images and establishing mapping relationships based on grayscale distribution, the problems of inconsistent image processing are solved, the uniformity of grayscale distribution and calculation efficiency are improved, and the quality and user experience of stitching images are improved.
Patent Information
- Application Number
- CN202410089743.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-01-22
- Publication Date
- 2025-07-22
AI Technical Summary
The prior art is difficult to ensure the consistency of image processing of multiple images, resulting in uneven grayscale distribution between images in the same scene, affecting the quality of the stitched image and the user's visual experience.
By selecting at least one second image, determining the first mapping relationship based on its grayscale distribution, and using a joint probability distribution function and normalization processing, a first mapping relationship is established, and image processing is performed on the multiple first images to ensure consistency of the grayscale distribution.
The uniformity of grayscale distribution of multiple images is achieved, the quality of stitched images and user visual experience is improved, while reducing the computing volume and hardware requirements, shortening processing time and reducing costs.
Smart Images

Figure CN120355635A_ABST
Abstract
Description
Technical Field
[0001] This application relates to, but is not limited to, the field of positioning technology, and particularly relates to an image processing method and apparatus, an electronic device, and a storage medium. Background Art
[0002] In some scenarios, it is often necessary to obtain multiple images. There may be a correlation between these multiple images. For example, sometimes it is necessary to stitch multiple images. The images for stitching can be taken by multiple cameras from different orientations, or can be taken by one or more cameras at different times. The stitched image can contain more content and have a larger field of view.
[0003] After obtaining the images, it is often necessary to perform image processing on the images to enhance the image quality. Image processing can include processing the images using a histogram equalization algorithm. After image processing using the histogram equalization algorithm, the pixel distribution of the image can be made more uniform. However, the histogram can only reflect the gray-scale distribution of a single image.
[0004] Therefore, it is necessary to ensure the consistency of image processing for multiple images. Summary of the Invention
[0005] In view of this, this application provides at least an image processing method and apparatus, an electronic device, and a storage medium to ensure the consistency of image processing for multiple images.
[0006] In a first aspect, this application provides an image processing method. The method includes: obtaining a plurality of first images; selecting at least one second image from the plurality of first images; determining a first mapping relationship based on the at least one second image, where the first mapping relationship is obtained based on the gray-scale distribution of the at least one second image; and performing image processing on the plurality of first images according to the first mapping relationship.
[0007] In some possible implementation manners, the operation of determining the first mapping relationship based on the at least one second image may include: determining the probability distribution function of each second image in the at least one second image, where the probability distribution function is used to characterize the gray-scale distribution of each second image; determining the joint probability distribution function according to the probability distribution functions of the at least one second image; and determining the first mapping relationship according to the joint probability distribution function.
[0008] In some possible implementation manners, the operation of determining the joint probability distribution function based on the probability distribution functions of the at least one second image may include: adding the probability distribution functions of the at least one second image to obtain a first probability distribution function; and performing normalization processing on the first probability distribution function to obtain the joint probability distribution function.
[0009] In some possible embodiments, the joint probability distribution function is a monotonically increasing function.
[0010] In some possible embodiments, the operation of determining the first mapping relationship based on the joint probability distribution function may include: obtaining the first mapping relationship based on the joint probability distribution function and the maximum gray value.
[0011] In some possible embodiments, the operation of selecting at least one second image from multiple first images may include: selecting at least one second image from multiple first images according to a first strategy; wherein, the first strategy is associated with at least one of the following: gray distribution, discrete cosine transform.
[0012] In some possible embodiments, multiple first images are processed through image processing to obtain multiple third images, and the multiple third images have a consistent gray distribution.
[0013] In a second aspect, the present application provides an image processing apparatus. The apparatus includes an image acquisition module, an image selection module, a mapping determination module, and an image processing module. The image acquisition module is configured to acquire multiple first images. The image selection module is configured to select at least one second image from multiple first images. The mapping determination module is configured to determine a first mapping relationship based on at least one second image, wherein the first mapping relationship is obtained based on the gray distribution of at least one second image. The image processing module is configured to perform image processing on multiple first images according to the first mapping relationship.
[0014] In some possible embodiments, the mapping determination module may be configured to: determine the probability distribution function of each second image in at least one second image, wherein the probability distribution function is used to characterize the gray distribution of each second image; determine the joint probability distribution function according to the probability distribution function of at least one second image; determine the first mapping relationship according to the joint probability distribution function.
[0015] In some possible embodiments, the mapping determination module may be configured to: add the probability distribution functions of at least one second image to obtain a first probability distribution function; perform normalization processing on the first probability distribution function to obtain the joint probability distribution function.
[0016] In some possible embodiments, the joint probability distribution function may be a monotonically increasing function.
[0017] In some possible embodiments, the mapping determination module may be configured to: obtain the first mapping relationship based on the joint probability distribution function and the maximum gray value.
[0018] In some possible embodiments, the image selection module may be configured to: select at least one second image from a plurality of first images according to a first policy; wherein, the first policy is associated with at least one of the following: gray scale distribution, discrete cosine transform.
[0019] In some possible embodiments, a plurality of first images are processed through image processing to obtain a plurality of third images, and the plurality of third images have a consistent gray scale distribution.
[0020] In a third aspect, the present application provides an electronic device. The electronic device includes a processor and a memory. The memory is connected to the processor and is configured to store executable instructions. When the processor is configured to execute the executable instructions, an image processing method as described in any one of the first aspect and its possible embodiments is implemented.
[0021] In a fourth aspect, the present application provides a computer-readable storage medium. Executable instructions are stored on the storage medium. When the executable instructions are executed by a processor in an electronic device, an image processing method as described in any one of the first aspect and its possible embodiments is implemented.
[0022] In a fifth aspect, the present application provides a computer program product. The computer program product includes executable instructions. When the executable instructions are executed by a processor in an electronic device, an image processing method as described in any one of the first aspect and its possible embodiments is implemented.
[0023] In the present application, a first mapping relationship can be obtained based on the gray scale distribution of at least one second image, and the first mapping relationship is used to perform image processing on the first image. In this way, the obtained first mapping relationship can take into account the gray scale distribution of one or more of the plurality of first images. After the first image is processed by using such a first mapping relationship, the first mapping relationship has high consistency for the image processing of the plurality of first images, thereby avoiding excessive differences between the plurality of first images of the same scene and ensuring the uniformity of the gray scale distribution between the plurality of first images of the same scene. Further, after the first image is processed by the first mapping relationship, in the case of splicing the processed first images to obtain a spliced image or in the case of continuously viewing the processed first images, the user's visual experience is enhanced.
[0024] Furthermore, by selecting one or more second images from the plurality of first images and determining the first mapping relationship based on the second images, while ensuring the applicability of the first mapping relationship to the plurality of first images, the number of first images used to determine the first mapping relationship can be reduced, thereby significantly reducing the computational amount required to determine the first mapping relationship, accelerating the calculation speed and reducing the hardware requirements, thereby reducing time and cost.
[0025] In addition, by applying function value constraints and / or monotonicity constraints to the joint probability distribution function, on the one hand, the maximum and minimum values of the function values of the joint probability distribution function are 1 and 0 respectively, and on the other hand, the joint probability distribution function is a monotonic function. This ensures that each gray value in the first image can be mapped to a unique corresponding gray value, thereby enhancing the accuracy of the mapping.
[0026] It should be understood that the above general description and the following detailed description are only exemplary and explanatory, and do not limit the technical solutions of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] The accompanying drawings herein are incorporated into the specification and constitute a part of this specification. These drawings illustrate embodiments consistent with the present application and, together with the specification, are used to explain the technical solutions of the present application.
[0028] Figure 1 It is a schematic flowchart of an image processing method in an embodiment of the present application.
[0029] Figure 2A It is a schematic diagram of the first scene for collecting the first image by a camera in an embodiment of the present application.
[0030] Figure 2B It is a schematic diagram of the second scene for collecting the first image by a camera in an embodiment of the present application.
[0031] Figure 3 It is a schematic flowchart of step S120 of the image processing method in an embodiment of the present application for the second scene.
[0032] Figure 4 It is a schematic flowchart of step S130 of the image processing method in an embodiment of the present application.
[0033] Figure 5 It is a schematic structural diagram of an image processing device in an embodiment of the present application.
[0034] Figure 6 It is a schematic structural diagram of an electronic device in an embodiment of the present application. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0035] The embodiments of the present application will be described below with reference to the accompanying drawings in the embodiments of the present application. In the following description, reference is made to the accompanying drawings that form a part of the present application and illustrate specific aspects of the embodiments of the present application or specific aspects in which the embodiments of the present application can be used. It should be understood that the embodiments of the present application can be used in other aspects and may include structural or logical changes not depicted in the accompanying drawings. Therefore, the following detailed description should not be construed in a limiting sense, and the scope of the present application is defined by the appended claims. For example, it should be understood that the disclosure of the described method can be equally applicable to the corresponding device or system that executes the method, and vice versa. For example, if one or more specific method steps are described, the corresponding device may include one or more units such as functional units to execute the one or more described method steps (e.g., one unit executes one or more steps, or multiple units, where each executes one or more of the multiple steps), even if such one or more units are not explicitly depicted or described in the accompanying drawings. On the other hand, for example, if a specific device is described based on one or more units such as functional units, the corresponding method may include a step to execute the functionality of the one or more units (e.g., one step executes the functionality of one or more units, or multiple steps, where each executes the functionality of one or more of the multiple units), even if such one or more steps are not explicitly depicted or described in the accompanying drawings. Further, it should be understood that, unless otherwise explicitly stated, the features of the various exemplary embodiments and / or aspects described herein can be combined with each other.
[0036] Figure 1 It is a schematic flowchart of an image processing method in an embodiment of the present application. As Figure 1 shown, the image processing method in the embodiment of the present application may include steps S110 to S140.
[0037] In step S110, a plurality of first images are obtained.
[0038] Here, the first image may include at least one of the following: a grayscale image, a color image.
[0039] In some embodiments, the plurality of first images may be images captured by one or more cameras. In one example, the original image captured by the camera may be a grayscale image. At this time, the original image captured by the camera may be directly used as the first image. In one example, the original image captured by the camera may be a color image or other image. At this time, the original image captured by the camera may be processed through image processing to obtain the corresponding grayscale image, and the obtained grayscale image may be used as the first image.
[0040] In some embodiments, the image processing from the original image to the grayscale image can be implemented by a camera. At this time, the image collected by the camera can be a color image or other images, and the output image can be a grayscale image. In some embodiments, the image processing from the original image to the grayscale image can be implemented by an electronic device other than the camera. At this time, the original image output by the camera can be stored in the electronic device and converted into a grayscale image by the electronic device.
[0041] In some embodiments, the camera can be disposed on an object. In one example, multiple cameras can be disposed on the same object. In one example, multiple cameras can be disposed on different objects. In other words, one or more cameras can be disposed on an object.
[0042] In some embodiments, the object can be a fixed or moving object. For example, the object can be a fixed object such as a tripod or a street lamp. For example, the object can be a moving object such as a vehicle, a drone, a ship, an aircraft, a handheld gimbal, or a personal terminal device.
[0043] In some embodiments, the multiple first images can be images collected by multiple cameras. The multiple cameras can correspond to different orientations. Thus, the content presented in the first images collected by the multiple cameras can be different. It should be noted that the number, position, and orientation of the multiple cameras can be set arbitrarily according to actual needs, and the embodiments of the present application do not make specific limitations on this.
[0044] Figure 2A This is a schematic diagram of the first scenario for collecting the first image by the camera in the embodiments of the present application. As Figure 2A shown, three cameras 2021, 2022, and 2023 can be disposed on the object 201. The three cameras 2021, 2022, and 2023 correspond to different orientations. The camera 2021 can face the ground and is used to collect the image of the ground in front of the object 201. The camera 2022 can horizontally face the front of the object 201 and is used to collect the image of the front of the object 201. The camera 2023 can face the sky and is used to collect the image of the sky in front of the object 201. The content in the first image 2031 collected by the camera 2021 is mainly the ground. The content in the first image 2033 collected by the camera 2023 is mainly the sky. The content in the first image 2032 collected by the camera 2022 can include both the ground and the sky.
[0045] In some embodiments, the multiple first images can be images collected by at least one camera at different times. Thus, as time goes by, the content presented in the first images collected by the camera at different times can be different.
[0046] Figure 2B This is a schematic diagram of the second scenario for collecting the first image by the camera in the embodiment of the present application. As Figure 2B shown, the object 201 can move in one direction. The camera 2024 located in front of the object 201 can collect images of the moving direction of the object 201 at different times. Then, as time goes by and / or as the object 201 moves to different positions, the content in the multiple first images collected by the camera 2024 can be different.
[0047] In some embodiments, multiple first images can be used for stitching. The multiple first images can be stitched to obtain a stitched image. Compared with each first image, the stitched image can contain more content and present a wider field of view. In one example, the stitched image obtained based on the stitching of multiple first images can present a 180-degree or even 360-degree view. For example, the multiple first images can be stitched to obtain a full-frame image. For example, the multiple first images can be stitched to obtain a panoramic image.
[0048] In step S120, at least one second image is selected from the multiple first images.
[0049] Here, the second image can be one or more of the multiple first images. Then, at least one second image can form a subset of the image set composed of the multiple first images.
[0050] In some embodiments, the second image can be the multiple first images. In other words, each first image can be used as the second image. In this case, the number of the first images and the second images can be equal.
[0051] In some embodiments, the second image can be a part of the multiple first images. In other words, the second image can include some of the multiple first images. The number of the second images can be less than the number of the first images. It can be understood that in this case, the second image can be referred to as a "key image".
[0052] In some embodiments, a first threshold can be set for the second image. The first threshold represents the maximum number of second images that can be selected. In this case, when the number of the first images is greater than the first threshold, the maximum number of second images can be selected from the first images; when the number of the first images is less than or equal to the first threshold, all the first images can be used as the second images.
[0053] In some embodiments, step S120 may be implemented as: selecting at least one second image from a plurality of first graphics according to a first strategy. Here, the first strategy may be set according to actual application, that is, the second image may be selected from the first image in any manner according to specific needs. This embodiment of the present application does not specifically limit this.
[0054] In some embodiments, the selection of the second image may be implemented based on image content. The plurality of first images may contain different image contents. Different image contents may cause different first images to have different grayscale distributions. In some embodiments, the first strategy may be associated with the grayscale distribution. More specifically, the grayscale distribution of the second image selected according to the first strategy is closer to the grayscale distribution of all first images than other first images in the plurality of first images.
[0055] In one example, for Figure 2A In the first scene shown, the first images 2031, 2032, and 2033 obtained by three cameras 2021, 2022, and 2023 can be spliced to obtain a spliced image. The content of the spliced image can include the ground and the sky at the same time. The content in the first image 2031 is mainly the ground, and its grayscale distribution is more inclined to gray (that is, more pixels are distributed at smaller grayscale values in the grayscale histogram). The content in the first image 2033 is mainly the sky, and its grayscale distribution is more inclined to bright (that is, more pixels are distributed at larger grayscale values in the grayscale histogram). The grayscale distribution of the first images 2031 and 2033 has a large deviation relative to the grayscale distribution of the spliced image. The content in the first image 2032 includes the ground and the sky at the same time, and its grayscale distribution is closer to the grayscale distribution of the spliced image. In this way, the first image 2032 can be used as a "key image" in multiple first images, that is, a second image.
[0056] In some embodiments, the selection of the second image can be implemented based on image similarity. For multiple first images captured by the same camera at different times, some of the first images may have substantially the same or similar image content. In this case, one or more first images with less similarity (i.e., greater difference) among the multiple first images can be used as the second image.
[0057] In one example, for Figure 2B In the second scene shown, at least one first image can be selected as a second image from among the multiple first images captured by the camera 2024. The similarities between the selected second images are relatively small.
[0058] In some embodiments, the image similarity can be obtained by discrete cosine transform. In other words, the first strategy can be associated with discrete cosine transform.
[0059] Figure 3 This is a flowchart of step S120 of the image processing method in the embodiments of this application for the second scenario. As Figure 3 shown, in some embodiments, step S120 may include steps S121 to S125.
[0060] In step S121, sort the first images.
[0061] Here, multiple first images can be sorted according to the acquisition time. In one example, multiple first images can be sorted from the earliest to the latest acquisition time. In one example, multiple first images can be sorted from the latest to the earliest acquisition time.
[0062] In step S122, calculate the discrete cosine transform of the first images.
[0063] Here, the discrete cosine transform can be performed for each first image to obtain the result of the discrete cosine transform. In this way, the results of the discrete cosine transform of multiple first images can be obtained respectively.
[0064] In some embodiments, the result obtained through the discrete cosine transform can be a coefficient matrix. The size of this coefficient matrix can be the same as the size of the first image.
[0065] In step S123, determine a first matrix for the first images based on the result of the discrete cosine transform.
[0066] Here, step S123 can be specifically implemented as follows: for each first image, first calculate the average value of each element in the coefficient matrix obtained by calculating the discrete cosine transform of this first image; then, compare the gray value of each pixel of this first image with this average value; if the gray value of the pixel is greater than the average value, the comparison result corresponding to this pixel is a first value; if the gray value of the pixel is less than the average value, the comparison result corresponding to this pixel can be a second value; if the gray value of the pixel is equal to the average value, the comparison result corresponding to this pixel can be the first value or the second value; for the comparison results of all pixels in the first image, a first matrix can be obtained. In this way, each element in the first matrix can have the first value or the second value.
[0067] In one example, the first value can be 1 and the second value can be 0. Of course, the first value and the second value can respectively have other values, and the embodiments of this application do not make specific limitations on this.
[0068] In some embodiments, the size of the first matrix can be the same as the size of the first image.
[0069] In step S124, compare the first matrices of multiple first images.
[0070] In this step, when one of the multiple first images is determined to be the second image, the first matrix of this first image can be compared successively with the first matrices of the subsequent first images.
[0071] In some embodiments, the comparison of the first matrices of two first images in step S124 can be implemented as follows: comparing the elements at the corresponding positions in the first matrices of the two first images; if the values of the elements at the corresponding positions are the same, the comparison result can be a third value; if the values of the elements at the corresponding positions are different, the comparison result can be a fourth value; accumulating the comparison results of all the elements in the first matrix to obtain an accumulated value; comparing the accumulated value with a second threshold; if the accumulated value is greater than the second threshold, it is determined that the two first images are not similar; if the accumulated value is less than the second threshold, it is determined that the two first images are similar; if the accumulated value is equal to the second threshold, it is determined that the two first images are similar or not similar.
[0072] In one example, the third value can be 0 and the fourth value can be 1. Of course, the third value and the fourth value can respectively have other values, and the embodiments of the present application do not make specific limitations thereto.
[0073] In some embodiments, the second threshold can be set according to specific needs, and the embodiments of the present application do not make specific limitations thereto.
[0074] Here, the first matrix of the first image determined to be the second image is compared with the first matrices of the subsequent first images until a first image that is not similar to this first image is determined. The determined first image can be used as the next second image. After that, starting from the determined next second image, the next next second image can be continued to be determined. And so on, until all the first images are traversed.
[0075] In some embodiments, the first first image after sorting of the multiple first images can be used as the first second image.
[0076] It can be understood that in the case of the combination of the first scenario and the second scenario, the second image can be selected based on both the image content and the image similarity.
[0077] In step S125, based on the comparison result of the first matrix, the second image is determined.
[0078] Here, after completing the comparison between all the first matrices, the determined non-similar first images can be determined as the second images.
[0079] In step S130, based on at least one second image, the first mapping relationship is determined.
[0080] Here, the first mapping relationship is obtained based on the gray-scale distribution of the second image. The first mapping relationship can be used to map the gray-scale distributions of multiple first images, thereby realizing image processing of the first images.
[0081] In some embodiments, the gray-scale distribution can be presented in the form of a gray-scale histogram.
[0082] Figure 4 It is a schematic flowchart of step S130 of the image processing method in the embodiments of the present application. As Figure 4 shown, in some embodiments, step S130 may include steps S131 to S133.
[0083] In step S131, determine the probability distribution function of each second image.
[0084] Here, the probability distribution function is used to characterize the gray-scale distribution of each second image.
[0085] In some embodiments, step S131 may include the following two sub-steps.
[0086] In the first sub-step, determine the probability density function of the gray-scale of each second image.
[0087] Here, the probability density function can be used to represent the distribution density of the pixels in the second image at each gray-scale value.
[0088] In some embodiments, for each second image, its probability density function can be expressed as:
[0089]
[0090] where, r represents the gray-scale value; n r represents the number of pixels with the gray-scale value of r in this second image; N represents the number of pixels in this second image; P r represents the probability density function of the gray-scale of this second image.
[0091] In some embodiments, the value range of r can be [0, L - 1], where L is used to define the maximum gray-scale value that r can take. In an example, the value range of r can be [0, 255], correspondingly, L can be 256.
[0092] In some embodiments, the value range of n r can be [0, N]. That is to say, the maximum value of n r can be the number of pixels in this second image.
[0093] It can be understood that for each second image, the corresponding probability density function can be obtained. In the probability density functions of each second image, r and nr The value ranges can be the same.
[0094] In the second sub-step, according to the probability density function, the probability distribution function is determined.
[0095] Here, based on the probability degree function, the probability distribution function of each second image can be obtained as follows:
[0096]
[0097] Wherein, w is a formal variable; F(r) is the probability distribution function of the gray level of this second image.
[0098] It should be noted that the probability distribution function is a monotonically non-decreasing function.
[0099] After processing each second image in sequence through the above first sub-step and second sub-step, the probability distribution function of each second image can be obtained. Thus, the probability distribution function of each second image in at least one second image can be expressed as:
[0100]
[0101] Wherein, i is the index of each second image in at least one second image. i is an integer, and i = 1, 2,..., I. I is the number of second images.
[0102] In step S132, according to the probability distribution function, the joint probability distribution function of the second image is determined.
[0103] Here, based on the probability distribution functions of all the second images, the joint probability distribution function can be obtained. Thus, the joint probability distribution function can be expressed as:
[0104] C(r) = f(F1(r), F2(r), F3(r),…, F I (r)) (4).
[0105] In some embodiments, the joint probability distribution function can satisfy at least one of the following: function value constraint, monotonicity constraint.
[0106] In some embodiments, the function value constraint can be used to indicate the value range of the function value of the joint probability distribution function. In one example, since the probability distribution function is used to represent probability, the value range of the probability distribution function can be [0, 1]. Of course, the function value constraint can also indicate other value ranges, and the embodiments of the present application do not make specific limitations thereto.
[0107] In some embodiments, the monotonicity constraint can be used to indicate that the joint probability distribution function is a monotonic function. In one example, the monotonicity constraint is used to indicate that the joint probability distribution function is a non-decreasing monotonic function.
[0108] In some embodiments, step S132 may include two sub-steps.
[0109] In the first sub-step, the probability distribution functions of at least one second image are added together to obtain a first probability distribution function.
[0110] In this sub-step, the probability distribution functions of each second image can be combined together by summation to form a first probability distribution function.
[0111] In the second sub-step, the first probability distribution function is normalized to obtain a joint probability distribution function.
[0112] In this sub-step, by normalizing the first probability distribution function, the value range of the function values of the joint probability distribution function can be limited to [0, 1].
[0113] Specifically, the normalization process can be implemented as follows: the ratio of the first probability distribution function to the number of second images can be calculated.
[0114] The joint probability distribution function determined by the above first sub-step and second sub-step can be expressed as:
[0115]
[0116] In formula (5), 0 ≤ F i (r) ≤ 1, then 0 ≤ F i (r) ≤ 1, so that 0 ≤ C(r) ≤ 1.
[0117] Here, the monotonicity of formula (5) is explained. For any r2 > r1, there can be:
[0118]
[0119] Because the probability distribution function is a non-decreasing monotonic function, for r2 > r1, there is:
[0120]
[0121] In this way, C(r2) - C(r1) ≥ 0 can be obtained, that is, the joint probability distribution function is a non-decreasing monotonic function.
[0122] It should be noted that the joint probability distribution function obtained based on the probability distribution functions of all second images may also have other forms, and the embodiments of the present application do not make specific limitations thereto.
[0123] In step S133, a first mapping relationship is determined according to the joint probability distribution function.
[0124] Here, after obtaining the joint probability distribution function, the first mapping relationship can be further obtained.
[0125] In some embodiments, the first mapping relationship may be in the form of a function. At this time, the first mapping relationship may also be referred to as the first mapping function. Of course, the first mapping relationship may also be in the form of a mapping table or other forms, and the embodiments of the present application do not make specific limitations thereon.
[0126] Here, the first mapping function obtained based on the joint probability distribution function can be expressed as:
[0127] s = T(r) = (L - 1)C(r) (8);
[0128] Among them, s is the new gray value mapped by the pixel with gray value r in the first image through the first mapping function.
[0129] It can be seen from formula (8) that the first mapping function T(r) is the product between the joint probability distribution function C(r) and the coefficient (L - 1). Since the joint probability distribution function is a monotonic function and the coefficient (L - 1) is usually greater than 0, the first mapping function can have the same monotonicity as the joint probability distribution function. Then, in the process of using the first mapping function to implement the gray mapping of the first image, each gray value of the first image can be mapped to a unique corresponding gray value, thereby enhancing the accuracy of the mapping.
[0130] In some embodiments, for the joint probability distribution function of formula (5), the corresponding first mapping function can be expressed as:
[0131]
[0132] In this way, through steps S131 to S133, the first mapping function can be obtained based on the probability distribution function of the second image.
[0133] In step S140, image processing is performed on multiple first images according to the first mapping relationship.
[0134] Here, multiple first images can be converted into multiple third images according to the first mapping relationship.
[0135] Specifically, in this step, the gray value of each pixel of each first image can be mapped to a new gray value according to the first mapping relationship. The image with the mapped gray value can be referred to as the third image.
[0136] The range of the gray values of the pixels in the third image can be the same as that of the multiple first images. In one example, the range of the gray values of the pixels in the third image can be [0, L - 1].
[0137] In some embodiments, the multiple third images can have a consistent gray distribution. More specifically, the adjustment of the gray distribution of the multiple first images using the first mapping relationship can be consistent.
[0138] Here, an explanation can be given for the "equalization" effect of the first mapping function on the gray distribution of the multiple first images.
[0139] The probability density function of the gray value of the third image can be expressed as p(s). During the process of mapping the gray value of the pixel in the first image to the gray value of the pixel in the third image, if the cumulative quantity of r and s remains unchanged, the following formula can be obtained:
[0140]
[0141] By transforming formula (10), the following formula can be obtained:
[0142]
[0143] On the other hand, by combining formulas (8) and (9), the following formula can be obtained:
[0144]
[0145] Then, by combining formulas (10) and (12), the following formula can be obtained:
[0146]
[0147] It can be seen from formula (12) that the probability density function of the gray value of the third image obtained by performing image processing on the first image using the first mapping relationship can be uniformly distributed within the range [0, L - 1].
[0148] So far, through the above steps S110 to S140, image processing can be performed on the multiple first images to obtain the same number of third images.
[0149] In the embodiments of the present application, a first mapping relationship can be obtained based on the gray-scale distribution of at least one second image, and the first mapping relationship is used to perform image processing on the first image. In this way, the obtained first mapping relationship can take into account the gray-scale distribution of one or more of the multiple first images. After performing image processing on the first image using such a first mapping relationship, the first mapping relationship has high consistency for the image processing of multiple first images, thereby avoiding excessive differences between multiple first images of the same scene and ensuring the uniformity of the gray-scale distribution between multiple first images of the same scene. Further, in the case of splicing the image-processed first images to obtain a spliced image or continuously viewing the image-processed first images, the visual experience of the user is enhanced.
[0150] Secondly, for the joint probability distribution function, function value constraints and / or monotonicity constraints are applied. On the one hand, the maximum and minimum values of the function values of the joint probability distribution function are 1 and 0 respectively, and on the other hand, the joint probability distribution function is a monotonic function. This ensures that each gray value in the first image can be mapped to a unique corresponding gray value, thereby enhancing the accuracy of the mapping.
[0151] In addition, by selecting one or more second images from multiple first images and determining the first mapping relationship based on the second images, while ensuring the applicability of the first mapping relationship to multiple first images, the number of first images used to determine the first mapping relationship can be reduced, thereby significantly reducing the computational amount required to determine the first mapping relationship, accelerating the calculation speed and reducing the hardware requirements, thereby reducing time and cost.
[0152] Based on the same inventive concept, embodiments of the present application provide an image processing apparatus. The apparatus can be disposed in an electronic device.
[0153] Figure 5 It is a schematic structural diagram of an image processing apparatus in the embodiments of the present application. As Figure 5 shown, the image processing apparatus 500 may include an image acquisition module 501, an image selection module 502, a mapping determination module 503, and an image processing module 504. The image acquisition module 501 is configured to acquire multiple first images. The image selection module 502 is configured to select at least one second image from the multiple first images. The mapping determination module 503 is configured to determine a first mapping relationship based on at least one second image, where the first mapping relationship is obtained based on the gray-scale distribution of at least one second image. The image processing module 504 is configured to perform image processing on the multiple first images according to the first mapping relationship.
[0154] In some possible embodiments, the mapping determination module 503 may be configured to: determine the probability distribution function of each of at least one second image, where the probability distribution function is used to characterize the gray-scale distribution of each second image; determine the joint probability distribution function according to the probability distribution functions of the at least one second image; and determine the first mapping relationship according to the joint probability distribution function.
[0155] In some possible embodiments, the mapping determination module 503 may be configured to: add the probability distribution functions of the at least one second image to obtain a first probability distribution function; and perform normalization processing on the first probability distribution function to obtain the joint probability distribution function.
[0156] In some possible embodiments, the joint probability distribution function may be a monotonically increasing function.
[0157] In some possible embodiments, the mapping determination module 503 may be configured to: obtain the first mapping relationship based on the joint probability distribution function and the maximum gray-scale value.
[0158] In some possible embodiments, the image selection module 502 may be configured to: select at least one second image from multiple first images according to a first strategy; where the first strategy is associated with at least one of the following: gray-scale distribution, discrete cosine transform.
[0159] In some possible embodiments, multiple first images are processed to obtain multiple third images, and the multiple third images have a consistent gray-scale distribution.
[0160] The description of the above device embodiments is similar to the description of the above method embodiments and has similar beneficial effects to the method embodiments. In some embodiments, the functions or modules included in the device provided in the embodiments of the present application can be used to execute the methods described in the above method embodiments. For the technical details not disclosed in the device embodiments of the present application, please refer to the description of the method embodiments of the present application for understanding.
[0161] Based on the same inventive concept, the embodiments of the present application provide an electronic device. Figure 6 It is a schematic structural diagram of an electronic device in the embodiments of the present application. As Figure 6 shown, the electronic device 600 includes a processor 601 and a memory 602. The memory 602 is connected to the processor 601 and is configured to store executable instructions. The processor 601 is configured to: when executing the executable instructions, implement the image processing method of the embodiments of the present application.
[0162] Based on the same inventive concept, an embodiment of the present application provides a computer-readable storage medium. The storage medium stores executable instructions. When the executable instructions are executed by a processor, the image processing method of the embodiment of the present application is implemented.
[0163] Based on the same inventive concept, an embodiment of the present application provides a computer program product. The computer program product includes executable instructions. When the executable instructions are executed by a processor, the image processing method of the embodiment of the present application is implemented.
[0164] Those skilled in the art can appreciate that the functions described in connection with the various illustrative logical blocks, modules, and algorithm steps disclosed herein can be implemented in hardware, software, firmware, or any combination thereof. If implemented in software, the functions described by the various illustrative logical blocks, modules, and steps can be stored or transmitted as one or more instructions or codes on a computer-readable medium and executed by a hardware-based processing unit. The computer-readable medium can include a computer-readable storage medium corresponding to a tangible medium, such as a data storage medium, or a communication medium including any medium that facilitates the transfer of a computer program from one place to another (e.g., according to a communication protocol). In this way, the computer-readable medium generally corresponds to (1) a non-transitory tangible computer-readable storage medium, or (2) a communication medium, such as a signal or a carrier wave. The data storage medium can be any available medium that can be accessed by one or more computers or one or more processors to retrieve instructions, codes, and / or data structures for implementing the techniques described in the present application. The computer program product can include a computer-readable medium.
[0165] By way of example, and not limitation, such computer-readable storage media can include Random Access Memory (RAM), Read-Only Memory (ROM), Electrically Erasable Programmable Read-Only Memory (EEPROM), Compact Disc Read-Only Memory (CD-ROM) or other optical disk storage, magnetic disk storage or other magnetic storage devices, flash memory, or any other medium that can be used to store the desired program code in the form of instructions or data structures and that is accessible by a computer. Also, any connection is properly termed a computer-readable medium. For example, if instructions are transmitted from a website, server, or other remote source using coaxial cable, fiber optic cable, twisted pair, Digital Subscriber Line (DSL), or wireless technologies such as infrared, radio, and microwave, then the coaxial cable, fiber optic cable, twisted pair, DSL, or wireless technologies such as infrared, radio, and microwave are included in the definition of the medium. However, it should be understood that the computer-readable storage media and data storage media do not include connections, carrier waves, signals, or other transient media, but rather are directed to non-transitory tangible storage media. As used herein, disk and disc include compact disc, laser disc, optical disc, digital versatile disc (DVD), and Blu-ray disc, where disks typically reproduce data magnetically, while discs reproduce data optically using lasers. Combinations of the above should also be included within the scope of computer-readable media.
[0166] The instructions can be executed by one or more processors, such as one or more Digital Signal Processors (DSPs), general purpose microprocessors, Application Specific Integrated Circuits (ASICs), Field Programmable Gate Arrays (FPGAs), or other equivalent integrated or discrete logic circuitry. Thus, the term "processor" as used herein can refer to any one of the foregoing structures or any other structure suitable for implementing the techniques described herein. Additionally, in some aspects, the functions described for the various illustrative logical blocks, modules, and steps can be provided within dedicated hardware and / or software modules configured for encoding and decoding, or incorporated in a combined codec. The techniques can be implemented entirely in one or more circuits or logic elements.
[0167] The technology of this application can be implemented in various devices or apparatuses described above, including wireless handsets, integrated circuits (ICs), or a group of ICs (e.g., a chipset). Various components, modules, or units are described in this application to emphasize the functional aspects of the apparatuses for performing the disclosed technology, but they do not necessarily need to be implemented by different hardware units. In fact, as described above, various units can be combined in a codec hardware unit with appropriate software and / or firmware, or provided by interoperating hardware units, including one or more processors as described above.
[0168] In the above embodiments, the descriptions of the respective embodiments have their own focuses. For parts not detailed in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0169] It should be understood that in various embodiments of this application, the magnitudes of the serial numbers of the above steps / processes do not mean the order of execution. The order of execution of each step / process should be determined by its function and internal logic, and should not constitute any limitation to the implementation process of the embodiments of this application.
[0170] As described above, the above are only exemplary specific implementation manners of this application, but the protection scope of this application is not limited thereto. Any changes or substitutions that can be easily thought of by those skilled in the art within the technical scope disclosed in this application should be covered by the protection scope of this application. Therefore, the protection scope of this application should be subject to the protection scope of the claims.
Claims
1. An image processing method, characterized in that, The method includes: Obtaining a plurality of first images; Selecting at least one second image from the plurality of first images; Based on the at least one second image, determining a first mapping relationship, wherein the first mapping relationship is obtained based on the gray-scale distribution of the at least one second image; Performing image processing on the plurality of first images according to the first mapping relationship.
2. The method according to claim 1, wherein The determining the first mapping relationship based on the at least one second image includes: Determining a probability distribution function of each second image in the at least one second image, wherein the probability distribution function is used to characterize the gray-scale distribution of each second image; Determining a joint probability distribution function according to the probability distribution functions of the at least one second image; Determining the first mapping relationship according to the joint probability distribution function.
3. The method according to claim 2, wherein The determining the joint probability distribution function based on the probability distribution functions of the at least one second image includes: Adding the probability distribution functions of the at least one second image to obtain a first probability distribution function; Performing normalization processing on the first probability distribution function to obtain the joint probability distribution function.
4. The method according to claim 2 or 3, characterized in that, The joint probability distribution function is a monotonically increasing function.
5. The method according to claim 2, wherein The determining the first mapping relationship based on the joint probability distribution function includes: Obtaining the first mapping relationship based on the joint probability distribution function and the maximum gray-scale value.
6. The method according to claim 1, characterized in that The selecting at least one second image from the plurality of first images includes: Selecting the at least one second image from the plurality of first images according to a first strategy; wherein the first strategy is associated with at least one of the following: gray-scale distribution, discrete cosine transform.
7. The method according to claim 1, wherein The plurality of first images are subjected to image processing to obtain a plurality of third images, and the plurality of third images have a consistent gray-scale distribution.
8. An image processing apparatus, characterized in that, The apparatus includes: An image acquisition module configured to obtain a plurality of first images; An image selection module configured to select at least one second image from the plurality of first images; A mapping determination module configured to determine a first mapping relationship based on the at least one second image, wherein the first mapping relationship is obtained based on the gray-scale distribution of the at least one second image; An image processing module configured to perform image processing on the plurality of first images according to the first mapping relationship.
9. An electronic device, characterized in that, The electronic device includes: A processor; A memory connected to the processor and configured to store executable instructions; wherein, when the processor is configured to execute the executable instructions, the image processing method according to any one of claims 1 to 7 is implemented.
10. A computer-readable storage medium having executable instructions stored thereon, characterized in that, When the executable instructions are executed by a processor in an electronic device, the processor is caused to execute the image processing method according to any one of claims 1 to 7.
11. A computer program product comprising executable instructions, characterized in that, When the executable instructions are executed by a processor, the image processing method according to any one of claims 1 to 7 is implemented.