An image color uniformity method supporting arbitrary shapes

By performing binary mask and matrix operations on the image, calculating the mean and covariance matrix, and performing singular value decomposition, the problem of difficulty in uniform color processing of any shape region in the prior art is solved, and effective uniform color processing of any shape region in the image is realized.

CN115456904BActive Publication Date: 2025-06-27CHINA UNIV OF GEOSCIENCES (WUHAN)
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211173390.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-09-26
Publication Date
2025-06-27
Estimated Expiration
2042-09-26

AI Technical Summary

Technical Problem

The prior art is difficult to effectively uniformly process any shape area in the image, and the accurate area in the image cannot be retained.

Method used

By obtaining the binary map of the original image, it is masked, converted into matrix rgbs, filtering the to-uniform color area, calculating the mean and covariance matrix of the matrix, and performing singular value decomposition, calculating the transformation matrix I, and assigning the to-uniform color area to-uniform color processing.

Benefits of technology

The uniform color processing of any shape area in the image is realized, and the area features in the image can be effectively retained.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115456904B_ABST
    Figure CN115456904B_ABST
Patent Text Reader

Abstract

The present invention relates to a method for color homogenization of images with arbitrary shapes. First, the Otsu method is used to obtain a binary image of the original image, and the original image is masked using the binary image, and both the reference image and the masked original image are converted into matrices; the pixel values of the area to be color homogenized in the masked original image are stored in the matrix; the pixel means of the RGB three components of the area to be color homogenized in the masked original image and the reference image are calculated respectively; the covariance matrices between the RGB three components of the area to be color homogenized in the original image and the reference image are calculated respectively and singular value decomposition is performed; the translation matrix, rotation matrix and scaling matrix are calculated respectively, and a transformation operation is performed on the matrix of the area to be color homogenized; the pixel values of the area to be color homogenized in the masked original image are re-assigned using the element values in the transformed result matrix to obtain the final result image. The beneficial effect of the present invention is that color homogenization processing of an area with an arbitrary shape in the image can be realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of image color homogenization, and particularly to an image color homogenization method supporting any shape. Background Art

[0002] When obtaining satellite images, due to the influence of the atmospheric environment and the like, there may be local color inconsistencies in the images. Most of the existing color homogenization methods perform color homogenization on the whole image, cannot retain the accurate regions in the image, and it is difficult to achieve the purpose of processing regions of any shape. Summary of the Invention

[0003] In view of this, aiming at the technical problem that the existing methods cannot perform color homogenization on regions of any shape, the present invention provides an image color homogenization method supporting any shape, which specifically includes the following steps:

[0004] S1: Obtain the binary image of the original image, mask the original image using the binary image to obtain the masked original image, and convert the masked original image into a matrix rgbs; select a reference image and convert the reference image into a matrix rgbt;

[0005] S2: Traverse the matrix rgbs, screen the regions to be color homogenized, and store the pixel values of the regions to be color homogenized into a matrix rgbs1;

[0006] S3: Calculate the mean values of the RGB three directions of the matrix rgbs1 and the matrix rgbt, and denote them as the mean matrix means and the mean matrix meant respectively;

[0007] S4: Calculate the covariance matrices of the RGB three directions of the matrix rgbs1 and the matrix rgbt to obtain the covariance result matrices covs and matrix covt, and perform singular value decomposition on the matrix covs and the matrix covt to obtain the singular value decomposition results, including: the third-order unitary matrix Us corresponding to the matrix covs, the third-order unitary matrix diagonal matrix As and the third-order unitary matrix Ut, third-order unitary matrix Vt and diagonal matrix At corresponding to the matrix covt;

[0008] S5: Calculate the transformation matrix I using the mean matrix means, the mean matrix meant and the singular value decomposition results;

[0009] S6: Assign the element values in the transformation matrix I to the regions to be color homogenized in the masked original image to obtain the final color homogenized result image.

[0010] The beneficial effect provided by the present invention is that color homogenization processing of regions of any shape in the image can be realized. Brief Description of the Drawings

[0011] Figure 1It is a schematic flow chart of the method of the present invention;

[0012] Figure 2 It is the related image description in this application;

[0013] Figure 3 It is a schematic diagram of the effect of the method of the present invention. Specific embodiments

[0014] To make the objectives, technical solutions and advantages of the present invention clearer, the embodiments of the present invention will be further described below in conjunction with the accompanying drawings.

[0015] The RGB values of the pixels in the image can be regarded as a three-dimensional random variable. The pixel points in any area of the image are represented as a data point cluster of a certain shape in the RGB color space. The present invention is to match the three-dimensional RGB distribution of the pixels in the area to be color-uniformed in the original image with the three-dimensional RGB distribution of the pixel points in the reference image through matrix operations, and can realize color-uniforming processing of any-shaped areas in the image.

