Image processing method and device, storage medium, and terminal
By performing singular value decomposition and wavelet transformation processing on the image, the elements in the singular value matrix are updated, and the problems of insufficient embedding efficiency and robustness of digital watermarks in the prior art are solved, and better watermark effect and robustness are achieved.
Patent Information
- Application Number
- CN202110780217.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-07-09
- Publication Date
- 2025-04-22
- Estimated Expiration
- 2041-07-09
AI Technical Summary
The prior art is difficult to effectively embed digital watermarks in images, resulting in poor watermark effects and low robustness.
By acquiring the original image's multiple original pixel matrix and the watermark pixel sequence of the watermark image, singular value decomposition and wavelet transformation processing are performed, and the elements in the singular value matrix are updated to generate the target image.
Improves the embedding efficiency and robustness of digital watermarks in images, and can effectively detect and extract watermark images even if the target image is compressed or cut.
Smart Images

Figure CN113674130B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image processing, and in particular to an image processing method and device, a storage medium, and a terminal. Background Art
[0002] Most digital media are stored in the form of images. At present, more and more digital media need to be protected by copyright. Usually, digital watermarks are embedded into the images to be protected, and then the digital watermarks are extracted to verify the ownership of the copyright and avoid the threat of illegal piracy. Therefore, there is an urgent need for an image processing method that can effectively embed digital watermarks in images and improve the effect of digital watermarks. Summary of the invention
[0003] The technical problem solved by the invention is to provide an image processing method for effectively embedding a digital watermark in an image.
[0004] To solve the above technical problems, an embodiment of the present invention provides an image processing method, the method comprising: obtaining multiple original pixel matrices of an original image and a watermark pixel sequence of a watermark image, wherein the original pixel matrices correspond to the color channels of the original image one by one, the elements in each original pixel matrix are the grayscale values of the pixels of the original image in the corresponding color channel, and the elements in the watermark pixel sequence are determined according to the grayscale values of the pixels of the watermark image in the preset color channel; segmenting the original pixel matrix corresponding to each color channel to obtain multiple original sub-matrices corresponding to the color channel; for the multiple original sub-matrices corresponding to each color channel, performing singular value decomposition on each original sub-matrix respectively. Processing to obtain a singular value matrix corresponding to the color channel, wherein the singular value matrix is a matrix with m rows and n columns, m is the number of original sub-matrices corresponding to the color channel, n is the number of singular values of the original sub-matrix, the value of the element in the i-th row of the singular value matrix is the singular value of the i-th original sub-matrix, m, n, i are positive integers, i≤m; according to the k-th element in the watermark pixel sequence, updating at least a part of the elements of the k+c×l-th row in the singular value matrix corresponding to each color channel to obtain multiple watermark image pixel matrices, the watermark image pixel matrices correspond to the color channels one by one, wherein c is the number of elements in the watermark pixel sequence, k and c are positive integers, k≤c≤m / 2, l is 0 to An integer between ; generating a target image according to the multiple watermark image pixel matrices.
[0005] Optionally, the elements in the watermark pixel sequence correspond one-to-one to the pixels of the watermark image. For each pixel of the watermark image, if the grayscale value of the pixel in the preset color channel is greater than or equal to a first preset threshold, the value of the element corresponding to the pixel in the watermark pixel sequence is 1; otherwise, the value of the element corresponding to the pixel in the watermark pixel sequence is 0.
[0006] Optionally, the original submatrix is a matrix with 2 rows and 2 columns.
[0007] Optionally, before segmenting the original pixel matrix corresponding to each color channel, the method further includes: performing a wavelet transform on each original pixel matrix to obtain a plurality of transformed pixel matrices, and using the plurality of transformed pixel matrices as the plurality of original pixel matrices.
[0008] Optionally, before performing singular value decomposition processing on each original sub-matrix respectively, the method further includes: performing discrete cosine transform processing on each original sub-matrix respectively to obtain multiple transformed sub-matrices, and using the multiple transformed sub-matrices as the multiple original sub-matrices.
[0009] Optionally, the elements in each row of the singular value matrix are arranged in descending order of numerical value, and updating at least a part of the elements in the k+c×lth row of the singular value matrix corresponding to each color channel according to the kth element in the watermark pixel sequence includes: for the singular value matrix corresponding to each color channel, updating the elements in the first N columns in the k+c×lth row of the singular value matrix according to the kth element in the watermark pixel sequence, where N is a preset positive integer and N≤n.
[0010] Optionally, updating the elements of the first N columns in the k+c×lth row in the singular value matrix according to the kth element in the watermark pixel sequence includes: updating using the following formula:
[0011]
[0012] Wherein, A(k+c×l,j) is the value of the element in the k+c×lth row and jth column in the singular value matrix before updating, A'(k+c×l,j) is the value of the element in the k+c×lth row and jth column in the singular value matrix after updating, j is a positive integer and j≤N, B and D are preset positive integers, C k is the value of the kth element in the watermark pixel sequence.
[0013] Optionally, generating a target image based on the multiple watermark image pixel matrices includes: generating multiple first watermark image sub-matrices corresponding to each color channel based on the watermark image pixel matrix corresponding to the color channel, wherein the i-th first watermark image sub-matrix is generated based on the elements of the i-th row of the watermark image pixel matrix; performing inverse transformation of singular value decomposition on the multiple first watermark image sub-matrices corresponding to each color channel to obtain multiple second watermark image sub-matrices corresponding to the color channel; splicing the multiple second watermark image sub-matrices corresponding to each color channel to obtain a target pixel matrix corresponding to the color channel; and generating the target image based on the target pixel matrices corresponding to each color channel.
[0014] Optionally, the method further comprises: extracting a watermark decoded image according to the target image, and performing similarity detection between the watermark decoded image and the watermark image.
[0015] Optionally, extracting a watermark decoded image based on the target image includes: generating multiple target pixel matrices, wherein the target pixel matrices correspond one-to-one to the color channels of the target image, and the elements in each target pixel matrix are the grayscale values of the pixels of the target image in the corresponding color channel; segmenting the target pixel matrix corresponding to each color channel to obtain multiple target sub-matrices corresponding to the color channel; performing singular value decomposition on each target sub-matrix to obtain a target singular value matrix corresponding to the color channel, wherein the elements in the qth row of the target singular value matrix are the singular values of the qth target sub-matrix, q is a positive integer, c≤q, and q is less than or equal to the number of rows of the target singular value matrix; determining the value of the kth element in the watermark decoding sequence based on the values of at least a part of the elements in the kth row of the target singular value matrix to obtain the watermark decoding sequence; and generating the watermark decoded image based on the watermark decoding sequence.
[0016] The embodiment of the present invention further provides an image processing device, which includes: an acquisition module, which is used to acquire an original pixel matrix of an original image and a watermark pixel sequence of a watermark image, wherein the original pixel matrix corresponds to a color channel of the original image one by one, and the elements in each original pixel matrix are the grayscale values of the pixel points of the original image in the corresponding color channel, and the elements in the watermark pixel sequence are determined according to the grayscale values of the pixel points of the watermark image in a preset color channel; a segmentation module, which is used to segment the original pixel matrix corresponding to each color channel to obtain multiple original sub-matrices corresponding to the color channel; and a singular value decomposition module, which is used to perform segmentation processing on each of the multiple original sub-matrices corresponding to each color channel. Singular value decomposition processing is performed to obtain a singular value matrix corresponding to the color channel, wherein the singular value matrix is a matrix with m rows and n columns, m is the number of original sub-matrices corresponding to the color channel, n is the number of singular values of the original sub-matrix, the elements of the i-th row in the singular value matrix are the singular values of the i-th original sub-matrix, m, n, i are positive integers, and i≤m; an updating module is used to update at least a part of the elements of the k+c×l-th row in the singular value matrix corresponding to each color channel according to the k-th element in the watermark pixel sequence to obtain multiple watermark image pixel matrices, the watermark image pixel matrices correspond to the color channels one by one, wherein c is the number of elements in the watermark pixel sequence, k and c are positive integers, k≤c<m, and l is 0 to An integer between ; a target image generating module, configured to generate a target image according to the plurality of watermark image pixel matrices.
[0017] An embodiment of the present invention further provides a storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps of the above-mentioned image processing method are executed.
[0018] An embodiment of the present invention further provides a terminal, including a memory and a processor, wherein the memory stores a computer program executable on the processor, and the processor executes the steps of the above-mentioned image processing method when running the computer program.
[0019] Compared with the prior art, the technical solution of the embodiment of the present invention has the following beneficial effects:
[0020] In the scheme of the embodiment of the present invention, at least a part of the elements of the k+c×lth row in the singular value matrix corresponding to each color channel is updated according to the kth element in the watermark pixel sequence to obtain the watermark image pixel matrix corresponding to each color channel, and then the target image is generated according to the watermark image pixel matrix. When such a scheme is adopted, since the value of the element in the i-th row in the singular value matrix is the singular value of the i-th original sub-matrix, when updating according to the kth element in the watermark pixel sequence, the singular value of the k+c×lth original sub-matrix is updated. Since l is an integer between 0 and m / c, and c≤m / 2, the value of the kth element of the watermark pixel sequence is added to the singular values of multiple original sub-matrices. Since the original sub-matrix is obtained by dividing the original pixel matrix of the original image, different original sub-matrices correspond to different positions of the original image. Therefore, when updating according to the kth element in the watermark pixel sequence, the value of the kth element of the watermark pixel sequence can be added to the pixel information of multiple positions of the original image. Since k is a positive integer between 1 and c, all elements in the watermark pixel sequence are added to multiple positions of the original image. Furthermore, since the elements in the watermark pixel sequence are determined according to the grayscale values of the pixels of the watermark image in the preset color channel, the watermark pixel sequence includes the pixel information of the watermark image. Therefore, by adopting the solution of the embodiment of the present invention, the pixel information of the watermark image can be added to different positions of the original image, and the target image obtained can contain rich information of the watermark image, so the effect of adding watermark is better. Even if the target image is compressed, cropped, etc., the watermark image can still be well detected and extracted, and the robustness is better.
[0021] Further, in the scheme of the embodiment of the present invention, the elements in the watermark pixel sequence correspond to the pixels of the watermark image one by one. For each pixel of the watermark image, if the grayscale value of the pixel in the preset channel is greater than or equal to the first preset threshold, the value of the element corresponding to the pixel in the watermark pixel sequence is 1, otherwise the value of the element corresponding to the pixel in the watermark pixel sequence is 0, that is, the value of the element in the watermark pixel sequence is 0 or 1. Therefore, when the singular value matrix is updated according to the watermark pixel sequence, the information of the watermark image can be added, and the difference with the data before the update can be reduced, so that the final target image can have less color distortion than the original image, thereby balancing the requirements of transparency and robustness.
[0022] Furthermore, in the scheme of the embodiment of the present invention, before performing singular value decomposition processing on each original sub-matrix, discrete cosine transform processing is performed on each original sub-matrix respectively. Since the elements in the transformed sub-matrix can intuitively reflect the low-frequency information in the original image, discrete cosine transform processing is first performed, and then singular value decomposition is performed on the transformed sub-matrix to obtain a singular value matrix, which is conducive to quickly and accurately determining the position of the elements to be updated in the singular value matrix. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] Figure 1 is a flowchart of a first image processing method in an embodiment of the present invention;
[0024] Figure 2 is a schematic flow chart of a second image processing method in an embodiment of the present invention;
[0025] Figure 3 is a schematic flow chart of a third image processing method in an embodiment of the present invention;
[0026] Figure 4 It is a structural schematic diagram of an image processing device in an embodiment of the present invention. DETAILED DESCRIPTION
[0027] As described in the background art, there is an urgent need for an image processing method that can effectively embed a digital watermark in an image and improve the effect of the digital watermark.
[0028] The inventor of the present invention has found through research that transparency is an important indicator for measuring the effect of digital watermarking. In the prior art, in order to make the added watermark image as imperceptible as possible, that is, to avoid the watermark image from affecting the display effect of the original image, the information of the watermark image added to the original image is very limited. Specifically, the original image is usually segmented according to the number of pixels of the watermark image, that is, the number of image blocks after segmentation is the same as the number of pixels of the watermark image, and then the pixel information of each pixel of the watermark image is added to the corresponding image block. Therefore, when this solution is adopted, the information of the added watermark image is very limited. When the image after adding the watermark is compressed or cropped, the watermark image cannot be detected well, that is, the robustness is poor.
[0029] In order to solve the above technical problems, an embodiment of the present invention provides an image processing method. In the scheme of the embodiment of the present invention, according to the kth element in the watermark pixel sequence, at least a part of the elements of the k+c×lth row in the singular value matrix corresponding to each color channel is updated to obtain the watermark image pixel matrix corresponding to each color channel, and then the target image is generated according to the watermark image pixel matrix. When such a scheme is adopted, since the value of the element in the i-th row in the singular value matrix is the singular value of the i-th original sub-matrix, when updating according to the kth element in the watermark pixel sequence, the singular value of the k+c×lth original sub-matrix is updated. Since l is an integer between 0 and m / c, and c≤m / 2, the value of the kth element of the watermark pixel sequence is added to the singular values of multiple original sub-matrices. Since the original sub-matrix is obtained by dividing the original pixel matrix of the original image, different original sub-matrices correspond to different positions of the original image. Therefore, when updating according to the kth element in the watermark pixel sequence, the value of the kth element of the watermark pixel sequence can be added to multiple positions of the original image. Since k is a positive integer between 1 and c, all elements in the watermark pixel sequence are added to multiple positions of the original image. Furthermore, since the elements in the watermark pixel sequence are determined according to the grayscale values of the pixels of the watermark image in the preset color channel, the watermark pixel sequence includes the pixel information of the watermark image. Therefore, by adopting the solution of the embodiment of the present invention, the pixel information of the watermark image can be added to different positions of the original image, and the target image obtained can contain rich information of the watermark image, so the effect of adding watermark is better. Even if the target image is compressed, cropped, etc., the watermark image can still be detected and extracted, and the robustness is better.
[0030] In order to make the above-mentioned objects, features and beneficial effects of the present invention more obvious and easy to understand, specific embodiments of the present invention are described in detail below with reference to the accompanying drawings.
[0031] Reference Figure 1 , Figure 1 : is a flowchart of an image processing method in an embodiment of the present invention. The image processing method can be executed by a terminal, and the terminal can be various appropriate terminals, such as a mobile phone, a computer, an Internet of Things device, etc., but is not limited thereto. Through the solution provided by the embodiment of the present invention, the pixel information of the watermark image can be added to the original image to obtain the target image. Compared with the original image, the target image adds the information of the watermark image on the basis of the original image. The user can subsequently detect or extract the watermark image from the target image to prove the copyright ownership of the original image, etc. Figure 1 The image processing method shown may include the following steps:
[0032] Step S101: obtaining a plurality of original pixel matrices of an original image and a watermark pixel sequence of a watermark image;
[0033] Step S102: segmenting the original pixel matrix corresponding to each color channel to obtain a plurality of original sub-matrices corresponding to the color channel;
[0034] Step S103: for the multiple original sub-matrices corresponding to each color channel, singular value decomposition is performed on each original sub-matrix to obtain a singular value matrix corresponding to the color channel;
[0035] Step S104: updating at least a portion of the elements of the k+c×lth row in the singular value matrix corresponding to each color channel according to the kth element in the watermark pixel sequence, so as to obtain a plurality of watermark image pixel matrices, wherein the watermark image pixel matrices correspond to the color channels one by one;
[0036] Step S105: Generate a target image according to the plurality of watermark image pixel matrices.
[0037] It is understandable that, in a specific implementation, the method can be implemented in the form of a software program, which runs in a processor integrated inside a chip or a chip module; or, the method can be implemented in the form of hardware or a combination of hardware and software.
[0038] In the specific implementation of step S101, an original image may be obtained, and the original image may be collected in real time, obtained from the outside, or pre-stored in a local data set, but is not limited thereto. The original image may be an image in various color spaces, such as RGB color space, YUV color space, CMYK color space, HSV color space, etc., but is not limited thereto, and the embodiment of the present invention does not impose any limitation on this.
[0039] Further, the original image can be converted into multiple original pixel matrices, and the original pixel matrix is the pixel matrix (Pixel Array) of the original image. Among them, the original pixel matrix corresponds to the color channel of the original image one by one, and the elements in each original pixel matrix are the grayscale values of the pixels of the original image in the corresponding color channel. Specifically, the original pixel matrix of the original image in multiple color channels is generated. In a non-limiting embodiment, the original image can be converted into three original pixel matrices, and the three original pixel matrices correspond to the three color channels of R, G, and B. The elements in the original pixel matrix correspond to the pixels in the original image one by one, and the value of the element in each original pixel matrix is the grayscale value of the corresponding pixel in the corresponding color channel. The value of the element in the original pixel matrix can be an integer between 0 and 255. For example, if the resolution of the original image is 1920×1080, three matrices of 1920 rows and 1080 columns (that is, 1920×1080) can be generated.
[0040] Furthermore, a watermark image may be obtained, and the watermark image may be obtained from the outside or may be pre-stored in a local data set, but is not limited thereto. The watermark image may be a color image or a grayscale image. It should be noted that in the embodiment of the present invention, the number of pixels of the watermark image is much smaller than the number of pixels in the original image, and more specifically, the number of pixels of the watermark image is smaller than the number of pixels in the row direction of the original image.
[0041] Furthermore, the watermark image can be converted into a watermark pixel sequence, wherein the number of elements in the watermark pixel sequence can be the same as the number of pixels in the watermark image, and the elements in the watermark pixel sequence correspond to the pixels of the watermark image one-to-one. More specifically, the pixel in the rth row and tth column of the watermark image corresponds to the r×P+tth element in the watermark pixel sequence, wherein P is the number of pixels in the watermark image in the row direction, r, t, and P are positive integers, and r≤P.
[0042] Furthermore, the value of the element in the watermark pixel sequence is determined according to the grayscale value of the corresponding pixel in the watermark image in a preset color channel. The preset color channel is any color channel among the multiple color channels corresponding to the multiple original pixel matrices, for example, the B channel can be used as the above preset color channel.
[0043] Specifically, for each pixel of the watermark image, if the grayscale value of the pixel in the preset color channel is greater than or equal to the first preset threshold, the value of the element corresponding to the pixel in the watermark pixel sequence is 1, otherwise the value of the element corresponding to the pixel in the watermark pixel sequence is 0. The first preset threshold may be pre-set, for example, the first preset threshold may be 128, but is not limited thereto. Therefore, in the solution of the embodiment of the present invention, the pixel information of the watermark image is characterized by a binary sequence.
[0044] It should be noted that the embodiment of the present invention does not limit the order of obtaining the original pixel matrix and obtaining the watermark pixel sequence.
[0045] In the specific implementation of step S102, the original pixel matrix of each color channel can be segmented to obtain multiple original sub-matrices corresponding to the color channel. It should be noted that the number of original sub-matrices corresponding to each color channel is the same. It should also be noted that the segmentation process is performed on the original pixel matrix, that is, the original pixel matrix is processed in blocks. By segmenting the original pixel matrix, it is equivalent to segmenting the original image into multiple non-overlapping image blocks, that is, each image block is represented by an original sub-matrix.
[0046] Specifically, the number of rows and columns of the original submatrix can be preset, and the original pixel matrix can be divided according to the preset number of rows and columns of the original submatrix. In a specific example, the original submatrix is a matrix of 2 rows and 2 columns, or a matrix of 3 rows and 3 columns, or a matrix of 4 rows and 4 columns, but is not limited to this. In a non-limiting embodiment, the original submatrix is a 2×2 matrix, that is, the original submatrix is a matrix of 2 rows and 2 columns. For the original pixel matrix of 1920×1080, 129,600 2×2 matrices can be obtained by segmentation.
[0047] In a specific embodiment, before the original pixel matrix is segmented, each original pixel matrix may be subjected to wavelet transform (WT) to obtain a plurality of transformed pixel matrices. For example, the original pixel matrix is a 1920×1080 matrix, and after the wavelet transform, the corresponding transformed pixel matrix is a 960×540 matrix, and then the transformed pixel matrix is segmented.
[0048] It can be understood that performing wavelet transform on the original pixel matrix and then performing subsequent processing on the transformed matrix can not only retain the main information in the original pixel matrix, but also greatly reduce the subsequent calculation amount, which is conducive to improving the efficiency of image processing.
[0049] In the specific implementation of step S103, singular value decomposition (SVD) is performed on each original sub-matrix to obtain a singular value matrix, and the singular value matrix corresponds to the color channel one by one.
[0050] Specifically, the number of original sub-matrices corresponding to each color channel is m, the number of singular values of each original sub-matrix is n, the singular value matrix is a matrix with m rows and n columns, the value of the element in the i-th row of the singular value matrix is the singular value (Singular Value) of the i-th original sub-matrix, m, n, i are positive integers, i≤m.
[0051] More specifically, according to M a×b =V a×a ×S a×b ×D T b×b Perform singular value decomposition on the i-th original sub-matrix, where M a×b is the original submatrix, V a×a is the left singular vector, D T b×b Right singular vectors, S a×b is a singular value vector. More specifically, S a×b is a diagonal matrix, S a×bThe value of the diagonal element is M a×b Furthermore, a singular value matrix can be generated according to the singular values of each original sub-matrix, and the value of the element in the i-th row of the singular value matrix is the singular value of the i-th original sub-matrix.
[0052] It should be noted that singular value decomposition is an orthogonal transformation that can diagonalize a matrix. The pixel features of an image are reflected by the singular values obtained by the decomposition, and the singular values of an image are usually relatively stable. When the image is compressed or cropped, the singular values change little. Therefore, the singular value matrix in an embodiment of the present invention can reflect the pixel features at different positions in the original image.
[0053] In a specific embodiment, for multiple original sub-matrices corresponding to each color channel, each original sub-matrix can be first subjected to discrete cosine transform (DCT) processing to obtain multiple transformed sub-matrices, and then the multiple transformed sub-matrices are subjected to singular value decomposition processing to obtain a singular value matrix corresponding to the color channel.
[0054] It should be noted that the discrete cosine transform can be performed using an existing appropriate method, and the embodiment of the present invention does not limit the specific process of the discrete cosine transform. It can be understood that the discrete cosine transform converts the spatial domain signal of the image to the frequency domain, and has good decorrelation. In other words, the discrete cosine transform can decompose the original submatrix into different frequency domains, and the elements in the transformed submatrix are frequency domain coefficients. The elements in the upper left corner area reflect the low-frequency information in the original submatrix, and the elements in the lower right corner area reflect the high-frequency information in the original submatrix, where the values of the elements in the lower right corner area are usually 0.
[0055] In the specific implementation of step S104, according to the kth element in the watermark pixel sequence, at least a part of the elements in the k+c×lth row in the singular value matrix corresponding to each color channel is updated to obtain multiple watermark image pixel matrices. Wherein c is the number of elements in the watermark pixel sequence, k and c are positive integers, k≤c≤m / 2, and l is 0 to Integers between , that is, l is 0, 1, 2, etc.
[0056] Specifically, for the singular value matrix corresponding to each color channel, according to the kth element in the watermark pixel sequence, at least a part of the elements of the k+c×lth row in the singular value matrix is updated, where l is 0 to integers between . Since the values of the elements in the i-th row of the singular value matrix are the singular values of the i-th original submatrix, the singular values of the k+c×l-th original submatrix can be updated according to the value of the k-th element in the watermark pixel sequence. Since c≤m / 2, l≥2, that is, each element in the watermark pixel sequence can be used to update the singular values of at least 2 original submatrices. Since the singular values of the original submatrices are used to characterize the pixel features at different positions in the original image, the pixel features at multiple positions in the original image can be updated according to the watermark pixel sequence.
[0057] More specifically, the elements of each row in the singular value matrix are arranged in descending order of value, and the elements of the first N columns in the k+c×lth row in the singular value matrix can be updated according to the kth element in the watermark pixel sequence, where N is a preset positive integer and N≤n. For example, N=1, or N=2, but not limited thereto. Further, the following formula can be used for updating:
[0058]
[0059] Where A(k+c×l,j) is the value of the element in the k+c×lth row and jth column in the singular value matrix before updating, A'(k+c×l,j) is the value of the element in the k+c×lth row and jth column in the singular value matrix after updating, j is a positive integer and j≤N, B and D are preset positive integers, for example, B can be 10 or 20 or 30, C k is the value of the kth element in the watermark pixel sequence, C k It takes 0 or 1. In a non-limiting embodiment, B is 20 and D is 4.
[0060] It should be noted that, by adopting the above method of updating singular values, while adding as much pixel information of the watermark image as possible, the difference between the updated singular value matrix and the singular value matrix before the update is small, so that the final target image has less color distortion than the original image.
[0061] In a specific example, the resolution of the watermark image is 192×108, then the number of elements in the watermark pixel sequence is c=20736, and the singular value matrix is a matrix of 129600×2, that is, m=129600. The kth element in the watermark pixel sequence can be used to update the k+20736×lth row in the singular value matrix, where l is 0, 1, 2, 3, 4, 5, and 6 in sequence.
[0062] In the specific implementation of step S105, the inverse processing of step S103 and step S102 may be performed on each watermark image pixel matrix in sequence to generate a target image.
[0063] Specifically, according to the watermark image pixel matrix corresponding to each color channel, a plurality of first watermark image sub-matrices corresponding to the color channel are generated, wherein the i-th first watermark image sub-matrix is generated according to the elements of the i-th row of the watermark image pixel matrix. More specifically, the first watermark image sub-matrix is a diagonal matrix, and the values of the elements on the diagonal line of the i-th first watermark image sub-matrix are the values of the elements of the i-th row of the watermark image pixel matrix in sequence.
[0064] Furthermore, for the multiple first watermark image sub-matrices corresponding to each color channel, an inverse transformation process of singular value decomposition is performed on each first watermark image sub-matrix to obtain a plurality of second watermark image sub-matrices corresponding to the color channel.
[0065] Furthermore, multiple second watermark image sub-matrices corresponding to each color channel are spliced to obtain a target pixel matrix corresponding to the color channel, and each element of the target pixel matrix corresponds to a pixel point of the target image one-to-one, and the value of the element of the target pixel matrix is the gray value of the corresponding pixel point in the corresponding color channel. Thus, the target image can be generated according to the target pixel matrix of each color channel.
[0066] It should be noted that if in the specific implementation of step S103, the original sub-matrix is first subjected to discrete cosine transform and then the transformed sub-matrix is subjected to singular value decomposition, then in the specific implementation of step S105, each second watermark image sub-matrix can be first subjected to inverse discrete cosine transform to obtain an inverse transformed sub-matrix, and then each inverse transformed sub-matrix is spliced to obtain the target pixel matrix corresponding to the color channel.
[0067] It should also be noted that if in the specific implementation of step S102, the original pixel matrix is first subjected to wavelet transformation and then the transformed pixel matrix is segmented, then in the specific implementation of step S105, each target pixel matrix may first be subjected to inverse wavelet transformation to obtain the final target pixel matrix.
[0068] Reference Figure 2 , Figure 2 It is a flowchart of the second image processing method in an embodiment of the present invention. Figure 2 The method shown may include the following steps:
[0069] Step S201: obtaining a plurality of original pixel matrices of the original image and a watermark pixel sequence of the watermark image;
[0070] Step S202: performing wavelet transform on the original pixel matrix corresponding to each color channel to obtain a plurality of transformed pixel matrices, wherein the transformed pixel matrices correspond to the color channels one by one;
[0071] Step S203: segmenting the transformed pixel matrix corresponding to each color channel to obtain a plurality of original sub-matrices corresponding to the color channel;
[0072] Step S204: performing discrete cosine transform on the multiple original sub-matrices corresponding to each color channel to obtain multiple transformed sub-matrices corresponding to the color channel;
[0073] Step S205: for the multiple transformed sub-matrices corresponding to each color channel, singular value decomposition is performed on each transformed sub-matrix to obtain a singular value matrix corresponding to the color channel;
[0074] Step S206: updating at least a portion of the elements of the k+c×lth row in the singular value matrix corresponding to each color channel according to the kth element in the watermark pixel sequence, so as to obtain a plurality of watermark image pixel matrices, wherein the watermark image pixel matrices correspond to the color channels one by one;
[0075] Step S207: Generate a target image according to the plurality of watermark image pixel matrices.
[0076] For the specific contents of steps S201 to S207 , reference may be made to the relevant descriptions of steps S101 to S105 above, which will not be repeated here.
[0077] Reference Figure 3 , Figure 3 This is the third image processing method in the embodiment of the present invention. Figure 3 The image processing method shown can be used to extract a watermark decoded image from a target image. Figure 3 The image processing method shown may include the following steps:
[0078] Step S301: generating a plurality of target pixel matrices, wherein the target pixel matrices correspond one-to-one to the color channels of the target image, and the elements in each target pixel matrix are the grayscale values of the pixel points of the target image in the corresponding color channel;
[0079] Step S302: segmenting the target pixel matrix corresponding to each color channel to obtain a plurality of target sub-matrices corresponding to the color channel;
[0080] Step S303: performing singular value decomposition processing on each target submatrix to obtain a target singular value matrix corresponding to the color channel, wherein the elements in the qth row of the target singular value matrix are singular values of the qth target submatrix, q is a positive integer, c≤q, and q is less than or equal to the number of rows of the target singular value matrix;
[0081] Step S304: determining the value of the kth element in the watermark decoding sequence according to the value of at least a part of the elements in the kth row in the target singular value matrix, so as to obtain the watermark decoding sequence;
[0082] Step S305: Generate the watermark decoded image according to the watermark decoding sequence.
[0083] In the specific implementation of step S301, a target image may be obtained first. The target image may be obtained by Figure 1 or Figure 2 The image processing method shown in the figure can be obtained. Further, multiple target pixel matrices can be generated according to the target image, wherein the target pixel matrices correspond to the color channels of the target image one by one, and the elements in each target pixel matrix are the grayscale values of the pixel points of the target image in the corresponding color channel. For more details about step S301, please refer to Figure 1 The relevant description of step S101 is not repeated here.
[0084] In step S302, the target pixel matrix is segmented to obtain the specific contents of multiple target sub-matrices. Figure 1 The description of segmenting the original pixel matrix in step S102 is not repeated here.
[0085] In step S303, each target sub-matrix is subjected to singular value decomposition to obtain the specific content of the target singular value matrix corresponding to the color channel. Figure 1 In step S103, singular value decomposition is performed on the original sub-matrix to obtain a singular value matrix corresponding to the color channel, which will not be repeated here.
[0086] In a specific implementation of step S304, the value of the kth element in the watermark decoding sequence is determined according to the value of at least a part of the elements in the kth row in the target singular value matrix to obtain the watermark decoding sequence.
[0087] In a specific embodiment, the elements of each row in the target singular value matrix are arranged in descending order of numerical value, and the value of the kth element in the watermark decoding sequence can be determined according to the values of the elements in the first N columns in the kth row in the target singular value matrix. It should be noted that the process of determining the value of the kth element in the watermark decoding sequence according to the values of the elements in the first N columns in the kth row in the target singular value matrix is an inverse operation of updating at least a part of the elements in the k+c×lth row in the singular value matrix corresponding to each color channel according to the kth element in the watermark pixel sequence.
[0088] More specifically, for the value of the element E(k,j) in the jth column of the first N columns in the kth row of the target singular value matrix, calculate The remainder Wherein, B is a positive integer preset in formula (1). Further, and For comparison, if Less than or equal to Then the value of the kth element in the watermark decoding sequence is 0 if Greater than Then the value of the kth element in the watermark decoding sequence is 1. In a non-limiting embodiment, B is 20 and D is 4.
[0089] In the specific implementation of step S305, a watermark decoded image can be generated according to the watermark decoded sequence. Specifically, the elements of the watermark decoded sequence correspond to the number of pixels of the watermark decoded image one by one. If the value of the kth element in the watermark decoded sequence is 1, the grayscale value of the pixel corresponding to the kth element is the first preset grayscale value. If the value of the kth element in the watermark decoded sequence is 0, the grayscale value of the pixel corresponding to the kth element is the second preset grayscale value, wherein the first preset grayscale value is greater than the first preset threshold value, and the second preset grayscale value is less than the first preset threshold value. For example, the first preset threshold value is 128, the first preset grayscale value is 255, and the second preset grayscale value is 0, but it is not limited thereto. In this way, the grayscale value of each pixel in the watermark decoded image can be determined, that is, the watermark decoded image is a grayscale image.
[0090] Furthermore, the watermark decoded image and the watermark image can be tested for similarity. If the similarity between the watermark decoded image and the watermark image exceeds a preset similarity threshold, the target image can be determined to be the original image after the watermark image is added. It should be noted that the method for calculating the similarity between the watermark decoded image and the watermark image can be any existing appropriate similarity calculation method, and the embodiment of the present invention does not limit this.
[0091] Figure 4 is a schematic diagram of the structure of an image processing device in an embodiment of the present invention. The image processing device in the embodiment of the present invention may include:
[0092] The acquisition module 41 is used to acquire an original pixel matrix of the original image and a watermark pixel sequence of the watermark image, wherein the original pixel matrix corresponds to the color channel of the original image one by one, the elements in each original pixel matrix are the grayscale values of the pixels of the original image in the corresponding color channel, and the elements in the watermark pixel sequence are determined according to the grayscale values of the pixels of the watermark image in the preset color channel;
[0093] A segmentation module 42 is used to segment the original pixel matrix corresponding to each color channel to obtain multiple original sub-matrices corresponding to the color channel;
[0094] A singular value decomposition module 43 is used to perform singular value decomposition processing on each of the multiple original sub-matrices corresponding to each color channel to obtain a singular value matrix corresponding to the color channel, wherein the singular value matrix is a matrix with m rows and n columns, m is the number of original sub-matrices corresponding to the color channel, n is the number of singular values of the original sub-matrix, and the elements of the i-th row in the singular value matrix are the singular values of the i-th original sub-matrix, m, n, i are positive integers, and i≤m;
[0095] The updating module 44 is used to update at least a part of the elements of the k+c×lth row in the singular value matrix corresponding to each color channel according to the kth element in the watermark pixel sequence, so as to obtain multiple watermark image pixel matrices, wherein the watermark image pixel matrices correspond to the color channels one by one, wherein c is the number of elements in the watermark pixel sequence, k and c are positive integers, k≤c<m / 2, and l is 0 to Integer between ;
[0096] The target image generating module 45 is configured to generate a target image according to the plurality of watermark image pixel matrices.
[0097] In a specific implementation, the above-mentioned image processing device may correspond to a chip with an image processing function in a terminal; or correspond to a chip module with an image processing function in a terminal, or correspond to a terminal.
[0098] about Figure 4 For more information on the working principle, working method and beneficial effects of the image processing device shown in FIG. Figures 1 to 3 The relevant description will not be repeated here.
[0099] The embodiment of the present invention further provides a storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps of the above-mentioned image processing method are executed. The storage medium may include ROM, RAM, a magnetic disk or an optical disk, etc. The storage medium may also include a non-volatile memory or a non-transitory memory, etc.
[0100] The embodiment of the present invention further provides a terminal, comprising a memory and a processor, wherein the memory stores a computer program that can be run on the processor, and the processor executes the steps of the above-mentioned image processing method when running the computer program. The computing device includes but is not limited to terminal devices such as mobile phones, computers, and tablet computers.
[0101] It should be understood that in the embodiments of the present application, the processor may be a central processing unit (CPU), and the processor may also be other general-purpose processors, digital signal processors (DSP), application specific integrated circuits (ASIC), field programmable gate arrays (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.
[0102] It should also be understood that the memory in the embodiments of the present application may be a volatile memory or a non-volatile memory, or may include both volatile and non-volatile memories. Among them, the non-volatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may be a random access memory (RAM), which is used as an external cache. By way of example but not limitation, many forms of random access memory (RAM) are available, such as static RAM (SRAM), dynamic random access memory (DRAM), synchronous DRAM (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link DRAM (SLDRAM) and direct rambus RAM (DR RAM).
[0103] The above embodiments may be implemented in whole or in part by software, hardware, firmware or any other combination thereof. When implemented using software, the above embodiments may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions or computer programs. When the computer instructions or computer programs are loaded or executed on a computer, the processes or functions described in the embodiments of the present application are generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer program may be stored in a computer-readable storage medium, or may be transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer program may be transmitted from one website, computer, server or data center to another website, computer, server or data center by wired or wireless means.
[0104] In the several embodiments provided in the present application, it should be understood that the disclosed methods, devices and systems can be implemented in other ways. For example, the device embodiments described above are merely schematic; for example, the division of the units is only a logical function division, and there may be other division methods in actual implementation; for example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. The units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the scheme of this embodiment.
[0105] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may be physically included separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of hardware plus software functional units. For example, for each device or product applied to or integrated in a chip, each module / unit contained therein may be implemented in the form of hardware such as circuits, or at least part of the modules / units may be implemented in the form of software programs, which run on a processor integrated inside the chip, and the remaining (if any) modules / units may be implemented in the form of hardware such as circuits; for each device or product applied to or integrated in a chip module, each module / unit contained therein may be implemented in the form of hardware such as circuits, and different modules / units may be located in the same component (such as a chip, circuit module, etc.) or different components of the chip module, or at least part of the modules / units may be implemented in the form of software programs. The element can be implemented in the form of a software program, which runs on a processor integrated inside the chip module, and the remaining (if any) modules / units can be implemented in the form of hardware such as circuits; for various devices and products applied to or integrated in the terminal, the various modules / units contained therein can be implemented in the form of hardware such as circuits, and different modules / units can be located in the same component (for example, chip, circuit module, etc.) or in different components in the terminal, or, at least some modules / units can be implemented in the form of a software program, which runs on a processor integrated inside the terminal, and the remaining (if any) modules / units can be implemented in the form of hardware such as circuits.
[0106] It should be understood that the term "and / or" in this article is only a description of the association relationship of the associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article indicates that the associated objects before and after are in an "or" relationship.
[0107] The "plurality" appearing in the embodiments of the present application refers to two or more.
[0108] The first, second, etc. descriptions appearing in the embodiments of the present application are only used for illustration and distinction of the description objects. There is no order, nor do they indicate any special limitation on the number of devices in the embodiments of the present application, and cannot constitute any limitation on the embodiments of the present application.
[0109] Although the present invention is disclosed as above, the present invention is not limited thereto. Any person skilled in the art can make various changes and modifications without departing from the spirit and scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the scope defined by the claims.
Claims
1. An image processing method, characterized in that: The method comprises: Acquire multiple original pixel matrices of the original image and a watermark pixel sequence of the watermark image, wherein the original pixel matrices correspond to the color channels of the original image one by one, the elements in each original pixel matrix are the grayscale values of the pixels of the original image in the corresponding color channel, and the elements in the watermark pixel sequence are determined according to the grayscale values of the pixels of the watermark image in the preset color channel; Segmenting the original pixel matrix corresponding to each color channel to obtain multiple original sub-matrices corresponding to the color channel; For multiple original sub-matrices corresponding to each color channel, singular value decomposition is performed on each original sub-matrix to obtain a singular value matrix corresponding to the color channel, wherein the singular value matrix is a matrix with m rows and n columns, m is the number of original sub-matrices corresponding to the color channel, n is the number of singular values of the original sub-matrix, the value of the element in the i-th row in the singular value matrix is the singular value of the i-th original sub-matrix, m, n, i are positive integers, and i≤m; According to the kth element in the watermark pixel sequence, at least a part of the elements in the k+c×lth row in the singular value matrix corresponding to each color channel is updated to obtain multiple watermark image pixel matrices, wherein the watermark image pixel matrices correspond to the color channels one by one, wherein c is the number of elements in the watermark pixel sequence, k and c are positive integers, k≤c≤m / 2, and l is 0 to Integer between ; Generating a target image according to the plurality of watermark image pixel matrices; The following formula is used to update at least a portion of the elements in the k+c×lth row of the singular value matrix corresponding to each color channel: Wherein, A(k+c×l,j) is the value of the element in the k+c×lth row and jth column in the singular value matrix before updating, A'(k+c×l,j) is the value of the element in the k+c×lth row and jth column in the singular value matrix after updating, j is a positive integer and j≤N, B and D are preset positive integers, C k is the value of the kth element in the watermark pixel sequence.
2. The image processing method according to claim 1, characterized in that: The elements in the watermark pixel sequence correspond one-to-one to the pixels of the watermark image. For each pixel of the watermark image, if the grayscale value of the pixel in the preset color channel is greater than or equal to the first preset threshold, the value of the element corresponding to the pixel in the watermark pixel sequence is 1; otherwise, the value of the element corresponding to the pixel in the watermark pixel sequence is 0.
3. The image processing method according to claim 1, characterized in that: The original submatrix is a matrix with 2 rows and 2 columns.
4. The image processing method according to claim 1, characterized in that: Before segmenting the original pixel matrix corresponding to each color channel, the method further includes: Wavelet transform is performed on each original pixel matrix to obtain a plurality of transformed pixel matrices, and the plurality of transformed pixel matrices are used as the plurality of original pixel matrices.
5. The image processing method according to claim 1, characterized in that: Before performing singular value decomposition processing on each original sub-matrix respectively, the method further includes: Discrete cosine transform processing is performed on each original sub-matrix respectively to obtain a plurality of transformed sub-matrices, and the plurality of transformed sub-matrices are used as the plurality of original sub-matrices.
6. The image processing method according to claim 5, characterized in that: The elements in each row of the singular value matrix are arranged in descending order of value. According to the kth element in the watermark pixel sequence, updating at least a part of the elements in the k+c×lth row of the singular value matrix corresponding to each color channel includes: For the singular value matrix corresponding to each color channel, the elements of the first N columns in the k+c×lth row in the singular value matrix are updated according to the kth element in the watermark pixel sequence, where N is a preset positive integer and N≤n.
7. The image processing method according to claim 1, characterized in that: Generating a target image according to the plurality of watermark image pixel matrices comprises: According to the watermark image pixel matrix corresponding to each color channel, a plurality of first watermark image sub-matrices corresponding to the color channel are generated, wherein the i-th first watermark image sub-matrix is generated according to the elements of the i-th row of the watermark image pixel matrix; Performing inverse transformation of singular value decomposition on a plurality of first watermark image sub-matrices corresponding to each color channel to obtain a plurality of second watermark image sub-matrices corresponding to the color channel; Performing splicing processing on a plurality of second watermark image sub-matrices corresponding to each color channel to obtain a target pixel matrix corresponding to the color channel; The target image is generated according to the target pixel matrix corresponding to each color channel.
8. The image processing method according to claim 1, characterized in that: The method further comprises: A watermark decoding image is extracted according to the target image, and a similarity detection is performed between the watermark decoding image and the watermark image.
9. The image processing method according to claim 8, characterized in that: Extracting a watermarked decoded image according to the target image comprises: Generate a plurality of target pixel matrices, wherein the target pixel matrices correspond to the color channels of the target image one by one, and the elements in each target pixel matrix are the grayscale values of the pixel points of the target image in the corresponding color channel; Segmenting the target pixel matrix corresponding to each color channel to obtain multiple target sub-matrices corresponding to the color channel; Performing singular value decomposition processing on each target submatrix to obtain a target singular value matrix corresponding to the color channel, wherein the elements in the qth row of the target singular value matrix are singular values of the qth target submatrix, q is a positive integer, c≤q, and q is less than or equal to the number of rows of the target singular value matrix; determining the value of the kth element in the watermark decoding sequence according to the values of at least a part of the elements in the kth row of the target singular value matrix to obtain the watermark decoding sequence; The watermark decoded image is generated according to the watermark decoded sequence.
10. An image processing device, characterized in that: The device comprises: An acquisition module, used to acquire an original pixel matrix of an original image and a watermark pixel sequence of a watermark image, wherein the original pixel matrix corresponds to a color channel of the original image one by one, an element in each original pixel matrix is a grayscale value of a pixel point of the original image in a corresponding color channel, and an element in the watermark pixel sequence is determined according to the grayscale value of a pixel point of the watermark image in a preset color channel; A segmentation module is used to segment the original pixel matrix corresponding to each color channel to obtain multiple original sub-matrices corresponding to the color channel; A singular value decomposition module is used to perform singular value decomposition processing on each of the multiple original sub-matrices corresponding to each color channel to obtain a singular value matrix corresponding to the color channel, wherein the singular value matrix is a matrix with m rows and n columns, m is the number of original sub-matrices corresponding to the color channel, n is the number of singular values of the original sub-matrix, the elements of the i-th row in the singular value matrix are the singular values of the i-th original sub-matrix, m, n, i are positive integers, i≤m; an updating module is used to update at least a part of the elements of the k+c×l-th row in the singular value matrix corresponding to each color channel according to the k-th element in the watermark pixel sequence to obtain multiple watermark image pixel matrices, the watermark image pixel matrices correspond to the color channels one by one, wherein c is the number of elements in the watermark pixel sequence, k and c are positive integers, k≤c<m / 2, l is 0 to Integer between ; The target image generation module is used to generate a target image according to the plurality of watermark image pixel matrices; wherein the following formula is used to update at least a part of the elements of the k+c×lth row in the singular value matrix corresponding to each color channel: Wherein, A(k+c×l,j) is the value of the element in the k+c×lth row and jth column in the singular value matrix before updating, A'(k+c×l,j) is the value of the element in the k+c×lth row and jth column in the singular value matrix after updating, j is a positive integer and j≤N, B and D are preset positive integers, C k is the value of the kth element in the watermark pixel sequence.
11. A storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the image processing method according to any one of claims 1 to 9 are executed.
12. A terminal comprising a memory and a processor, wherein the memory stores a computer program that can be run on the processor, characterized in that: When the processor runs the computer program, the processor performs the steps of the image processing method according to any one of claims 1 to 9.
Citation Information
Patent Citations
Digital blind watermarking method for double protection of image integrity
CN101866477A
Digital image processing method and device
CN104156906A