Method and system for preventing e-commerce pictures from being stolen
By embedding watermarks in the mid-frequency coefficient of e-commerce pictures and dynamically determining the target sub-image block, the distortion problem of traditional watermark technology under compression and transformation attacks is solved, the difficulty of image protection and verification capabilities of e-commerce pictures is improved, and the difficulty of e-commerce pictures is enhanced security.
Patent Information
- Application Number
- CN202411474090.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-22
- Publication Date
- 2025-01-14
- Estimated Expiration
- 2044-10-22
AI Technical Summary
When traditional image watermarking technology faces compression, cropping or geometric transformation attacks of e-commerce images, watermark information is easily distorted or lost, making it difficult to effectively prevent e-commerce images from being stolen.
By embedding the watermark into the intermediate frequency coefficient of the Y channel of the image and dynamically determining the target sub-image block and the intermediate frequency coefficient, the difficulty of being stolen is increased, and there is no need to know the number of the target image block and the position of the intermediate frequency coefficient in advance, and the discrete cosine transformation and Inverse discrete cosine transformation to realize the embedding and extraction of watermarks.
It improves the robustness and difficulty of e-commerce image watermarks, enhances the verification of the authenticity and integrity of images, and reduces the risk of misappropriation.
Smart Images

Figure CN119313535A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image information processing, and in particular to a method and system for preventing e-commerce images from being stolen. Background Art
[0002] In recent years, e-commerce has developed rapidly. Especially with the continuous maturity of Internet technology and logistics systems, online shopping has become one of the main consumption methods for consumers around the world. The popularization of mobile Internet, the application of 5G technology, and the support of big data and artificial intelligence have further promoted the intelligent and personalized services of e-commerce platforms. At the same time, new models such as live e-commerce and social e-commerce have emerged, user participation has increased significantly, and the shopping experience has become more diversified. In the development of e-commerce, pictures play a vital role. High-definition and high-quality product pictures can not only intuitively show the appearance and details of the product, enhance users' shopping confidence, but also influence consumers' purchasing decisions. On e-commerce platforms, consumers cannot directly touch the products, and vision has become the main way to understand the products. In addition, high-quality pictures can also enhance brand image, enhance user experience, and reduce after-sales disputes.
[0003] Some small businesses directly use the original pictures that businesses have invested a lot of energy and money to shoot without authorization, which not only affects the interests of the original businesses, but also disrupts the market order. As an effective means of image protection, image watermarking technology can embed copyright information or authentication information into images, which not only provides a legal basis for the owner of the image, but also effectively verifies the authenticity and integrity of the image. Although traditional watermarking schemes have certain anti-attack capabilities, they still have certain limitations when facing a variety of complex attacks, especially when the image content is subjected to strong compression, cropping or geometric transformation attacks, the watermark information is often easily distorted or lost. Summary of the invention
[0004] In order to reduce the possibility of e-commerce pictures being stolen, the present invention provides a method for preventing e-commerce pictures from being stolen, and the method comprises the following steps: Obtain the watermark and the carrier image to be watermarked, convert the watermark into a binary sequence, and convert the carrier image into a YCbCr color space; divide the Y channel into multiple image blocks of the same size and not overlapping, and further divide each image block into multiple sub-image blocks of the same size and not overlapping; Performing discrete cosine transform on the sub-image block to obtain a DCT coefficient matrix of the sub-image block, and selecting two target sub-image blocks from the plurality of sub-image blocks based on the DCT coefficient matrix of the sub-image block; determining a target intermediate frequency coefficient of each target sub-image block, and adjusting the two target intermediate frequency coefficients so that a difference between the two target intermediate frequency coefficients is located in an interval corresponding to the bits to be embedded; After all the bits to be embedded are embedded, all sub-image blocks are subjected to inverse discrete cosine transform to obtain the Y channel, and the Y channel is combined with the original Cb and Cr channels and transformed into the RGB channel to obtain the watermarked image.
[0005] Preferably, the selecting two target sub-image blocks from the plurality of sub-image blocks based on the DCT coefficient matrix of the sub-image blocks is specifically: Calculate the Frobenius norm of the DCT coefficient matrix of each sub-image block of the image block or the DCT coefficient matrix with the boundary removed; Sort the sub-image blocks in descending order of Frobenius norm; The first two image blocks after sorting are used as target sub-image blocks.
[0006] Preferably, the determining of the target intermediate frequency coefficient of each target sub-image block is specifically: Obtain the image block to which the target sub-image block belongs, and perform downsampling to obtain an image block of the same size as the target sub-image block; Performing discrete cosine transform on the downsampled image block to obtain a DCT coefficient matrix of the downsampled image block; Obtain the positions of the two maximum values in the intermediate frequency region of the DCT coefficient matrix of the downsampled image block; The positions of the two maximum values are taken as the positions of the target intermediate frequency coefficients of the two target sub-image blocks.
[0007] Preferably, the intermediate frequency region is determined as follows: The size n×n of the DCT coefficient matrix of the downsampled image block is obtained, and a k×k element region located in the central region of the DCT coefficient matrix of the downsampled image block is used as the intermediate frequency region, where k=n-1 or k=n-2.
[0008] Preferably, the two intermediate frequency coefficients are adjusted so that the difference between the two intermediate frequency coefficients is within the interval corresponding to the bits to be embedded, specifically: 2M intervals are pre-divided, where the intervals with even numbers are the intervals corresponding to 0, the intervals with odd numbers are the intervals corresponding to 0, and M is a positive integer greater than or equal to 2; Calculate the difference between the target intermediate frequency coefficients of the two target sub-image blocks; If the bit to be embedded is 0, find an interval closest to the difference and with an even number, calculate the middle value of the found interval, and adjust one or two of the target intermediate frequency coefficients of the two target sub-image blocks so that the difference between the two is the middle value; If the bit to be embedded is 1, find the interval closest to the difference and with an odd sequence number, calculate the middle value of the found interval, and adjust one or two of the target intermediate frequency coefficients of the two target sub-image blocks so that the difference between the two is the middle value.
[0009] In addition, the present invention also provides a system for preventing e-commerce pictures from being stolen, and the system includes the following modules: The segmentation module is used to obtain the watermark and the carrier image to be watermarked, convert the watermark into a binary sequence, and convert the carrier image into a YCbCr color space; divide the Y channel into multiple image blocks of the same size and non-overlapping, and further divide each image block into multiple sub-image blocks of the same size and non-overlapping; a watermark adding module, configured to perform discrete cosine transform on the sub-image block to obtain a DCT coefficient matrix of the sub-image block, select two target sub-image blocks from the plurality of sub-image blocks based on the DCT coefficient matrix of the sub-image block; determine a target intermediate frequency coefficient of each target sub-image block, and adjust the two target intermediate frequency coefficients so that a difference between the two target intermediate frequency coefficients is located in an interval corresponding to the bit to be embedded; The inverse transformation module is used to perform inverse discrete cosine transformation on all sub-image blocks to obtain the Y channel after all the bits to be embedded are embedded, and the Y channel is combined with the original Cb and Cr channels and then transformed into the RGB channel to obtain the image with the watermark added.
[0010] Preferably, the selecting two target sub-image blocks from the plurality of sub-image blocks based on the DCT coefficient matrix of the sub-image blocks is specifically: Calculate the Frobenius norm of the DCT coefficient matrix of each sub-image block of the image block or the DCT coefficient matrix with the boundary removed; Sort the sub-image blocks in descending order of Frobenius norm; The first two image blocks after sorting are used as target sub-image blocks.
[0011] Preferably, the determining of the target intermediate frequency coefficient of each target sub-image block is specifically: Obtain the image block to which the target sub-image block belongs, and perform downsampling to obtain an image block of the same size as the target sub-image block; Performing discrete cosine transform on the downsampled image block to obtain a DCT coefficient matrix of the downsampled image block; Obtain the positions of the two maximum values in the intermediate frequency region of the DCT coefficient matrix of the downsampled image block; The positions of the two maximum values are taken as the positions of the target intermediate frequency coefficients of the two target sub-image blocks.
[0012] Preferably, the intermediate frequency region is determined as follows: The size n×n of the DCT coefficient matrix of the downsampled image block is obtained, and a k×k element region located in the central region of the DCT coefficient matrix of the downsampled image block is used as the intermediate frequency region, where k=n-1 or k=n-2.
[0013] Preferably, the two intermediate frequency coefficients are adjusted so that the difference between the two intermediate frequency coefficients is within the interval corresponding to the bits to be embedded, specifically: 2M intervals are pre-divided, where the intervals with even numbers are the intervals corresponding to 0, the intervals with odd numbers are the intervals corresponding to 0, and M is a positive integer greater than or equal to 2; Calculate the difference between the target intermediate frequency coefficients of the two target sub-image blocks; If the bit to be embedded is 0, find an interval closest to the difference and with an even number, calculate the middle value of the found interval, and adjust one or two of the target intermediate frequency coefficients of the two target sub-image blocks so that the difference between the two is the middle value; If the bit to be embedded is 1, find the interval closest to the difference and with an odd sequence number, calculate the middle value of the found interval, and adjust one or two of the target intermediate frequency coefficients of the two target sub-image blocks so that the difference between the two is the middle value.
[0014] To address the problem that e-commerce images are easily stolen, the present invention embeds the bits of the watermark to be embedded into the intermediate frequency coefficients of the Y channel of the image, and dynamically determines the target sub-image block and the intermediate frequency coefficient, which not only increases the difficulty of theft but also eliminates the need to know the number of the target image block and the position of the intermediate frequency coefficient in advance. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] Figure 1 This is a flow chart of Embodiment 1; Figure 2 To illustrate the pseudo code of the present invention; Figure 3 The process of adding watermarks; Figure 4 This is a structural diagram of the second embodiment. DETAILED DESCRIPTION
[0016] In order to make the purpose, technical scheme and advantages of the embodiment of the present invention clearer, the technical scheme in the embodiment of the present invention will be clearly and completely described in conjunction with the drawings in the embodiment of the present invention. Obviously, the described embodiment is a part of the embodiment of the present invention, not all of the embodiments. Based on the embodiments in the present invention, all other embodiments obtained by ordinary technicians in the field without creative work are within the scope of protection of the present invention. In addition, the technical features in the various embodiments or single embodiments provided by the present invention can be combined with each other arbitrarily to form a feasible technical solution. This combination is not subject to the constraints of the sequence of steps and / or the structural composition mode, but must be based on the ability of ordinary technicians in the field to achieve. When the combination of technical solutions is contradictory or cannot be achieved, it should be considered that the combination of such technical solutions does not exist and is not within the scope of protection required by the present invention. If there are step numbers in the following embodiments, they are only set for the convenience of explanation, and the order between the steps is not limited in any way. The execution order of each step in the embodiment can be adaptively adjusted according to the understanding of those skilled in the art.
[0017] Figure 1 The first aspect of the present invention is shown. The present invention provides a method for preventing e-commerce pictures from being stolen. The method comprises the following steps: S1, obtain the watermark and the carrier image to be watermarked, convert the watermark into a binary sequence, convert the carrier image into a YCbCr color space; divide the Y channel into multiple image blocks of the same size and non-overlapping, and further divide each image block into multiple sub-image blocks of the same size and non-overlapping; When adding a watermark to an image, first obtain the watermark to be added and the carrier image. The watermark can be text, string, number, picture, etc. The watermark is converted into a binary sequence. For example, the watermark to be embedded is the letter a, and its corresponding binary sequence is 01100001 00001010. The binary sequence includes multiple 0s and 1s, and each binary bit is a bit. The carrier image is converted into the YCbCr color space. In the YCbCr color space, Y is the brightness channel, Cb is the blue component, and Cr is the red component. Specifically, it is converted by rgb2ycbcr (carrier image). Then extract the Y channel, and divide the Y channel image into multiple image blocks of the same size and non-overlapping. Preferably, the image block size is 16×16, and each image block is further divided into multiple sub-image blocks. The sub-image blocks also do not overlap with each other and are of the same size. Preferably, the sub-image block size is 8×8.
[0018] S2, performing discrete cosine transform on the sub-image block to obtain a DCT coefficient matrix of the sub-image block, selecting two target sub-image blocks from the multiple sub-image blocks based on the DCT coefficient matrix of the sub-image block; determining a target intermediate frequency coefficient of each target sub-image block, and adjusting the two target intermediate frequency coefficients so that the difference between the two target intermediate frequency coefficients is within the interval corresponding to the bit to be embedded; Perform discrete cosine transform (DCT) on each sub-image block to obtain the DCT coefficient matrix of the sub-image block. The DCT coefficient matrix of the sub-image block is the same size as the sub-image block. For example, if the sub-image block size is 8×8, the DCT coefficient matrix is also 8×8. In the DCT coefficient matrix, the upper left corner represents the low-frequency component, and the lower right corner represents the high-frequency component. The low-frequency component is the overall information of the sub-image block, such as the overall brightness information, and the high-frequency component is the detail information of the sub-image block. Changing the high-frequency component and the low-frequency component will greatly change the visual effect of the image. Moreover, when the attacker changes the brightness of the image, blurs the image, etc., the high-frequency component and the low-frequency component are changed more. In order to keep the changes of the carrier image before and after the watermark is embedded, especially the visual effect, small and improve the robustness, the watermark is embedded in the intermediate frequency component. For a sub-image block with a relatively small intermediate frequency component, when a certain amplitude is changed, the impact generated is greater than that of a sub-image block with a large intermediate frequency component. For example, if an intermediate frequency component is originally 4, the change amount after the increase of 1 is 25%, while if an intermediate frequency component is originally 20, the change amount after the increase of 1 is 5%. An image block has multiple sub-image blocks, and two target sub-image blocks are selected from the multiple sub-image blocks. In one embodiment, the two target sub-image blocks are selected from the multiple sub-image blocks based on the DCT coefficient matrix of the sub-image blocks, specifically: Calculate the Frobenius norm of the DCT coefficient matrix of each sub-image block of the image block or the DCT coefficient matrix with the boundary removed; Sort the sub-image blocks in descending order of Frobenius norm; The first two image blocks after sorting are used as target sub-image blocks.
[0019] The Frobenius norm of the DCT coefficient matrix of each sub-image block is calculated, that is, the root sum of the squares of the elements in the DCT coefficient matrix is calculated. Since the one with the larger intermediate frequency coefficient area is to be selected from multiple sub-image blocks, in another embodiment, the DCT coefficient matrix is delimited before calculating the Frobenius norm, wherein delimiting the boundaries specifically means delimiting the first row, the last row, the first column, and the last column.
[0020] After calculating the Frobenius norm, the sub-image blocks are sorted in descending order of the norm. Assuming there are four sub-image blocks B1-B4, which are sorted as B3, B1, B2, and B4, the first two image blocks B3 and B1 are taken as target sub-image blocks.
[0021] When embedding a bit sequence, the intermediate frequency component in the DCT coefficient matrix of the target sub-image block is changed. In the DCT coefficient matrix, there are multiple frequency components. For example, the size of the sub-image block is 8×8, and its DCT coefficient matrix is also 8×8. Each frequency component in the DCT coefficient matrix is recorded as C(i, j), where 1≤i, j≤8. In one embodiment, the central area of the DCT coefficient matrix is used as the intermediate frequency area. In one embodiment, the intermediate frequency area is determined as follows: Get the size n×n of the DCT coefficient matrix of the downsampled image block, and use the k×k element area located in the central area of the DCT coefficient matrix of the downsampled image block as the intermediate frequency area, where k=n-1 or k=n-2. More specifically, the area consisting of {C(i, j)|2≤i, j≤n-1} or {C(i, j)|3≤i, j≤m-2} in the DCT coefficient matrix is used as the intermediate frequency area. Still taking the above example, n=8, then the intermediate frequency area is the area consisting of {C(i, j)|2≤i, j≤7} or {C(i, j)|3≤i, j≤6} in the DCT coefficient matrix.
[0022] In the obtained intermediate frequency region, the target intermediate frequency coefficient of each target sub-image block is determined from the intermediate frequency region. In one embodiment, the target intermediate frequency coefficient is predetermined. For example, the target intermediate frequency coefficient of the first target sub-image block is the coefficient corresponding to the position C (3, 5) in the DCT coefficient matrix of the first target sub-image block. For this method, when extracting the watermark, the positions of the two intermediate frequency coefficients need to be known in advance.
[0023] Similarly, in order to keep the change of the carrier image before and after the watermark embedding, especially the visual effect change slightly and improve the robustness, in another embodiment, the target intermediate frequency coefficient of each target sub-image block is determined as follows: Obtain the image block to which the target sub-image block belongs, and perform downsampling to obtain an image block of the same size as the target sub-image block; Performing discrete cosine transform on the downsampled image block to obtain a DCT coefficient matrix of the downsampled image block; Obtain the positions of the two maximum values in the intermediate frequency region of the DCT coefficient matrix of the downsampled image block; The positions of the two maximum values are taken as the positions of the target intermediate frequency coefficients of the two target sub-image blocks.
[0024] The target sub-image block and the image block to which the target sub-image block belongs are of different sizes, which results in different sizes of the DCT coefficient matrix. The image block is first downsampled, and the downsampling method includes but is not limited to average pooling, maximum pooling or convolution. Then the downsampled image block is subjected to DCT transformation to obtain the DCT coefficient matrix. The positions of the two maximum values in the intermediate frequency region of the DCT coefficient matrix of the downsampled image block are found, such as C (3, 4) and C (5, 2). The positions of these two maximum values are used as the positions of the intermediate frequency coefficients of the two target sub-image blocks. Then the target intermediate frequency coefficient of the first target sub-image block is the intermediate frequency component at C (3, 4), and the target intermediate frequency coefficient of the second target sub-image block is the intermediate frequency component at C (5, 2).
[0025] After determining the position of the intermediate frequency coefficient, for example, C (3, 4) and C (5, 2), the specific value of the intermediate frequency coefficient can be obtained, assuming that the value of C (3, 4) in the DCT coefficient matrix of the first target sub-image block is a1, and the value of C (5, 2) in the DCT coefficient matrix of the second target sub-image block is a2. Compared with the previous embodiment, when extracting the watermark, it is not necessary to know the position of the intermediate frequency coefficient in the target sub-image block. In one embodiment, the image block ranked first after sorting the sub-image blocks in descending order according to the Frobenius norm is used as the first target image block, and the larger of the two maximum values of the intermediate frequency area of the DCT coefficient matrix of the down-sampled image block is used as the target intermediate frequency coefficient of the first target image block; the image block ranked second after sorting the sub-image blocks in descending order according to the Frobenius norm is used as the second target image block, and the smaller of the two maximum values of the intermediate frequency area of the DCT coefficient matrix of the down-sampled image block is used as the target intermediate frequency coefficient of the second target image block.
[0026] The bit embedding process is as follows: 2M intervals are pre-divided, where the intervals with even numbers are the intervals corresponding to 0, the intervals with odd numbers are the intervals corresponding to 0, and M is a positive integer greater than or equal to 2; Calculate the difference between the target intermediate frequency coefficients of the two target sub-image blocks; If the bit to be embedded is 0, find an interval closest to the difference and with an even number, calculate the middle value of the found interval, and adjust one or two of the target intermediate frequency coefficients of the two target sub-image blocks so that the difference between the two is the middle value; If the bit to be embedded is 1, find the interval closest to the difference and with an odd sequence number, calculate the middle value of the found interval, and adjust one or two of the target intermediate frequency coefficients of the two target sub-image blocks so that the difference between the two is the middle value.
[0027] Divide multiple numerical intervals in advance, for example, into 4 intervals, numbered 1-4 respectively, and the values of the multiple numerical intervals are continuous. In one embodiment, the method of pre-dividing 2M intervals is: determine the lower limit value and the upper limit value, and divide the area between the lower limit value and the upper limit value into 2M intervals, preferably, M=2. For example, if the lower limit value is -4 and the upper limit value is 4, the divided intervals are [-4,-2), [-2,0), [0,2), [2,4]. The interval with an even number is the interval corresponding to bit 0, and the interval with an odd number is the interval corresponding to bit 1, then the interval corresponding to bit 0 is [-2,0), [2,4], and the interval corresponding to bit 1 is [-4,-2), [0,2).
[0028] Calculate the difference between the target intermediate frequency coefficients of the two target sub-image blocks B3 and B1, that is, a1-a2. Assume that a1-a2=1. If the bit to be embedded is 0, the interval corresponding to bit 0 is [-2,0) and [2,4]. The difference is closest to [2,4]. The middle value of [2,4] is 3. Adjust a1 and a2 so that the difference between the two is 3. Specifically, the adjustment method is to increase the target intermediate frequency coefficient of the first target sub-image block by d, and decrease the target intermediate frequency coefficient of the second target sub-image block by d, and 2d is equal to the middle value minus the difference, for example, a1 increases by d, a2 decreases by d, and 2d=2. In another adjustment method, only the target intermediate frequency coefficient of the first target sub-image block is increased, or only the target intermediate frequency coefficient of the second target sub-image block is decreased.
[0029] Similarly, if the bit to be embedded is 1, the interval corresponding to bit 1 is [-4, -2), [0, 2), the difference 1 is within [0, 2), and is equal to the middle value of the interval, and there is no need to adjust the target intermediate frequency coefficient of the first target sub-image block and the target intermediate frequency coefficient of the second target sub-image block. If the difference is 1.5, since the middle value is 1, the target intermediate frequency coefficients of the two target sub-image blocks are adjusted so that the difference between the two is the middle value. Specifically, the adjustment method is to increase the target intermediate frequency coefficient of the first target sub-image block by d, and reduce the target intermediate frequency coefficient of the second target sub-image block by d, and 2d is equal to the middle value minus the difference, for example, a1 increases by d, a2 decreases by d, and 2d=-0.5. In another adjustment method, only the target intermediate frequency coefficient of the first target sub-image block is increased, or only the target intermediate frequency coefficient of the second target sub-image block is reduced.
[0030] S3, after all the bits to be embedded are embedded, all sub-image blocks are subjected to inverse discrete cosine transform to obtain the Y channel, and the Y channel is combined with the original Cb and Cr channels and then transformed to the RGB channel to obtain the image with the watermark added.
[0031] After all the bits to be embedded are embedded, all sub-image blocks or target sub-image blocks are subjected to inverse discrete cosine transform to obtain the Y channel, which is then combined with the original Cb and Cr channels and transformed to the RGB channel to obtain the watermarked image.
[0032] When extracting the watermark, the inverse operation is performed, that is, the watermarked image is first segmented to obtain image blocks, each image block is further segmented to obtain sub-image blocks, and two target sub-image blocks are selected from the multiple sub-image blocks based on the DCT coefficient matrix of the sub-image blocks.
[0033] If the position of the target intermediate frequency coefficient is pre-set, the target intermediate frequency coefficient is extracted from the DCT coefficient matrix of the two target sub-image blocks according to the position, and then the difference between the target intermediate frequency coefficients of the two target sub-image blocks is calculated, and whether it is bit 1 or bit 0 is determined according to the interval to which the difference belongs.
[0034] If the position of the target intermediate frequency coefficient is determined based on the image block, the position of the target intermediate frequency coefficient is also determined in the above manner, and the target intermediate frequency coefficient is further obtained. Then, the difference between the target intermediate frequency coefficients of the two target sub-image blocks is calculated, and whether it is bit 1 or bit 0 is determined based on the interval to which the difference belongs. Figure 2 The pseudo code of the present invention is shown, Figure 3 The process of adding watermarks is shown.
[0035] Figure 4 The second aspect of the present invention is shown. The present invention further provides a system for preventing e-commerce pictures from being stolen. The system includes the following modules: The segmentation module is used to obtain the watermark and the carrier image to be watermarked, convert the watermark into a binary sequence, and convert the carrier image into a YCbCr color space; divide the Y channel into multiple image blocks of the same size and non-overlapping, and further divide each image block into multiple sub-image blocks of the same size and non-overlapping; a watermark adding module, configured to perform discrete cosine transform on the sub-image block to obtain a DCT coefficient matrix of the sub-image block, select two target sub-image blocks from the plurality of sub-image blocks based on the DCT coefficient matrix of the sub-image block; determine a target intermediate frequency coefficient of each target sub-image block, and adjust the two target intermediate frequency coefficients so that a difference between the two target intermediate frequency coefficients is located in an interval corresponding to the bit to be embedded; The inverse transformation module is used to perform inverse discrete cosine transformation on all sub-image blocks to obtain the Y channel after all the bits to be embedded are embedded, and the Y channel is combined with the original Cb and Cr channels and then transformed into the RGB channel to obtain the image with the watermark added.
[0036] Preferably, the selecting two target sub-image blocks from the plurality of sub-image blocks based on the DCT coefficient matrix of the sub-image blocks is specifically: Calculate the Frobenius norm of the DCT coefficient matrix of each sub-image block of the image block or the DCT coefficient matrix with the boundary removed; Sort the sub-image blocks in descending order of Frobenius norm; The first two image blocks after sorting are used as target sub-image blocks.
[0037] Preferably, the determining of the target intermediate frequency coefficient of each target sub-image block is specifically: Obtain the image block to which the target sub-image block belongs, and perform downsampling to obtain an image block of the same size as the target sub-image block; Performing discrete cosine transform on the downsampled image block to obtain a DCT coefficient matrix of the downsampled image block; Obtain the positions of the two maximum values in the intermediate frequency region of the DCT coefficient matrix of the downsampled image block; The positions of the two maximum values are taken as the positions of the target intermediate frequency coefficients of the two target sub-image blocks.
[0038] Preferably, the intermediate frequency region is determined as follows: The size n×n of the DCT coefficient matrix of the downsampled image block is obtained, and a k×k element region located in the central region of the DCT coefficient matrix of the downsampled image block is used as the intermediate frequency region, where k=n-1 or k=n-2.
[0039] Preferably, the two intermediate frequency coefficients are adjusted so that the difference between the two intermediate frequency coefficients is within the interval corresponding to the bits to be embedded, specifically: 2M intervals are pre-divided, where the intervals with even numbers are the intervals corresponding to 0, the intervals with odd numbers are the intervals corresponding to 0, and M is a positive integer greater than or equal to 2; Calculate the difference between the target intermediate frequency coefficients of the two target sub-image blocks; If the bit to be embedded is 0, find an interval closest to the difference and with an even number, calculate the middle value of the found interval, and adjust one or two of the target intermediate frequency coefficients of the two target sub-image blocks so that the difference between the two is the middle value; If the bit to be embedded is 1, find the interval closest to the difference and with an odd sequence number, calculate the middle value of the found interval, and adjust one or two of the target intermediate frequency coefficients of the two target sub-image blocks so that the difference between the two is the middle value.
[0040] It should be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "includes..." do not exclude the existence of other identical elements in the process, method, article or device including the elements. Any "predetermined threshold", "preset threshold" and other similar expressions that do not indicate specific values can be determined by a person of ordinary skill in the art through simple experiments or corresponding debugging.
[0041] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for preventing e-commerce pictures from being stolen, characterized in that: The method comprises the following steps: Obtain the watermark and the carrier image to be watermarked, convert the watermark into a binary sequence, and convert the carrier image into a YCbCr color space; divide the Y channel into multiple image blocks of the same size and not overlapping, and further divide each image block into multiple sub-image blocks of the same size and not overlapping; Performing discrete cosine transform on the sub-image block to obtain a DCT coefficient matrix of the sub-image block, and selecting two target sub-image blocks from the plurality of sub-image blocks based on the DCT coefficient matrix of the sub-image block; determining a target intermediate frequency coefficient of each target sub-image block, and adjusting the two target intermediate frequency coefficients so that a difference between the two target intermediate frequency coefficients is located in an interval corresponding to the bits to be embedded; After all the bits to be embedded are embedded, all sub-image blocks are subjected to inverse discrete cosine transform to obtain the Y channel, and the Y channel is combined with the original Cb and Cr channels and transformed into the RGB channel to obtain the watermarked image.
2. The method according to claim 1, characterized in that The selecting two target sub-image blocks from the plurality of sub-image blocks based on the DCT coefficient matrix of the sub-image blocks is specifically: Calculate the Frobenius norm of the DCT coefficient matrix of each sub-image block of the image block or the DCT coefficient matrix with the boundary removed; Sort the sub-image blocks in descending order of Frobenius norm; The first two image blocks after sorting are used as target sub-image blocks.
3. The method according to claim 1, characterized in that The determination of the target intermediate frequency coefficient of each target sub-image block is specifically as follows: Obtain the image block to which the target sub-image block belongs, and perform downsampling to obtain an image block of the same size as the target sub-image block; Performing discrete cosine transform on the downsampled image block to obtain a DCT coefficient matrix of the downsampled image block; Obtain the positions of the two maximum values in the intermediate frequency region of the DCT coefficient matrix of the downsampled image block; The positions of the two maximum values are taken as the positions of the target intermediate frequency coefficients of the two target sub-image blocks.
4. The method according to claim 3, characterized in that The intermediate frequency region is determined as follows: The size n×n of the DCT coefficient matrix of the downsampled image block is obtained, and a k×k element region located in the central region of the DCT coefficient matrix of the downsampled image block is used as the intermediate frequency region, where k=n-1 or k=n-2.
5. The method according to claim 1, characterized in that The two intermediate frequency coefficients are adjusted so that the difference between the two intermediate frequency coefficients is within the interval corresponding to the bits to be embedded, specifically: 2M intervals are pre-divided, where the intervals with even numbers are the intervals corresponding to 0, the intervals with odd numbers are the intervals corresponding to 0, and M is a positive integer greater than or equal to 2; Calculate the difference between the target intermediate frequency coefficients of the two target sub-image blocks; If the bit to be embedded is 0, find an interval closest to the difference and with an even number, calculate the middle value of the found interval, and adjust one or two of the target intermediate frequency coefficients of the two target sub-image blocks so that the difference between the two is the middle value; If the bit to be embedded is 1, find the interval closest to the difference and with an odd sequence number, calculate the middle value of the found interval, and adjust one or two of the target intermediate frequency coefficients of the two target sub-image blocks so that the difference between the two is the middle value.
6. A system for preventing e-commerce pictures from being stolen, characterized in that: The system includes the following modules: The segmentation module is used to obtain the watermark and the carrier image to be watermarked, convert the watermark into a binary sequence, and convert the carrier image into a YCbCr color space; divide the Y channel into multiple image blocks of the same size and non-overlapping, and further divide each image block into multiple sub-image blocks of the same size and non-overlapping; a watermark adding module, configured to perform discrete cosine transform on the sub-image block to obtain a DCT coefficient matrix of the sub-image block, and select two target sub-image blocks from the plurality of sub-image blocks based on the DCT coefficient matrix of the sub-image block; Determine a target intermediate frequency coefficient for each target sub-image block, and adjust two target intermediate frequency coefficients so that a difference between the two target intermediate frequency coefficients is located in an interval corresponding to the bits to be embedded; The inverse transformation module is used to perform inverse discrete cosine transformation on all sub-image blocks to obtain the Y channel after all the bits to be embedded are embedded, and the Y channel is combined with the original Cb and Cr channels and then transformed into the RGB channel to obtain the image with the watermark added.
7. The system according to claim 6, characterized in that The selecting two target sub-image blocks from the plurality of sub-image blocks based on the DCT coefficient matrix of the sub-image blocks is specifically: Calculate the Frobenius norm of the DCT coefficient matrix of each sub-image block of the image block or the DCT coefficient matrix with the boundary removed; Sort the sub-image blocks in descending order of Frobenius norm; The first two image blocks after sorting are used as target sub-image blocks.
8. The system according to claim 6, characterized in that The determination of the target intermediate frequency coefficient of each target sub-image block is specifically as follows: Obtain the image block to which the target sub-image block belongs, and perform downsampling to obtain an image block of the same size as the target sub-image block; Performing discrete cosine transform on the downsampled image block to obtain a DCT coefficient matrix of the downsampled image block; Obtain the positions of the two maximum values in the intermediate frequency region of the DCT coefficient matrix of the downsampled image block; The positions of the two maximum values are taken as the positions of the target intermediate frequency coefficients of the two target sub-image blocks.
9. The system according to claim 8, characterized in that The intermediate frequency region is determined as follows: The size n×n of the DCT coefficient matrix of the downsampled image block is obtained, and a k×k element region located in the central region of the DCT coefficient matrix of the downsampled image block is used as the intermediate frequency region, where k=n-1 or k=n-2.
10. The system according to claim 6, characterized in that The two intermediate frequency coefficients are adjusted so that the difference between the two intermediate frequency coefficients is within the interval corresponding to the bits to be embedded, specifically: 2M intervals are pre-divided, where the intervals with even numbers are the intervals corresponding to 0, the intervals with odd numbers are the intervals corresponding to 0, and M is a positive integer greater than or equal to 2; Calculate the difference between the target intermediate frequency coefficients of the two target sub-image blocks; If the bit to be embedded is 0, find an interval closest to the difference and with an even number, calculate the middle value of the found interval, and adjust one or two of the target intermediate frequency coefficients of the two target sub-image blocks so that the difference between the two is the middle value; If the bit to be embedded is 1, find the interval closest to the difference and with an odd sequence number, calculate the middle value of the found interval, and adjust one or two of the target intermediate frequency coefficients of the two target sub-image blocks so that the difference between the two is the middle value.
Citation Information
Patent Citations
Color image watermark embedding method, detection method and system
CN110232650A
Method and device for processing and extracting image watermark information
CN118379177A
Method and apparatus for detecting image copy of content base
JP2004007552A