[0016] Please refer to Figure 1 , Figure 1 It is a flow chart of the method of the present invention;

[0017] A method for image color-uniforming supporting any shape provided by the present invention specifically includes the following steps:

[0018] S1: Obtain a binary image of the original image, use the binary image to mask the original image to obtain the masked original image, and convert the masked original image into a matrix rgbs; select a reference image and convert the reference image into a matrix rgbt;

[0019] It should be noted that first, the Otsu method is used to obtain the binary image of the original image, and the original image is masked with the binary image; the black pixels in the binary image represent the background area, and the area with a pixel value of 255 represents the foreground area, that is, the area to be color-uniformed;

[0020] Convert the masked original image into a matrix rgbs, and the selected reference image into a matrix rgbt; in the present invention, the reshape function of the MATLAB platform is called to convert the masked original image into a matrix rgbs, and the selected reference image into a matrix rgbt; for the convenience of calculation, the im2doubles function of the MATLAB platform is called to standardize the values of the elements in the matrix rgbs and the matrix rgbt to [0,1];

[0021] Please refer to Figure 2 , Figure 2 It is the related image description in this application. Figure 2Among them, a is the original image, b is the binary image obtained by Otsu's method for a, c is the image obtained by masking a with b, and d is the reference image.

[0022] Rules for converting the image into a matrix:

[0023] Create a matrix rgbs with 3 rows and M columns, where M is the total number of pixels in the original image, and the initial element value in the matrix is 0. The number of rows in the matrix is 3, representing the RGB three components of the original image after masking. The number of columns M is the total number of pixels in the original image after masking, including the foreground area and the background area;

[0024] The values of the elements in the first row of the matrix rgbs are the pixel values of all the R components of the original image after masking. Denote the number of rows and columns of the R component of the original image after masking as a and b respectively. First, assign the values of the a pixels in the first column of the R component to the elements in the first row of the matrix rgbs from top to bottom. Then, continue to assign the pixel values of the second column of the R component to the elements in the first row of the matrix rgbs from top to bottom until the pixel values of the b columns are all assigned to the first row of the matrix rgbs, that is, the assignment of the first row of the matrix rgbs is completed;

[0025] Then, assign the pixel values of the G component and B component of the original image after masking to the second row and the third row of the matrix rgbs respectively according to the above rules, that is, the matrix rgbs is obtained.

[0026] The conversion rule of the matrix rgbt is the same as that of the matrix rgbs.

[0027] S2: Traverse the matrix rgbs, screen the areas to be color - equalized, and store the pixel values of the areas to be color - equalized in the matrix rgbs1;

[0028] It should be noted that count the number of foreground area pixels of any shape in the binary image, denoted as n. Call the zeros function of the MATLAB platform to create a matrix rgbs1 with 3 rows and n columns, and the initial value of the elements in the matrix is 0. The number of rows and columns of the binary image is a rows and b columns. Denote the 3 rows of elements in the matrix rgbs1 as row vectors , , and assign the pixel values of the foreground area in the R component to the elements in the row vector , where ;

[0029] Traverse the binary image column by column. First, start from the first column with a pixels and traverse from top to bottom, and count the number of times the pixels with a value of 255 appear;

[0030] For example, when traversing the pixel at the p-th row and q-th column in the binary image, the number of pixels with a value of 255 that have appeared before is N; when the pixel value at the p-th row and q-th column in the binary image is 255, the number of pixels with a value of 255 at this time is N + 1, and the pixel value of the R component of the original image after masking at the p-th row and q-th column is assigned to the row vector of the matrix in the element ;

[0031] When the pixel value in the binary image is 0, it indicates the background area, and the pixel values in the background area are not stored in the matrix, that is, the row vector of the matrix does not perform the assignment operation;

[0032] When the traversal of the binary image is completed column by column, the assignment of the row vector ends, and then the row vector is assigned in the same way After the assignment, the matrix rgbs1 is obtained.

[0033] S3: Calculate the mean values of the RGB three-direction components of the matrix rgbs1 and the matrix rgbt, which are denoted as the mean matrix means and the mean matrix meant respectively;

[0034] Call the mean function of the MATLAB platform to calculate the pixel means of the RGB three components of the area to be color-uniformed in the original image after masking and the reference image. In the matrix, it is to calculate the mean value of each row of the matrix rgbs1 and the matrix rgbt respectively, and store the means into the result matrices means and meant with three rows and one column respectively, where , , represent the mean values of each row element in the matrix rgbs1 respectively, represent the mean values of each row element in the matrix rgbt respectively.

[0035] S4: Calculate the covariance matrices of the RGB three-direction components of the matrix rgbs1 and the matrix rgbt to obtain the covariance result matrices covs and matrix covt, and perform singular value decomposition on the matrix covs and the matrix covt to obtain the singular value decomposition results, including: the third-order unitary matrix Us corresponding to the matrix covs, the third-order unitary matrix diagonal matrix As and the third-order unitary matrix Ut corresponding to the matrix covt, the third-order unitary matrix Vt and the diagonal matrix At;

[0036] It should be noted that in step S4, the covariance matrices between the RGB three components of the area to be color-uniformed in the original image and the reference image are calculated respectively and singular value decomposition is performed, which is carried out by calling the cov function of the MATLAB platform;

[0037] That is, the covariance matrices of the three row vectors of matrix rgbs1 and matrix rgbt are calculated respectively, and the results of the covariance matrices are denoted as matrix covs and matrix covt;

[0038] Perform singular value decomposition on the covariance matrix covs to obtain a third-order unitary matrix Us, a third-order unitary matrix diagonal matrix As, , where represents the singular value of matrix covs;

[0039] Perform singular value decomposition on the covariance matrix covt to obtain a third-order unitary matrix Ut, a third-order unitary matrix Vt and a diagonal matrix At, , where represents the singular value of matrix covt;

[0040] S5: Calculate the transformation matrix I using the mean matrix means, the mean matrix meant, and the singular value decomposition results;

[0041] It should be noted that the translation matrix, rotation matrix, and scaling matrix are calculated and the conversion operation of formula (1) is performed;

[0042] (1)

[0043] where I is the result matrix after conversion, , represents the three row vectors of matrix rgbs1; respectively represent the translation, rotation, and scaling matrices of the reference image, T respectively represent the translation, rotation, and scaling matrices of the area to be color - uniformed in the original image after masking;

[0044] The calculation methods of the translation matrices Ts and Tt are as follows in formula (2), where are the three elements of the mean matrix means, are the three elements of the mean matrix meant;

[0045] (2)

[0046] The calculation methods of the rotation matrices Rs and Rt are as follows (3), where Us is the third - order unitary matrix obtained by singular value decomposition of the covariance matrix covs, and Ut is the third - order unitary matrix obtained by singular value decomposition of the covariance matrix covt;

[0047] (3)

[0048] The calculation methods of the scaling matrices Ss and St are as follows in formula (4), where represents the singular value of the covariance matrix covs, Represent the singular values of the covariance matrix covt;

[0049] (4)

[0050] S6. Assign the element values in the transformation matrix I to the area to be color - uniformized in the masked original image to obtain the final color - uniformized result image.

[0051] It should be noted that the element values in the converted result matrix I are used to re - assign values to the pixels in the area to be color - uniformized in the masked original image to obtain the final result image;

[0052] The element values of the first three rows of the converted result matrix I are the pixel values after color - uniformization of the area to be color - uniformized in the masked original image, excluding the background area.

[0053] Denote the first three row vectors of matrix I as 、 and . Among them ; that is, use the element values of the row vector in matrix I to re - assign values to the R component of the area to be color - uniformized in the masked original image, and use the element values of the row vectors and to re - assign values to the G component and B component of the area to be color - uniformized in the masked original image respectively; the final result image should correspond to three matrices of a rows and b columns, representing the values of the RGB three components respectively. Create three matrices of a rows and b columns, which are 、 and , and the initial values of the elements in the matrix are 0. These three matrices correspond to the RGB three components of the final result image;

[0054] Assign values to the matrix : Traverse the binary image column - by - column. First, start from the first column with a total of a pixels and traverse from top to bottom, and count the number of pixels with a value of 255 that appear; for example, when traversing to the pixel at the p - th row and q - th column in the binary image, the number of pixels with a value of 255 that have appeared before is N; when the pixel value at the p - th row and q - th column in the binary image is 255, the number of pixels with a value of 255 that appear at this time is N + 1, that is, assign the value of the element in the row vector of the converted result matrix I to the element at the p - th row and q - th column of the matrix ; when the pixel value in the binary image is 0, it means it is the background area, and the element value at the p - th row and q - th column in the matrix remains 0 unchanged, and continue to traverse downwards; the matrices and are also obtained by assignment according to the row vectors and in matrix I respectively, according to the RGB three - component matrices , and the final result image is obtained.

[0055] Finally, please refer to Figure 3 , Figure 3 which is a schematic diagram of the effect of the method of the present invention; wherein Figure 3 a in represents a schematic diagram of the result after color homogenization of the original image after masking; Figure 3 b in represents a schematic diagram of the effect of the original image after automatic color homogenization. The present invention can be used to perform color homogenization processing on any area in the image according to the reference image.

[0056] Generally speaking, the beneficial effect of the present invention is that it can achieve color homogenization processing of any shaped area in the image.

[0057] The above are only the preferred embodiments of the present invention and are not intended to limit the present invention. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principle of the present invention shall be included within the protection scope of the present invention.

Claims

1. An image color uniformity method supporting arbitrary shapes, characterized in that: Including the following steps: S1: Obtain the binary image of the original image, use the binary image to mask the original image to obtain the masked original image, and convert the masked original image into a matrix rgbs; Select a reference image and convert the reference image into a matrix rgbt; In step S1, the matrix rgbs is a matrix with 3 rows and M columns; where the number of columns M is the total number of pixels of the original image, and the 3 rows of the matrix rgbs represent the RGB three components of the masked original image in sequence; The matrix rgbt is also a matrix with 3 rows and M columns; where the number of columns M is the total number of pixels of the reference image, and the 3 rows of the matrix rgbt represent the RGB three components of the reference image in sequence; S2: Traverse the matrix rgbs, screen the area to be color - balanced, and store the pixel values of the area to be color - balanced into the matrix rgbs1; In step S2, the process of obtaining the matrix rgbs1 is as follows: S21: Construct a matrix rgbs1 with 3 rows and n columns, and initialize the elements of the matrix rgbs1 to 0; S22. Obtain that the number of rows and columns of the binary image of the original image is a rows and b columns, and denote the 3 rows of elements in the matrix rgbs1 as row vectors , ; The pixel values of the elements in the binary image are 0 or 255; Denote = ; S23. Traverse the binary image column by column. Starting from the first column with a total of a pixels, traverse from top to bottom, and cumulatively count the number of occurrences of the pixel value 255. If the pixel at the p-th row and q-th column in the binary image is 255 when traversing, and the number of previously appeared pixel values of 255 is N, then assign the pixel value of the R component of the original image after masking at the p-th row and q-th column to the element of the row vector of the matrix rgbs1 in ; If the pixel at the p-th row and q-th column in the binary image is 0 when traversing, then no assignment operation is performed on the row vector of the matrix rgbs1, and the original initial value is maintained; When the traversal of the binary image column by column is completed, the row vector assignment ends, and then use the same method to assign values to the row vector After assignment, the matrix rgbs1 is obtained; S3: Calculate the mean values of the RGB three - direction components of the matrix rgbs1 and the matrix rgbt, and denote them as the mean matrix means and the mean matrix meant respectively; S4: Calculate the covariance matrices for the RGB components in three directions of the matrix rgbs1 and the matrix rgbt to obtain the covariance result matrices covs and covt, and perform singular value decomposition on the matrix covs and the matrix covt to obtain the singular value decomposition results, including: the third-order unitary matrix Us corresponding to the matrix covs, the third-order unitary matrix diagonal matrix As, and the third-order unitary matrix Ut, third-order unitary matrix Vt, and diagonal matrix At corresponding to the matrix covt; S5: Calculate the transformation matrix I using the mean matrix means, the mean matrix meant, and the singular - value decomposition result; S6: Assign the element values in the transformation matrix I to the area to be color - balanced in the masked original image to obtain the final color - balanced result image.

2. The method for color uniformity of an image supporting any shape according to claim 1, wherein: The calculation formula (1) of the transformation matrix I in step S5 is as follows: (1) Among them, , represent the three row vectors of the matrix rgbs1; represent the translation, rotation and scaling matrices of the reference image respectively, T represent the translation, rotation and scaling matrices of the area to be color - homogenized of the original image after masking respectively.

3. A method for uniformizing the color of an image with an arbitrary shape as described in claim 2, characterized in that: The calculation methods of the translation matrices Ts and Tt are as shown in the following formula (2): (2) wherein are three elements of the mean matrix means, are three elements of the mean matrix meant.

4. A method for uniformizing the color of an image with an arbitrary shape according to claim 2, characterized in that: The calculation methods of the rotation matrices Rs and Rt are as follows (3): (3) Where Us is a third - order unitary matrix obtained by singular - value decomposition of the covariance matrix covs, and Ut is a third - order unitary matrix obtained by singular - value decomposition of the covariance matrix covt.

5. An image color - balancing method supporting arbitrary shapes according to claim 2, characterized in that: The calculation methods of the scaling matrices Ss and St are as shown in the following formula (4): (4) where represents the singular value of the covariance matrix covs, represents the singular value of the covariance matrix covt.

Citation Information

Patent Citations

  • Multiple-colour tone image unity regulating method based on color transfer

    CN101441763A

  • A method for encoding and simultaneously decoding images having multiple color components

    CN103782306A