CN113822784A - Image processing method and device - Google Patents

Image processing method and device Download PDF

Info

Publication number
CN113822784A
CN113822784A CN202110765849.8A CN202110765849A CN113822784A CN 113822784 A CN113822784 A CN 113822784A CN 202110765849 A CN202110765849 A CN 202110765849A CN 113822784 A CN113822784 A CN 113822784A
Authority
CN
China
Prior art keywords
watermark
target
lightness
image
brightness
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202110765849.8A
Other languages
Chinese (zh)
Inventor
吴雪蕾
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN202110765849.8A priority Critical patent/CN113822784A/en
Publication of CN113822784A publication Critical patent/CN113822784A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T1/00General purpose image data processing
    • G06T1/0021Image watermarking
    • G06T1/0028Adaptive watermarking, e.g. Human Visual System [HVS]-based watermarking
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T11/002D [Two Dimensional] image generation
    • G06T11/60Editing figures and text; Combining figures or text

Abstract

The embodiment of the invention discloses an image processing method and a device, wherein the method comprises the following steps: when a trigger event for matching and superposing an image to be processed and a target watermark is responded, a target area for displaying the target watermark in the image to be processed is obtained, and the brightness of the target area is obtained; acquiring a reference watermark lightness matched with the lightness of the target area based on a negative correlation between the image lightness and the watermark lightness; and if the current watermark lightness of the target watermark is not matched with the reference watermark lightness, adjusting the current watermark lightness of the target watermark according to the reference lightness. By adopting the embodiment of the invention, the display effect between the image and the watermark is improved.

Description

Image processing method and device
Technical Field
The present application relates to the field of image processing, and in particular, to an image processing method and apparatus.
Background
The Watermark refers specifically to a Digital Watermark (Digital Watermark), which is a technology for embedding a specific Digital signal into a Digital product to protect the copyright or integrity of the Digital product. Based on the characteristic of the watermark, the card-punching watermark is generated at the right moment, the card-punching watermark is the main characteristic of various watermark cameras which are popular in the market at present, and a user can condition various required information on an image according to the own requirements by using the card-punching watermark, such as geographic position, weather, mood, current time, ambient sound decibel and the like. Each type of information can correspond to a type of card-punching watermark, such as a time watermark for adding time information, a place watermark for adding place information, a weather watermark for adding weather information, and a brand watermark for adding brand information.
Although the existing watermark card printing technology is powerful, the user still needs to be very troublesome to select the watermark after shooting the image: matching the shot image with a favorite watermark, the effect of overlapping and displaying the image and the watermark may not be good, and the effect of the same watermark appearing on different images is different. For designers, sometimes a watermark with a high style is designed, which has an ideal effect on a specific background picture, but when the watermark is used by a user, the effect of matching other background pictures is not satisfactory. Therefore, in the field of image processing, matching and superimposing of watermarks and images is one of the hot issues in research.
Disclosure of Invention
The embodiment of the invention provides an image processing method, device and equipment, which can ensure that an image to be processed is matched and superposed with a target watermark on the image to be processed, and improve the superposition display effect between the image and the watermark.
In one aspect, an embodiment of the present invention provides an image processing method, including:
when a trigger event for matching and superposing an image to be processed and a target watermark is responded, a target area for displaying the target watermark in the image to be processed is obtained, and the brightness of the target area is obtained;
acquiring a reference watermark lightness matched with the lightness of the target area based on a negative correlation between the image lightness and the watermark lightness;
and if the current watermark lightness of the target watermark is not matched with the reference watermark lightness, adjusting the current watermark lightness of the target watermark according to the reference lightness.
In one aspect, an embodiment of the present invention provides an image apparatus, including:
the device comprises an acquisition unit, a comparison unit and a display unit, wherein the acquisition unit is used for acquiring a target area used for displaying a target watermark in an image to be processed and acquiring the brightness of the target area when responding to a trigger event for matching and superposing the image to be processed and the target watermark;
the acquiring unit is further used for acquiring a reference watermark lightness matched with the lightness of the target area based on a negative correlation between the image lightness and the watermark lightness;
and the adjusting unit is used for adjusting the current watermark lightness of the target watermark according to the reference lightness if the current watermark lightness of the target watermark is not matched with the reference watermark lightness.
In one aspect, an embodiment of the present invention provides an image processing apparatus, including:
a processor adapted to implement one or more computer programs; and the number of the first and second groups,
a computer storage medium storing one or more computer programs adapted to be loaded by the processor and to perform the steps of:
when a trigger event for matching and superposing an image to be processed and a target watermark is responded, a target area for displaying the target watermark in the image to be processed is obtained, and the brightness of the target area is obtained;
acquiring a reference watermark lightness matched with the lightness of the target area based on a negative correlation between the image lightness and the watermark lightness;
and if the current watermark lightness of the target watermark is not matched with the reference watermark lightness, adjusting the current watermark lightness of the target watermark according to the reference lightness.
In one aspect, an embodiment of the present invention provides a computer storage medium, where a computer program is stored in the computer storage medium, and when executed by a processor, the computer program is configured to perform the following steps:
when a trigger event for matching and superposing an image to be processed and a target watermark is responded, a target area for displaying the target watermark in the image to be processed is obtained, and the brightness of the target area is obtained;
acquiring a reference watermark lightness matched with the lightness of the target area based on a negative correlation between the image lightness and the watermark lightness;
and if the current watermark lightness of the target watermark is not matched with the reference watermark lightness, adjusting the current watermark lightness of the target watermark according to the reference lightness.
In one aspect, an embodiment of the present invention provides a computer program product or a computer program, where the computer program product includes a computer program, and the computer program is stored in a computer storage medium; a processor of the image processing apparatus reads the computer program from the computer storage medium, the processor executing the computer program, so that the image processing apparatus performs the steps of:
when a trigger event for matching and superposing an image to be processed and a target watermark is responded, a target area for displaying the target watermark in the image to be processed is obtained, and the brightness of the target area is obtained;
acquiring a reference watermark lightness matched with the lightness of the target area based on a negative correlation between the image lightness and the watermark lightness;
and if the current watermark lightness of the target watermark is not matched with the reference watermark lightness, adjusting the current watermark lightness of the target watermark according to the reference lightness.
In the embodiment of the invention, when a trigger event for matching, superposing and displaying the image to be processed and the target watermark is required, a target area for displaying the target watermark in the image to be processed is obtained, and the brightness of the target area is calculated; further, acquiring a reference watermark lightness matched with the lightness of the target area based on the negative correlation between the image lightness and the watermark lightness; and if the current watermark lightness of the target watermark is not matched with the reference watermark lightness, adjusting the current watermark lightness of the target watermark according to the reference watermark lightness. In the image processing process, the reference watermark lightness is determined according to the negative correlation between the image lightness and the watermark lightness, is not determined by the user according to the self aesthetics or experience, has certain objectivity, and is not influenced by different users with different aesthetics or experience; in addition, once the watermark lightness of the target watermark displayed in the target area is not matched with the reference watermark lightness, the current watermark lightness of the target watermark is adjusted based on the reference watermark lightness, so that the adaptability between the target watermark and the image to be processed can be ensured, and the effect of the target watermark which is displayed on the image to be processed in an overlapping manner is improved.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings needed to be used in the description of the embodiments are briefly introduced below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts.
Fig. 1 is a schematic diagram of adding a watermark to an image to be processed according to an embodiment of the present invention;
FIG. 2 is a schematic diagram of an image processing system according to an embodiment of the present invention;
fig. 3a is a schematic diagram illustrating a relationship between a watermark, watermark text, and a watermark text shadow according to an embodiment of the present invention;
FIG. 3b is a flow chart of adding a watermark to a processed image according to an embodiment of the present invention;
FIG. 4 is a flowchart illustrating an image processing method according to an embodiment of the present invention;
fig. 5a is a schematic diagram of a target watermark provided by an embodiment of the present invention;
fig. 5b is a schematic diagram illustrating an effect of displaying a target watermark on different images to be processed according to an embodiment of the present invention;
FIG. 6 is a flow chart of another image processing method according to an embodiment of the present invention;
FIG. 7 is a flowchart of another image processing method according to an embodiment of the present invention;
FIG. 8 is a schematic structural diagram of an image processing apparatus according to an embodiment of the present invention;
fig. 9 is a schematic structural diagram of an image processing apparatus according to an embodiment of the present invention.
Detailed Description
The technical solution in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention.
The card-punching watermark is widely applied by users as the main characteristic of various watermark cameras, is rich in watermark types, supports multiple functions of position movement, angle rotation, size scaling, transparency adjustment, color switching and the like, can be networked to prevent tampering in time, can be automatically matched in places according to the positions of the users, supports personal icons and other users to automatically define operations, and is beneficial to the users to realize one-key recording life.
The same card-punching watermark is superimposed on different images to show different effects, for example, one card-punching watermark comprises white watermark characters, and the superimposition of the white characters on a large-area dark image is artistic, but if an image shot by a user is surrounded by a white tone, or the light is too strong, the watermark characters of the card-punching watermark are not clear. Therefore, in order to make the card watermark better available to the user, the problem that needs to be solved is that the card watermark is displayed on the corresponding image in an adaptive manner in an overlapping manner.
In the embodiment of the invention, when the above problems are researched, two schemes for matching and superposing the card-punching watermark and the image are provided: (for simplicity of description, the card watermark will be collectively referred to as the watermark in the following):
the first method comprises the following steps: the user modifies the attribute information of the target watermark according to the image information of the image to be processed (any image selected by the user for adding the target watermark, the target watermark refers to any one or more of watermarks), the attribute information of the target watermark may include the font attributes of watermark characters such as font size, thickness, color and the like, and the attribute information of the target watermark may also include the position information of the target watermark. For example, in fig. 1, a user wants to add an object watermark to an object region 102 of an image 101 to be processed, where the object region 102 is an image of a white cloud, and the object watermark includes watermark words "watermark camera has ensured time not to be tampered with", and the watermark words are also white, so that the object watermark is superimposed on the object region, which causes the watermark words to be displayed unobviously as shown in fig. 1, and 103 in fig. 1 indicates the watermark words. At this time, the user can clearly see the watermark text on the image to be processed by modifying the color of the watermark text, for example, modifying the color of the watermark text to black.
And the second method comprises the following steps: and adaptively adjusting the brightness of the target watermark according to the brightness of a target area for displaying the target watermark in the image to be processed so as to adapt the target watermark and the target area. Specifically, when the image to be processed and the target watermark need to be matched and superposed, a target area for displaying the target watermark in the image to be processed is obtained, and the brightness of the target area is obtained; in previous research, the lower the brightness of an image, the more obvious the watermark is displayed on the image, and therefore, the higher the brightness of the watermark can be; conversely, the higher the lightness of the image, the more blurred the watermark, especially the white watermark text in the watermark, and the lower the lightness of the watermark at this time, in summary, the negative correlation between the lightness of the image and the lightness of the watermark is present, and in brief, the negative correlation between the lightness of the image and the lightness of the watermark can be understood as the sum of the lightness of the image and the lightness of the watermark is equal to a constant; further, acquiring a reference watermark lightness matched with the lightness of the target area based on the negative correlation between the image lightness and the watermark lightness; if the current watermark lightness of the target watermark is not matched with the reference watermark lightness, the current watermark lightness of the target watermark is adjusted according to the reference watermark lightness so that the adjusted target watermark lightness is matched with the reference watermark lightness, and the target watermark lightness is matched with the reference watermark lightness, so that the target watermark has a better display effect when displayed in a target area, and therefore, the matching and the superposition of the image to be processed and the target watermark are realized.
Compared with the two schemes, the first scheme greatly reduces the style of the watermark by modifying the font property of the watermark characters, limits the exertion of a watermark designer, challenges the aesthetic level of a user by modifying the color of the watermark characters, reduces the convenience of adding the watermark, and simultaneously destroys the original design effect of the watermark.
In the second scheme, the reference watermark brightness is determined according to the negative correlation between the image brightness and the watermark brightness, is not determined by the user according to the self aesthetic value or experience, has certain objectivity, and is not influenced by different users with different aesthetic values or different experiences; in addition, once the watermark lightness of the target watermark displayed in the target area is not matched with the reference watermark lightness, the current watermark lightness of the target watermark is adjusted based on the reference watermark lightness, so that the adaptability between the target watermark and the image to be processed can be ensured, and the effect of the target watermark which is displayed on the image to be processed in an overlapping manner is improved. It can be seen that the second solution is more preferable, and therefore the second solution will be described with emphasis in the following embodiments of the present invention.
Based on the second scheme, an embodiment of the present invention provides an image processing system, and referring to fig. 2, a schematic structural diagram of the image processing system provided in the embodiment of the present invention is shown. The image processing system illustrated in fig. 2 may include an image processing device 201 and a watermark management device 202, where both the image processing device 201 and the watermark management device 202 may be terminals, such as a smart phone, a tablet computer, a laptop computer, a desktop computer, a smart speaker, a smart watch, a smart car-mounted device, and the like; alternatively, the image processing apparatus 201 and the watermark management apparatus 202 may both be servers, such as independent physical servers, or may be a server cluster or a distributed system formed by a plurality of physical servers, or may be cloud servers that provide basic cloud computing services such as cloud services, a cloud database, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDNs, and big data and artificial intelligence platforms.
The watermark management device 202 is used for storing and managing various types of watermarks, and for the sake of security, the watermarks stored in the watermark management device 202 may be stored in a block chain, where the block chain is a novel application mode of computer technologies such as distributed data storage, peer-to-peer transmission, a consensus mechanism, and an encryption algorithm, and the data stored in the block chain has non-tamper-property. The security of the watermark can be fully ensured due to the non-tampering property of the block chain. Some of the watermark correlation concepts are described in detail below:
a watermark may include watermark attribute information and watermark-related information, wherein the watermark attribute information may include title, background map, position, height, width, movable range, layout, and version number; wherein, the title can be displayed on the background picture; the watermark-related information may include under what circumstances the watermark appears, such as historical data loading, being displayed after refresh, and being present under adaptive layout, etc.;
the layout of a watermark may include one or more watermark characters, a watermark character may include watermark character attribute information and watermark character related information, and the watermark character attribute information may include whether the watermark character is editable, and the position and height of the watermark character. Width, shading, text size, and text color, etc.; the watermark text related information may include setting a color gamut offset, setting a sensitivity of a shadow lightness adjustment, and a shadow color system, and the like.
As an attribute of the watermark text, the attribute of the watermark text shadow may include: shadow color, shadow radius, shadow offset, and shadow feathering switch, etc.; the information related to the watermark text shadow may include a modified color, a modified radius, and a modified offset. The relationship between the watermark, the watermark text and the watermark text shadow can be as shown in fig. 3 a.
The watermarks stored in the watermark management device 202 are stored in the form of original watermark files, which are usually stored in json format, and then files in wmc (a file format for ios system devices) format or dat (a file format for android system devices) format are generated by using encryption tools.
In one embodiment, the image processing apparatus 201 may obtain the target watermark from the watermark management apparatus 202, and specifically, after the watermark management apparatus 202 receives the request for the target watermark from the image processing apparatus 201, the encrypted watermark original file in the corresponding format may be sent to the image processing apparatus 201. The image processing device 201 analyzes the file returned by the watermark management device 202, the file needs to be decrypted firstly, and then the file is analyzed into a json object through a known watermark format, wherein attributes in the json object correspond to attributes of the watermark one by one; a watermark is generated based on the json object.
In other embodiments, the target watermark resource may be stored locally in the image processing apparatus 201, and when the target watermark needs to be added to the image to be processed, the image processing apparatus 201 may add the target watermark from the local storage of the image processing apparatus 201. Based on the above, a flowchart of adding a watermark on an image to be processed by the image processing apparatus 202 can be seen in fig. 3 b. Firstly, determining that a user wants to add a target watermark to an image to be processed according to selection operation of the user, and then acquiring a file path of the target watermark by the image processing device 201; judging whether the file exists or not, and if not, giving up rendering the watermark; and if so, acquiring a target watermark file, and then decrypting and analyzing the target file to generate the target watermark.
After the image processing apparatus 201 adds the target watermark to the image to be processed, it may be that the target watermark is not matched with the image to be processed, for example, the image to be processed is mostly white, and the target watermark is also mainly white, so that the target watermark is not displayed obviously on the image to be processed. Therefore, when a trigger event for matching and superimposing the image to be processed and the target watermark is detected (for example, it is detected that the target watermark is loaded on the line of the image to be processed, or the user inputs a watermark optimization operation on the image to be processed, or the user adjusts the position of the target watermark, or the like), the image processing apparatus 201 obtains a target area for displaying the target watermark in the image to be processed, and obtains the brightness of the target area, and further obtains a reference watermark brightness matching the brightness of the image area based on a negative correlation between the image brightness and the watermark brightness (that is, the sum of the image brightness and the watermark brightness is equal to a constant, and this relationship is generally referred to as a negative correlation); if the current watermark lightness of the target watermark is not matched with the reference watermark lightness, the current watermark lightness of the target watermark is adjusted according to the reference watermark lightness, so that the image to be processed and the target watermark can be ensured to be matched and superposed, and the display effect of the target watermark on the image to be processed is improved.
Referring to the image processing system, an embodiment of the invention provides an image processing method. Fig. 4 is a schematic flow chart of an image processing method according to an embodiment of the present invention. The image processing method described in fig. 4 may be executed by an image processing apparatus, and may specifically be executed by a processor of the image processing apparatus. The image processing method shown in fig. 4 may include the steps of:
step S401, when a trigger event for matching and superposing the image to be processed and the target watermark is responded, a target area for displaying the target watermark on the image to be processed is obtained, and the brightness of the target area is obtained.
The matching superposition of the image to be processed and the target watermark means that when the target watermark is superposed and displayed on the image to be processed, the target watermark can be ensured to have a better display effect, if the white color of the image to be processed is too much, the target watermark is also too much, and if the image to be processed and the target watermark can be matched and superposed, the target watermark can be clearly displayed on the image to be processed.
The target watermark may be any one of the selected card-punching watermarks in the card-punching watermark selection list page of the user operation interface, and the target watermark may include watermark characters and a watermark background image (that is, a background included in the aforementioned attributes of the target watermark), wherein the watermark characters may be divided into first type watermark characters and second type watermark characters according to whether the watermark characters are displayed on the watermark background image, and the first type watermark characters refer to watermark characters which are not displayed on the watermark background image but are directly displayed on the image to be processed; the second type of watermark characters refers to watermark characters displayed on the image to be processed. The second type of watermark text may be a title in the attribute information of the target watermark as mentioned above. In other words, the first type of watermark characters in the target watermark are directly displayed on the image to be processed by taking the image to be processed as the background; the second type of watermark characters are displayed on the watermark background image by taking the watermark background image as the background. For example, referring to fig. 5a, a schematic diagram of a target watermark provided in the embodiment of the present invention is shown, where 501 denotes a watermark background diagram, and "copy record" and 502 both denote watermark texts, but as can be seen from fig. 5a, the watermark text "copy record" is displayed on the watermark background diagram 501, so that the "copy text" belongs to the second type of watermark text, that is, the "copy watermark" belongs to a title of the target watermark, and the title of the target watermark is used to represent what type of watermark the target watermark belongs to, which means that the target watermark is the watermark belonging to the copy type in fig. 5 a. The watermark text 502 is not displayed on the watermark background image, and if the target watermark is superimposed with the image to be processed, the watermark text 502 directly takes the image to be processed as the background, so that the watermark text 502 belongs to the first class of watermark text.
In one embodiment, the trigger event for matching and superimposing the image to be processed and the target watermark mentioned in step S401 may include: detecting an adding operation of adding a target watermark in an image to be processed, for example, an image processing device displays a user operation interface of a shooting device with a card-punching watermark function, a user obtains the image to be processed through shooting through the user operation interface, then a target watermark is selected from a card-punching watermark selection list of the user operation interface, and at the moment, the adding operation of adding the target watermark in the image to be processed is determined and detected; for another example, before shooting the image to be processed, the user selects the target watermark from the card-punching watermark selection list, and when the user is detected to shoot the image to be processed through the user operation interface, the adding operation of adding the target watermark in the image to be processed is determined to be detected.
In other embodiments, the triggering event for matching and superimposing the image to be processed and the target watermark may further include: and when the target watermark is added in the image to be processed, detecting the change operation of the attribute information of the target watermark. It should be understood that when a target watermark exists in an image to be processed, the target watermark and the image to be processed are already adjusted to be in a matching and overlaying state, and at this time, once any one of the target watermark and the image to be processed is transformed, the matching and overlaying state between the target watermark and the image to be processed is affected, and the image processing device is required to perform relevant processing of matching and overlaying the target watermark and the image to be processed.
Optionally, the attribute information of the target watermark may include a color, a position, and a size, and the operation of modifying the target watermark may include any one or more of a color modification of the target watermark, a position shift operation of the target watermark, and a scaling operation of the size of the target watermark. For example, the target watermark is moved from the position at the lower left corner of the image to be processed to the position at the upper right corner of the image to be processed. As another example, the size of the target watermark is scaled to 2 times the original size, or to 1/2.
As can be seen from the foregoing, the target watermark may include the first type of watermark text, the second type of watermark text, and the watermark background image, and therefore, the color of the target watermark may include at least one of the following: the color of the first type of watermark characters, the color of the second type of watermark characters and the color of the watermark background image. The modification of the color of the target watermark may include modification of any one of the colors of the target watermark, such as modification of the color of the first type of watermark text, modification of the color of the second type of watermark text, or modification of the color of the watermark background image.
It should be understood that the target watermark is superimposed on a certain area of the image to be processed, rather than being completely covered on the image to be processed, so that after a trigger event for matching and superimposing the image to be processed and the target watermark is detected, a target area for superimposing and displaying the target watermark in the image to be processed is obtained. In general, setting initial position information of the upper left corner of a target watermark in an image to be processed and initial size information of the target watermark in advance; if the target watermark is superposed on the image to be processed, the position information and the size information are not changed, and the default is taken as the main point; then, obtaining a target area for displaying the target watermark in the image to be processed may include: and determining a position in the image to be processed according to the initial position information, then determining an area from the position according to the size information of the target watermark, and determining the area as a target area.
In other embodiments, after the target watermark is added to the to-be-processed image, the user performs a moving operation and a scaling operation on the target watermark, and then acquiring a target area for displaying the target watermark in the to-be-processed image includes: presetting the initial position information based on the moving operation to obtain first position information of the target watermark, and presetting the initial position information based on the zooming operation to obtain second size information of the target watermark; starting from the position indicated by the first position information on the image to be processed, determining an area according to the first size information, wherein the area is the target area.
After the target area is determined on the image to be processed, the brightness of the target area is obtained, so that the brightness of the target watermark is adjusted based on the brightness of the target area to match the brightness of the target area with the brightness of the target watermark, and thus the matching and superposition of the image to be processed and the target watermark are realized. Brightness is the feeling of the eyes to the brightness of light sources and objects, and is a visual experience mainly determined by the intensity of light. Generally, the stronger the light, the brighter it looks, i.e., the higher the lightness; the weaker the light, the darker, i.e., the lower the brightness, the more. Brightness may also refer to the shade of a color. The shade may be different for colors of the same hue. For example, magenta and pink both contain red, but the former appears dark and the latter appears bright. Currently, lightness is often described using LAB (a less common color space) that is built on the basis of international standards for color metrics established by the international commission on illumination (CIE) in 1931. In 1976, the modified CIELab was formally named CIELab. It is a device-independent color system, and is also a color system based on physiological characteristics. This means that it describes the human visual perception digitally. The L component in the Lab color space is used for representing the brightness of the pixel, namely the lightness, the value range is [0,100], and the L component represents pure black to pure white; a represents the range from red to green, and the value range is [127, -128 ]; b represents the range from yellow to blue, and the value range is [127, -128 ].
Since it is known that the brightness of the target area is related to the pixels, the brightness of the target area is determined based on the color information of the plurality of pixels in the target area. In one embodiment, determining the brightness of the target area comprises: acquiring color information of a plurality of pixels included in a target area; calculating the brightness of any pixel according to the color information and brightness determination rule of any pixel; the brightness of the target area is obtained by performing a predetermined operation, such as an averaging operation, on the brightness of the plurality of pixels. For example, the color information of any pixel includes R, G, and B, and the brightness of any pixel can be obtained by the following formula:
Figure BDA0003150480560000101
wherein, L represents the lightness of any pixel, and the value range of L is between 0 and 1.
Step S402, acquiring a reference watermark lightness matched with the lightness of the target area based on the negative correlation between the image lightness and the watermark lightness.
As can be seen from the foregoing description, the lower the brightness of the area for displaying the watermark in an image, the more obvious the watermark is displayed thereon, and therefore, the higher the brightness of the watermark can be at this time; conversely, the higher the lightness of the area of an image in which the watermark is displayed, the more blurred the watermark is displayed thereon, and thus the lower the lightness of the watermark may be. Therefore, the brightness of the target area in the image to be processed and the brightness of the watermark present a negative correlation, so that in the embodiment of the present invention, enabling the target watermark and the image to be processed to be matched and superimposed actually means that the brightness of the target watermark matches the brightness of the target area in the image to be processed, so that displaying the target watermark on the target area of the image to be processed has a better display effect, and is more beneficial for a user to view.
Therefore, after the lightness of the target area is obtained in step S401, a reference watermark lightness matching the lightness of the target area can be calculated in step S402 based on the negative correlation between the lightness of the target area and the watermark lightness, so that the current watermark lightness of the target watermark can be adjusted subsequently based on the reference watermark lightness.
In a specific implementation, the reference watermark lightness matched with the lightness of the target area is obtained by the following formula: l1 ═ 1- α L2; wherein L1 represents the lightness of the target watermark, L2 represents the lightness of the target area, α is a correlation coefficient, and the value may be between 0 and 1, and is usually 1.
In one embodiment, as can be seen from the foregoing description, the target watermark may include a watermark background image and a first type of watermark text, and a second type of watermark text, where the first type of watermark text may be displayed on the image to be processed after being shaded, or may be displayed on the image to be processed without being shaded. Particularly under what kind of scene the shadow is added, and what the shadow brightness is, it is difficult to control in the prior art. For example, fig. 5b shows the display effect of the target watermark shown in fig. 5a on three different to- be-processed images 512, 513, and 514, respectively, where the first type of watermark text in the target watermark 514 is added with a shadow, and as can be seen from the to-be-processed image 514, the default added shadow affects the overall effect display in the bright to-be-processed image area; the first type of watermark characters in the image to be processed 512 are not added with shadows, and can be seen from the image to be processed 512, if the first type of watermark characters are not added with shadows by default, the target watermark can not be seen clearly on the image to be processed with a large number of white and bright parts, and the character display effect is influenced.
The image processing method shown in the embodiment of the invention in FIG. 4 can more accurately control the number of the watermark character shadow lightness of the first type of watermark characters which should be set under different conditions. In one embodiment, the matching and superimposing of the image to be processed and the target watermark may refer to matching and superimposing a first sub-region, which displays a first type of watermark characters, on the target region of the image to be processed and the first type of watermark characters, where the first sub-region refers to a region occupied by the first type of watermark characters in the target region, and the matching and superimposing of the first sub-region and the first type of watermark characters may refer to matching of lightness of the first sub-region and shadow lightness of the first type of watermark characters.
In another embodiment, the watermark background image of the same target watermark, which shows different effects in different images to be processed, may also be affected by the brightness of the area in which the watermark background image is displayed. Therefore, in this embodiment, the matching and overlapping of the image to be processed and the target watermark may refer to the matching and overlapping of the second sub-region used for displaying the watermark background image in the target region and the watermark background image, and the matching and overlapping of the second sub-region and the watermark background image may refer to the matching and overlapping of the lightness of the second sub-region and the lightness of the watermark background image.
It should be understood that, in the target watermark, a relationship between the initial position information of the first type of watermark text and the initial position information of the target watermark and a relationship between the initial size information of the first type of watermark text and the initial size information of the target watermark are default, for example, it is preset that a specified relationship is satisfied between the upper left corner coordinate of the first type of watermark text and the upper left corner coordinate of the target watermark, for example, the upper left corner coordinate of the first type of watermark text is equal to the upper left corner coordinate of the target watermark of 1/2, so that the first sub-region occupied by the first type of watermark text can be determined from the target region according to the initial position information and the initial watermark information of the target watermark, and the position relationship and the size relationship between the target watermark text and the first type of watermark text. And similarly, determining the second sub-area occupied by the watermark background image from the target area according to the initial position information and the initial size information of the target watermark and the position relation and the size relation between the target watermark and the watermark background image.
Step S403, if the current watermark lightness of the target watermark is not matched with the reference watermark lightness, adjusting the current watermark lightness of the target watermark according to the reference watermark lightness.
In one embodiment, the reference watermark lightness may comprise a reference watermark text lightness, and the current watermark lightness of the target watermark not matching the reference watermark lightness may comprise: the step S403 of adjusting the current watermark lightness of the target watermark according to the reference watermark lightness may include: and adjusting the current watermark character shadow lightness of the first type of watermark characters to the reference watermark character shadow lightness.
In another embodiment, the reference watermark lightness may further include a reference watermark background picture lightness. The mismatch between the current watermark lightness of the target watermark and the reference watermark lightness means that the current lightness of the watermark background image is not matched with the reference watermark background lightness, and the current watermark lightness of the target watermark is adjusted according to the reference watermark lightness, and the method comprises the following steps: adjusting a current lightness of the watermark background map to the reference watermark background lightness.
It should be understood that, before adjusting the current lightness of the watermark background image, the lightness of the watermark background image in the target watermark should be matched with the watermark character shadow lightness of the second type of watermark characters displayed on the watermark background image, and if the reference watermark background lightness is not matched with the current watermark character shadow lightness of the second type of watermark characters after adjusting the lightness of the watermark background image to the reference watermark background lightness, the current watermark character shadow lightness of the second type of watermark characters is adjusted according to the preset relationship between the watermark background image and the watermark character shadow lightness of the second type of watermark characters.
In the embodiment of the invention, when a trigger event for matching, superposing and displaying the image to be processed and the target watermark is required, a target area for displaying the target watermark in the image to be processed is obtained, and the brightness of the target area is calculated; further, acquiring a reference watermark lightness matched with the lightness of the target area based on the negative correlation between the image lightness and the watermark lightness; and if the current watermark lightness of the target watermark is not matched with the reference watermark lightness, adjusting the current watermark lightness of the target watermark according to the reference watermark lightness. In the image processing process, the reference watermark lightness is determined according to the negative correlation between the image lightness and the watermark lightness, is not determined by the user according to the self aesthetics or experience, has certain objectivity, and is not influenced by different users with different aesthetics or experience; in addition, once the watermark lightness of the target watermark displayed in the target area is not matched with the reference watermark lightness, the current watermark lightness of the target watermark is adjusted based on the reference watermark lightness, so that the adaptability between the target watermark and the image to be processed can be ensured, and the effect of the target watermark which is displayed on the image to be processed in an overlapping manner is improved.
Based on the above embodiment of the image processing method, another image processing method is provided in the embodiment of the present invention, and fig. 6 is a flowchart illustrating another image processing method provided in the embodiment of the present invention. The image processing method shown in fig. 6 may be executed by an image processing apparatus, and may specifically be executed by a processor of the image processing apparatus, and the image processing apparatus shown in fig. 6 may include the following steps:
step S601, when the target watermark is added in the image to be processed, if the change operation of the attribute information of the target watermark is detected, acquiring a first sub-area occupied by a first type of watermark characters in the target watermark in the image to be processed.
Optionally, the obtaining a first sub-region occupied by the first type of watermark characters in the target watermark in the image to be processed may include: determining initial position information of a target watermark and initial size information of the target watermark in an image to be processed; acquiring first position information and first size information of a target watermark in an image to be processed based on a change operation, initial position information of the target watermark and initial size information of the target watermark; and determining the target position information and the target size information of the first type of watermark characters based on the first position information and the first size information of the target watermark.
The attribute information of the target watermark may include a position and a size, and the modification operation on the attribute information of the target watermark includes any one or more of a moving operation on the position of the target watermark and a scaling operation on the size of the target watermark.
Optionally, if the operation of modifying the attribute information of the target watermark includes a moving operation on the position of the target watermark and a scaling operation on the size of the target watermark, acquiring first position information and first size information of the target watermark in the image to be processed based on the modifying operation, the initial position information of the target watermark, and the initial size information of the target watermark, including: adding the initial position information and the offset generated by the moving operation to obtain new initial position information; scaling and adjusting the new initial position information based on the scaling corresponding to the scaling operation to obtain the target position information of the target watermark; and multiplying the scaling and the initial size information of the target watermark to obtain first size information.
For example, assume that the offset generated by the move operation is denoted as movePosObject watermarking(x, y), initial position information of the target watermark is expressed as PosObject watermarking(x, y), then the new initial position information may be expressed as PosObject watermarking(x,y)+movePosObject watermarking(x, y). After the moving operation is performed, if the target watermark is scaled, the new initial position information is also changed, and the new position information is scaled according to the scaling operation to obtain the first position information of the target watermark.
The shifting operation does not affect the initial size information of the target watermark, but the scaling operation is performed, so that when determining the first size information, only the initial size information of the target watermark needs to be multiplied by the scaling ratio.
Further, after the first position information and the first size information of the target watermark are determined, the target position information and the target size information of the first type of watermark characters can be determined based on the first position information and the first size information of the target watermark. As an embodiment, determining target position information and target size information of a first type of watermark text based on first position information and first size information of a target watermark includes: performing preset operation on the first position information based on the position relation between the target watermark and the first type of watermark characters to obtain target position information of the first type of watermark characters; and performing preset operation on the first size information based on the size relationship between the target watermark and the first type of watermark characters to obtain the target size information of the first type of watermark characters.
In brief, a preset position relationship exists between the target watermark and the first type of watermark characters, for example, the first position information of the target watermark indicates that the coordinates of the upper left corner of the target watermark are (0, y), and the first size information of the size target watermark indicates that the target watermark is a rectangle with the length of x and the width of y; the preset position relation between the target watermark and the first type of watermark characters is as follows: the upper left corner of the first type of watermark characters has the same horizontal coordinate as the upper left corner of the target watermark, and the vertical coordinate of the first type of watermark characters is equal to half of the vertical coordinate of the upper left corner of the target watermark, so that the target position information of the first type of watermark characters indicates that the upper left corner coordinate of the first type of watermark characters is (1, 1/2 y).
Similarly, a preset size relationship exists between the target watermark and the first type of watermark characters, for example, the first type of watermark characters and the target watermark are both rectangles, the length of the first type of watermark characters is equal to x times of the length of the target watermark, x is an integer greater than 0, for example, when the value of x is 1, the length of the first type of watermark characters is equal to the length of the target watermark, and when the value of x is 1/2, the length of the first type of watermark characters is equal to half of the length of the target watermark; the width of the first type of watermark text is equal to y times of the width of the target watermark, and the value of y can be an integer larger than 0.
As another optional embodiment, determining the target position information and the target size information of the first type of watermark text based on the first position information and the first size information of the target watermark includes: acquiring initial position information of the first type of watermark characters and initial size information of the first type of watermark characters; multiplying the initial position information of the first type of watermark characters by the scaling ratio, and adding the operation result and the first position information to obtain the target position information of the first type of watermark characters; and multiplying the initial size information of the first type of watermark characters by the scaling ratio to obtain the target size information of the first type of watermark characters.
For example, the first position information of the target watermark is expressed as PosObject watermarking(x, y), the scaling is represented as k, and the initial position information of the first type watermark characters is represented as PosWatermark character(x1, y1), firstThe target position information of one type of text is expressed as PosWatermark character(x, y), then PosWatermark character(x, y) can be represented by the following formula: posWatermark character(x,y)=PosWatermark character(x1, y1) × k scaling factor + PosObject watermarking(x,y)
Step S602, obtaining a sensitivity parameter for adjusting the watermark text shadow lightness of the first type of watermark text, and calculating the lightness of the first sub-region based on the sensitivity parameter and the lightness determination rule.
In general, because the length of the first type of watermark characters is not fixed, severe changes in hue and lightness may occur in the first sub-region occupied by the watermark characters, if the lightness of the first sub-region is calculated, only a way of averaging the lightness of all pixels is adopted, which may cause the lightness of the shadow of the finally determined reference watermark character to be higher, and in the place with high lightness in the first sub-region, strong contrast cannot be formed, and the first type of watermark characters cannot be highlighted.
In order to solve the above problem, one method is to divide the first sub-region into a plurality of image blocks when calculating the brightness of the first sub-region, calculate the brightness of each image block separately, and then take the highest brightness as the brightness of the first sub-region. Such an approach may improve the accuracy of the determined reference watermark text shadow lightness, but may affect performance.
In order to balance the two modes, the embodiment of the invention leads out the sensitivity parameters and provides a sensitivity parameter interface, and controls the accuracy of the determined reference watermark character shadow lightness by adjusting the sensitivity parameter class. Meeting different performance requirements.
Based on this, the brightness of the first sub-region is calculated based on the sensitivity parameter and the brightness determination rule in the embodiment of the present invention. In one embodiment, computing the brightness of the first sub-region based on the sensitivity participation and brightness determination rules comprises: if the sensitivity parameter is a first numerical value, acquiring color information of a plurality of pixels included in the first sub-region; calculating the brightness of any pixel according to the color information of the pixel and the brightness determination rule; and carrying out preset operation on the brightness of the plurality of pixels to obtain the brightness of the first sub-area. The first value may be 1 and a sensitivity parameter of 1 indicates that the brightness is calculated for the first sub-region as a whole. Specifically, the brightness of each pixel in the first sub-region may be solved first, and then the brightness of all the pixels is averaged, and the result of the operation is used as the brightness of the first sub-region.
In yet another embodiment, the calculating the brightness of the first sub-region based on the sensitivity parameter and the brightness determination rule comprises: if the sensitivity parameter is a second numerical value, dividing the first sub-area into N image blocks, wherein N is an integer greater than or equal to 1; calculating the lightness of the ith image block according to the color information of a plurality of pixels in the ith image block and the lightness determining rule, wherein i is an integer which is greater than or equal to 1 and less than or equal to N; determining brightness meeting a preset condition from brightness of the N image blocks as brightness of the first area. The second value may be any value such as 2, 3, 4, etc., and when the second value is 2, it means that the first sub-region is divided into two image blocks to solve the brightness of the first sub-region, and similarly, when the second value is 4, it means that the first sub-region is divided into 4 image blocks to solve the brightness of the first sub-region. The lightness meeting the preset condition may refer to the maximum lightness, or lightness greater than a certain lightness threshold.
Step S603, obtaining the reference watermark text shadow lightness matched with the lightness of the first sub-area based on the negative correlation between the image lightness and the watermark lightness.
The details included in this step have been described in the foregoing embodiments, and are not described herein again.
Step S604, if the current watermark text shadow lightness of the first type watermark text is not matched with the reference watermark text shadow lightness, adjusting the current watermark text shadow of the first type watermark text according to the reference watermark text shadow lightness.
In a specific implementation, if the current watermark text shadow lightness of the first type of watermark text is not matched with the reference watermark text shadow lightness, the current watermark text shadow lightness of the first type of watermark text can be adjusted to be the reference watermark text shadow lightness. After the watermark character shadow lightness of the first type of watermark characters is adjusted, further, the reference watermark character shadow lightness of the first type of watermark characters is converted into RGB color information according to the correlation between lightness and RGB color, and then the color indicated by the RGB color information is assigned to the color of the first type of watermark character shadow to complete rendering display. It is assumed that the relationship between the RGB color information and the reference watermark text shadow lightness can be expressed as: R-G-B-L-255, where L denotes the reference watermark text shading lightness, and R, G, and B denote color RGB color information.
To summarize, the image processing method shown in fig. 6 can be specifically represented by the flowchart 7, where when a trigger event that the image to be processed and the target watermark need to be matched and superimposed is detected, the image processing device calculates target position information and target size information of a first type of watermark text in the image to be processed, and intercepts a target area from the image to be processed based on the target position information and the target size information; then acquiring sensitivity parameters, and determining whether the target area needs to be cut or not according to the sensitivity parameters; if not, calculating the brightness of the target area as a whole; if the image is needed, the target area is cut into N image blocks based on the indication of the sensitivity parameters, and the brightness of each image block is calculated; then determining the brightness of the target area based on the brightness of the N image blocks; further, the reference watermark character shadow lightness matched with the lightness of the target area is calculated, and the first type of watermark characters are drawn based on the reference watermark character shadow lightness.
In the embodiment of the invention, the current watermark character shadow lightness of the first type of watermark characters is compared with the reference watermark character shadow lightness, and the current watermark character shadow lightness is automatically adjusted based on the reference watermark character shadow lightness under the condition that the current watermark character shadow lightness and the reference watermark character shadow lightness are not matched, so that the self-adaptive adjustment of the watermark character shadow is realized. The reference watermark character shadow lightness is matched with lightness of a first sub-area occupied by a first type of watermark characters in an image to be processed, the current watermark character shadow lightness of the first type of watermark characters is adjusted based on the reference watermark character shadow lightness, the adjusted watermark character shadow lightness of the first type of watermark characters and the first sub-area can be matched and superposed, namely when the first type of watermark characters are displayed in the first sub-area by the adjusted watermark character shadow lightness, the first type of watermark characters and the first sub-area have better contrast, and higher watermark character display effect can be ensured.
Based on the above-mentioned embodiment of the image processing method, an embodiment of the present invention provides an image processing apparatus. Fig. 8 is a schematic structural diagram of an image processing apparatus according to an embodiment of the present invention. The image processing apparatus shown in fig. 8 may operate as follows:
an obtaining unit 801, configured to, in response to a trigger event that matches and superimposes an image to be processed and a target watermark, obtain a target area in the image to be processed, where the target area is used to display the target watermark, and obtain brightness of the target area;
the obtaining unit 801 is further configured to obtain a reference watermark lightness matching the lightness of the target area based on a negative correlation between the image lightness and the watermark lightness;
an adjusting unit 802, configured to adjust the current watermark lightness of the target watermark according to the reference lightness if the current watermark lightness of the target watermark does not match the reference watermark lightness.
In one embodiment, the triggering event includes any one or more of:
detecting an adding operation of adding the target watermark in the image to be processed;
when the target watermark is added in the image to be processed, detecting the change operation for changing the attribute information of the target watermark; wherein the attribute information of the target watermark includes any one or more of a color, a position and a size of the target watermark; the operation of changing the attribute information of the target watermark comprises one or more of the following operations: the method comprises the following steps of changing the color of the target watermark, moving the position of the target watermark and scaling the size of the target watermark.
In one embodiment, the target watermark includes watermark characters and a watermark background image, the watermark characters include a first type of watermark characters and a second type of watermark characters, the first type of watermark characters are displayed on the image to be processed, the second type of watermark characters are displayed on the watermark background image, the target area includes a first sub-area occupied by the first type of watermark characters in the image to be processed, and the target area includes a second sub-area occupied by the watermark background image in the image to be processed.
In one embodiment, the reference watermark lightness comprises a reference watermark text lightness, the current watermark lightness of the target watermark not matching the reference watermark lightness comprises the current watermark text lightness of the first type of watermark text not matching the reference watermark text lightness; when the adjusting unit 802 adjusts the current watermark brightness of the target watermark according to the reference watermark brightness, the following steps are performed: and adjusting the current watermark character shadow lightness of the first type of watermark characters to the reference watermark character shadow lightness.
In one embodiment, the reference watermark lightness comprises a reference watermark lightness, the current watermark lightness of the target watermark not matching the reference watermark lightness comprises the current watermark lightness of the watermark background map not matching the reference watermark lightness, the adjusting unit 802 performs the following steps when adjusting the current watermark lightness of the target watermark according to the reference watermark lightness: adjusting a current watermark background brightness of the watermark background map to the reference watermark background brightness.
In an embodiment, the adjusting unit 802 is further configured to adjust the current watermark text shadow lightness of the second type of watermark text according to a preset lightness relationship between the watermark background image and the second type of watermark text if the reference watermark background lightness does not match the current watermark text shadow lightness of the second type of watermark text.
In one embodiment, the obtaining unit 801, when obtaining the reference watermark lightness matching the lightness of the target area based on the negative correlation between the image lightness and the watermark lightness, performs the following steps:
acquiring a correlation coefficient, and multiplying the brightness of the target area by the correlation coefficient; and inputting the multiplication result into a negative correlation operation rule for operation to obtain the reference watermark brightness matched with the brightness of the target area.
In one embodiment, if the target area includes a first sub-area occupied by the first type of watermark text in the image to be processed, the obtaining unit 801 performs the following steps when obtaining the lightness of the target area:
acquiring sensitivity parameters for adjusting the shadow lightness of the watermark characters of the first type; determining a brightness of the first sub-region based on the sensitivity parameter and a brightness determination rule.
In one embodiment, the obtaining unit 801, when determining the brightness of the first sub-region based on the sensitivity parameter and the brightness determination rule, performs the following steps: if the sensitivity parameter is a first numerical value, acquiring color information of a plurality of pixels included in the first sub-region; calculating the brightness of the corresponding pixel according to the color information of each pixel and the brightness determination rule; and carrying out preset operation on the brightness of the plurality of pixels to obtain the brightness of the first sub-area.
In one embodiment, the obtaining unit 801, when determining the brightness of the first sub-region based on the sensitivity parameter and the brightness determination rule, performs the following steps:
if the sensitivity parameter is a second numerical value, dividing the first sub-area into N image blocks, wherein N is an integer greater than or equal to 1; determining the brightness of the ith image block according to the color information of a plurality of pixels in the ith image block and the brightness determination rule, wherein i is an integer which is greater than or equal to 1 and less than or equal to N; determining brightness of the N image blocks meeting a preset condition as brightness of the first area.
In one embodiment, if the target area includes a first sub-area occupied by the first type of watermark text in the image to be processed, the obtaining unit 801, when obtaining the target area occupied by the target watermark in the image to be processed, includes:
acquiring target position information and target size information of the first type of watermark characters in the image to be processed; and carrying out region positioning in the image to be processed according to the target position information and the target size information to obtain a first sub-region.
In an embodiment, if the trigger event includes a change operation of detecting that the attribute information of the target watermark is changed when the target watermark is added to the image to be processed, the obtaining unit 801 performs the following steps when obtaining the target position information and the target size information of the first type of watermark text in the image to be processed:
determining initial position information of the target watermark and initial size information of the target watermark in the image to be processed; acquiring first position information and first size information of the target watermark in the image to be processed based on the change operation, the initial position information of the target watermark and the initial size information of the target watermark; and determining the target position information and the target size information of the first type of watermark characters based on the first position information and the first size information of the target watermark.
In one embodiment, the modification operation includes a shift operation on a position of the target watermark and a scaling operation on a size of the target watermark, and the obtaining unit 801 performs the following steps when obtaining first position information and first size information of the target watermark in the image to be processed based on the modification operation and the initial position information of the target watermark and the initial size information of the target watermark:
adding the initial position information and the offset generated by the moving operation to obtain new initial position information; scaling the new initial position information based on the scaling corresponding to the scaling operation to obtain target position information of the target watermark; and multiplying the scaling ratio and the initial size information of the target watermark to obtain first size information.
In one embodiment, when determining the target position information and the target size information of the first type of watermark text based on the first position information and the first size information of the target watermark, the obtaining unit 801 performs the following steps:
acquiring initial position information of the first type of watermark characters and initial size information of the first type of watermark characters; multiplying the initial position information of the first type of watermark characters by the scaling ratio, and adding the operation result and the first position information to obtain the target position information of the first type of watermark characters; and multiplying the initial size information of the first type of watermark characters by the scaling ratio to obtain the target size information of the first type of watermark characters.
According to an embodiment of the present invention, the steps involved in the image processing methods shown in fig. 4 and 6 may be performed by the units in the image apparatus shown in fig. 8. For example, step S401 and step S402 described in fig. 4 may be performed by the acquisition unit 801 in the image processing apparatus described in fig. 8, and step S403 may be performed by the adjustment unit 802 in the image processing apparatus shown in fig. 8; as another example, steps S601 to S603 described in fig. 6 may be performed by the acquisition unit 801 in the image processing apparatus described in fig. 8, and step S604 may be performed by the adjustment unit 802 in the image processing apparatus described in fig. 8.
According to another embodiment of the present invention, the units in the image processing apparatus shown in fig. 7 may be respectively or entirely combined into one or several other units to form the image processing apparatus, or some unit(s) thereof may be further split into multiple units with smaller functions to form the image processing apparatus, which may achieve the same operation without affecting the achievement of the technical effects of the embodiments of the present invention. The units are divided based on logic functions, and in practical application, the functions of one unit can be realized by a plurality of units, or the functions of a plurality of units can be realized by one unit. In other embodiments of the present invention, the image processing apparatus may also include other units, and in practical applications, these functions may also be implemented by being assisted by other units, and may be implemented by cooperation of a plurality of units.
According to another embodiment of the present invention, the image processing apparatus shown in fig. 8 may be configured by running a computer program (including program codes) capable of executing the steps involved in the respective methods shown in fig. 4 and 6 on a general-purpose computing device such as a computer including a processing element such as a Central Processing Unit (CPU), a random access storage medium (RAM), a read-only storage medium (ROM), and a storage element, and an image processing method according to an embodiment of the present invention may be implemented. The computer program may be embodied on a computer-readable storage medium, for example, and loaded into and executed by the above-described computing apparatus via the computer-readable storage medium.
In the embodiment of the invention, when a trigger event for matching, superposing and displaying the image to be processed and the target watermark is required, a target area for displaying the target watermark in the image to be processed is obtained, and the brightness of the target area is calculated; further, acquiring a reference watermark lightness matched with the lightness of the target area based on the negative correlation between the image lightness and the watermark lightness; and if the current watermark lightness of the target watermark is not matched with the reference watermark lightness, adjusting the current watermark lightness of the target watermark according to the reference watermark lightness. In the image processing process, the reference watermark lightness is determined according to the negative correlation between the image lightness and the watermark lightness, is not determined by the user according to the self aesthetics or experience, has certain objectivity, and is not influenced by different users with different aesthetics or experience; in addition, once the watermark lightness of the target watermark displayed in the target area is not matched with the reference watermark lightness, the current watermark lightness of the target watermark is adjusted based on the reference watermark lightness, so that the adaptability between the target watermark and the image to be processed can be ensured, and the effect of the target watermark which is displayed on the image to be processed in an overlapping manner is improved.
Based on the above-mentioned embodiments of the image processing method and the image processing apparatus, an embodiment of the present invention provides an image processing device. Fig. 9 is a schematic structural diagram of an image processing apparatus according to an embodiment of the present invention. The image processing apparatus illustrated in fig. 9 includes at least a processor 901, an input interface 902, an output interface 903, and a computer storage medium 904. The processor 901, the input interface 902, the output interface 903, and the computer storage medium 904 may be connected by a bus or other means.
A computer storage medium 904 may be stored in the memory of the image processing apparatus, the computer storage medium 904 being used for storing a computer program, the processor 901 being used for executing the program computer program stored by the computer storage medium 904. The processor 901 (or CPU) is a computing core and a control core of the image Processing apparatus, and is adapted to implement one or more computer programs, and in particular, is adapted to load and execute the one or more computer programs so as to implement corresponding method flows or corresponding functions.
In one embodiment, the processor 901 according to the embodiment of the present invention may be configured to perform: when a trigger event for matching and superposing an image to be processed and a target watermark is responded, a target area for displaying the target watermark in the image to be processed is obtained, and the brightness of the target area is obtained; acquiring a reference watermark lightness matched with the lightness of the target area based on a negative correlation between the image lightness and the watermark lightness; and if the current watermark lightness of the target watermark is not matched with the reference watermark lightness, adjusting the current watermark lightness of the target watermark according to the reference lightness.
In the embodiment of the invention, when a trigger event for matching, superposing and displaying the image to be processed and the target watermark is required, a target area for displaying the target watermark in the image to be processed is obtained, and the brightness of the target area is calculated; further, acquiring a reference watermark lightness matched with the lightness of the target area based on the negative correlation between the image lightness and the watermark lightness; and if the current watermark lightness of the target watermark is not matched with the reference watermark lightness, adjusting the current watermark lightness of the target watermark according to the reference watermark lightness. In the image processing process, the reference watermark lightness is determined according to the negative correlation between the image lightness and the watermark lightness, is not determined by the user according to the self aesthetics or experience, has certain objectivity, and is not influenced by different users with different aesthetics or experience; in addition, once the watermark lightness of the target watermark displayed in the target area is not matched with the reference watermark lightness, the current watermark lightness of the target watermark is adjusted based on the reference watermark lightness, so that the adaptability between the target watermark and the image to be processed can be ensured, and the effect of the target watermark which is displayed on the image to be processed in an overlapping manner is improved.
An embodiment of the present invention further provides a computer storage medium (Memory), which is a Memory device in an image processing device and is used to store programs and data. It is understood that the computer storage medium herein may include both a storage medium built in the image processing apparatus and an extended storage medium supported by the image processing apparatus. The computer storage medium provides a storage space that stores an operating system of the image processing apparatus. Also, one or more computer programs adapted to be loaded and executed by the processor 901 are stored in the storage space; the computer storage medium may be a high-speed RAM memory, or may be a non-volatile memory (non-volatile memory), such as at least one disk memory; and optionally at least one computer storage medium located remotely from the processor.
In one embodiment, one or more computer programs in a computer storage medium may be loaded and executed by processor 901 to implement the corresponding steps in the image processing method embodiments described above in fig. 4 and 6. In particular implementations, one or more computer programs in a computer storage medium are loaded by processor 901 and perform the following steps:
when a trigger event for matching and superposing an image to be processed and a target watermark is responded, a target area for displaying the target watermark in the image to be processed is obtained, and the brightness of the target area is obtained; acquiring a reference watermark lightness matched with the lightness of the target area based on a negative correlation between the image lightness and the watermark lightness; and if the current watermark lightness of the target watermark is not matched with the reference watermark lightness, adjusting the current watermark lightness of the target watermark according to the reference lightness.
In one embodiment, the triggering event includes any one or more of: detecting an adding operation of adding the target watermark in the image to be processed; when the target watermark is added in the image to be processed, detecting the change operation for changing the attribute information of the target watermark; wherein the attribute information of the target watermark includes any one or more of a color, a position and a size of the target watermark; the operation of changing the attribute information of the target watermark comprises one or more of the following operations: the method comprises the following steps of changing the color of the target watermark, moving the position of the target watermark and scaling the size of the target watermark.
In one embodiment, the target watermark includes watermark characters and a watermark background image, the watermark characters include a first type of watermark characters and a second type of watermark characters, the first type of watermark characters are displayed on the image to be processed, the second type of watermark characters are displayed on the watermark background image, the target area includes a first sub-area occupied by the first type of watermark characters in the image to be processed, and the target area includes a second sub-area occupied by the watermark background image in the image to be processed.
In one embodiment, the reference watermark lightness comprises a reference watermark text lightness, the current watermark lightness of the target watermark not matching the reference watermark lightness comprises the current watermark text lightness of the first type of watermark text not matching the reference watermark text lightness; the processor 901 performs the following steps when adjusting the current watermark brightness of the target watermark according to the reference watermark brightness:
and adjusting the current watermark character shadow lightness of the first type of watermark characters to the reference watermark character shadow lightness.
In one embodiment, the reference watermark lightness comprises a reference watermark lightness, the mismatch between the target watermark lightness and the reference watermark lightness comprises a mismatch between the watermark background lightness and the reference watermark background lightness, and the processor 901 performs the following steps when adjusting the target watermark lightness according to the reference watermark lightness:
adjusting a current watermark background brightness of the watermark background map to the reference watermark background brightness.
In an embodiment, after the current watermark background brightness of the watermark background image is adjusted to the reference watermark background brightness, the processor 901 is further configured to adjust the current watermark text shadow brightness of the second type of watermark text according to a preset brightness relationship between the watermark background image and the second type of watermark text if the reference watermark background brightness is not matched with the current watermark text shadow brightness of the second type of watermark text.
In one embodiment, the processor 901 performs the following steps when obtaining a reference watermark lightness matching the lightness of the target area based on a negative correlation between an image lightness and a watermark lightness:
acquiring a correlation coefficient, and multiplying the brightness of the target area by the correlation coefficient; and inputting the multiplication result into a negative correlation operation rule for operation to obtain the reference watermark brightness matched with the brightness of the target area.
In one embodiment, if the target area includes a first sub-area occupied by the first type of watermark text in the image to be processed, the processor 901 performs the following steps when acquiring the lightness of the target area:
acquiring sensitivity parameters for adjusting the shadow lightness of the watermark characters of the first type; determining a brightness of the first sub-region based on the sensitivity parameter and a brightness determination rule.
In one embodiment, the processor 901, when determining the brightness of the first sub-region based on the sensitivity parameter and the brightness determination rule, performs the following steps:
if the sensitivity parameter is a first numerical value, acquiring color information of a plurality of pixels included in the first sub-region; determining the brightness of the corresponding pixel according to the color information of each pixel and the brightness determination rule; and carrying out preset operation on the brightness of the plurality of pixels to obtain the brightness of the first sub-area.
In one embodiment, the processor 901, when determining the brightness of the first sub-region based on the sensitivity parameter and the brightness determination rule, performs the following steps:
if the sensitivity parameter is a second numerical value, dividing the first sub-area into N image blocks, wherein N is an integer greater than or equal to 1; determining the brightness of the ith image block according to the color information of a plurality of pixels in the ith image block and the brightness determination rule, wherein i is an integer which is greater than or equal to 1 and less than or equal to N; determining brightness of the N image blocks meeting a preset condition as brightness of the first area.
In an embodiment, if the target area includes a first sub-area occupied by the first type of watermark text in the image to be processed, the processor 901 performs the following steps when acquiring the target area occupied by the target watermark in the image to be processed:
acquiring target position information and target size information of the first type of watermark characters in the image to be processed; and carrying out region positioning in the image to be processed according to the target position information and the target size information to obtain a first sub-region.
In an embodiment, if the trigger event includes a modification operation for detecting that the attribute information of the target watermark is modified when the target watermark is added to the image to be processed, the processor 901 performs the following steps when acquiring the target position information and the target size information of the first type of watermark text in the image to be processed:
determining initial position information of the target watermark and initial size information of the target watermark in the image to be processed; acquiring first position information and first size information of the target watermark in the image to be processed based on the change operation, the initial position information of the target watermark and the initial size information of the target watermark; and determining the target position information and the target size information of the first type of watermark characters based on the first position information and the first size information of the target watermark.
In one embodiment, the modifying operation includes a moving operation on a position of the target watermark and a scaling operation on a size of the target watermark, and the processor 901 performs the following steps when acquiring first position information and first size information of the target watermark in the image to be processed based on the modifying operation and initial position information of the target watermark and initial size information of the target watermark:
adding the initial position information and the offset generated by the moving operation to obtain new initial position information;
scaling the new initial position information based on the scaling corresponding to the scaling operation to obtain target position information of the target watermark; and multiplying the scaling ratio and the initial size information of the target watermark to obtain first size information.
In one embodiment, when determining the target position information and the target size information of the first type of watermark text based on the first position information and the first size information of the target watermark, the processor 901 performs the following steps:
acquiring initial position information of the first type of watermark characters and initial size information of the first type of watermark characters; multiplying the initial position information of the first type of watermark characters by the scaling ratio, and adding the operation result and the first position information to obtain the target position information of the first type of watermark characters; and multiplying the initial size information of the first type of watermark characters by the scaling ratio to obtain the target size information of the first type of watermark characters.
In the embodiment of the invention, when a trigger event for matching, superposing and displaying the image to be processed and the target watermark is required, a target area for displaying the target watermark in the image to be processed is obtained, and the brightness of the target area is calculated; further, acquiring a reference watermark lightness matched with the lightness of the target area based on the negative correlation between the image lightness and the watermark lightness; and if the current watermark lightness of the target watermark is not matched with the reference watermark lightness, adjusting the current watermark lightness of the target watermark according to the reference watermark lightness. In the image processing process, the reference watermark lightness is determined according to the negative correlation between the image lightness and the watermark lightness, is not determined by the user according to the self aesthetics or experience, has certain objectivity, and is not influenced by different users with different aesthetics or experience; in addition, once the watermark lightness of the target watermark displayed in the target area is not matched with the reference watermark lightness, the current watermark lightness of the target watermark is adjusted based on the reference watermark lightness, so that the adaptability between the target watermark and the image to be processed can be ensured, and the effect of the target watermark which is displayed on the image to be processed in an overlapping manner is improved.
According to an invention of the present application, there is also provided a computer product or a computer program, the computer product including a computer program, the computer program being stored in a computer-readable storage medium. The processor 901 reads the computer program from the computer-readable storage medium, and causes the image processing apparatus to load and execute:
displaying a social interface of the social application in the first terminal; in the display process of the social interface, if interaction meeting interaction conditions occurs between the first terminal and the second terminal, displaying an interaction interface; performing interaction between a first user and a second user in the interactive interface; the first user is a user corresponding to a social application in the first terminal, and the second user is a user corresponding to a social application in the second terminal.
When a trigger event for matching and superposing an image to be processed and a target watermark is responded, a target area for displaying the target watermark in the image to be processed is obtained, and the brightness of the target area is obtained; acquiring a reference watermark lightness matched with the lightness of the target area based on a negative correlation between the image lightness and the watermark lightness; and if the current watermark lightness of the target watermark is not matched with the reference watermark lightness, adjusting the current watermark lightness of the target watermark according to the reference lightness.
In the embodiment of the invention, when a trigger event for matching, superposing and displaying the image to be processed and the target watermark is required, a target area for displaying the target watermark in the image to be processed is obtained, and the brightness of the target area is calculated; further, acquiring a reference watermark lightness matched with the lightness of the target area based on the negative correlation between the image lightness and the watermark lightness; and if the current watermark lightness of the target watermark is not matched with the reference watermark lightness, adjusting the current watermark lightness of the target watermark according to the reference watermark lightness. In the image processing process, the reference watermark lightness is determined according to the negative correlation between the image lightness and the watermark lightness, is not determined by the user according to the self aesthetics or experience, has certain objectivity, and is not influenced by different users with different aesthetics or experience; in addition, once the watermark lightness of the target watermark displayed in the target area is not matched with the reference watermark lightness, the current watermark lightness of the target watermark is adjusted based on the reference watermark lightness, so that the adaptability between the target watermark and the image to be processed can be ensured, and the effect of the target watermark which is displayed on the image to be processed in an overlapping manner is improved.

Claims (15)

1. An image processing method, comprising:
responding to a trigger event for matching and superposing an image to be processed and a target watermark, acquiring a target area for displaying the target watermark in the image to be processed, and acquiring the brightness of the target area;
acquiring a reference watermark lightness matched with the lightness of the target area based on a negative correlation between the image lightness and the watermark lightness;
and if the current watermark lightness of the target watermark is not matched with the reference watermark lightness, adjusting the current watermark lightness of the target watermark according to the reference watermark lightness.
2. The method of claim 1, wherein the triggering event comprises any one or more of:
detecting an adding operation of adding the target watermark in the image to be processed;
when the target watermark is added in the image to be processed, detecting the change operation for changing the attribute information of the target watermark; wherein the attribute information of the target watermark includes any one or more of a color, a position and a size of the target watermark; the operation of changing the attribute information of the target watermark comprises one or more of the following operations: the method comprises the following steps of changing the color of the target watermark, moving the position of the target watermark and scaling the size of the target watermark.
3. The method of claim 2, wherein the target watermark comprises watermark text and a watermark background map, the watermark text comprises a first type of watermark text and a second type of watermark text, the first type of watermark text is displayed on the image to be processed, the second type of watermark text is displayed on the watermark background map, the target area comprises a first sub-area occupied by the first type of watermark text in the image to be processed, and the target area comprises a second sub-area occupied by the watermark background map in the image to be processed.
4. The method of claim 3, wherein the reference watermark lightness comprises a reference watermark text shadow lightness, wherein the current watermark lightness of the target watermark not matching the reference watermark lightness comprises a current watermark text shadow lightness of the first type of watermark text not matching the reference watermark text shadow lightness; the adjusting the current watermark brightness of the target watermark according to the reference watermark brightness comprises:
and adjusting the current watermark character shadow lightness of the first type of watermark characters to the reference watermark character shadow lightness.
5. The method of claim 3, wherein the reference watermark lightness comprises a reference watermark lightness, the current watermark lightness of the target watermark not matching the reference watermark lightness comprises a current watermark lightness of the watermark background map not matching the reference watermark lightness, the adjusting the current watermark lightness of the target watermark by the reference watermark lightness comprises:
adjusting a current watermark background brightness of the watermark background map to the reference watermark background brightness.
6. The method of claim 5, wherein after adjusting the current watermark background value of the watermark background map to the reference watermark background value, the method further comprises:
and if the reference watermark background brightness is not matched with the current watermark character shadow brightness of the second type of watermark characters, adjusting the current watermark character shadow brightness of the second type of watermark characters according to a preset brightness relation between the watermark background image and the second type of watermark characters.
7. The method of claim 1, wherein obtaining a reference watermark lightness that matches a lightness of the target region based on a negative correlation between an image lightness and a watermark lightness comprises:
acquiring a correlation coefficient, and multiplying the brightness of the target area by the correlation coefficient;
and inputting the multiplication result into a negative correlation operation rule for operation to obtain the reference watermark brightness matched with the brightness of the target area.
8. The method of claim 3, wherein if the target area includes a first sub-area occupied by the first type of watermark text in the image to be processed, the obtaining the brightness of the target area comprises:
acquiring sensitivity parameters for adjusting the shadow lightness of the watermark characters of the first type;
determining a brightness of the first sub-region based on the sensitivity parameter and a brightness determination rule.
9. The method of claim 8, wherein the determining the brightness of the first sub-region based on the sensitivity parameter and a brightness determination rule comprises:
if the sensitivity parameter is a first numerical value, acquiring color information of a plurality of pixels included in the first sub-region;
determining the brightness of the corresponding pixel according to the color information of each pixel and the brightness determination rule;
and carrying out preset operation on the brightness of the plurality of pixels to obtain the brightness of the first sub-area.
10. The method of claim 8, wherein determining the brightness of the first sub-region based on the sensitivity parameter and a brightness determination rule comprises:
if the sensitivity parameter is a second numerical value, dividing the first sub-area into N image blocks, wherein N is an integer greater than or equal to 1;
determining the brightness of the ith image block according to the color information of a plurality of pixels in the ith image block and the brightness determination rule, wherein i is an integer which is greater than or equal to 1 and less than or equal to N;
determining brightness of the N image blocks meeting a preset condition as brightness of the first area.
11. The method of claim 3, wherein if the target area includes a first sub-area occupied by the first type of watermark text in the image to be processed, the obtaining the target area occupied by the target watermark in the image to be processed includes:
acquiring target position information and target size information of the first type of watermark characters in the image to be processed;
and carrying out region positioning in the image to be processed according to the target position information and the target size information to obtain a first sub-region.
12. The method of claim 11, wherein if the trigger event includes a change operation that detects a change of attribute information of the target watermark when the target watermark is added to the image to be processed, the obtaining target position information and target size information of the first type of watermark text in the image to be processed includes:
determining initial position information of the target watermark and initial size information of the target watermark in the image to be processed;
acquiring first position information and first size information of the target watermark in the image to be processed based on the change operation, the initial position information of the target watermark and the initial size information of the target watermark;
and determining the target position information and the target size information of the first type of watermark characters based on the first position information and the first size information of the target watermark.
13. The method of claim 12, wherein the modification operation includes a shift operation on a position of the target watermark and a scaling operation on a size of the target watermark, and the obtaining first position information and first size information of the target watermark in the image to be processed based on the modification operation and initial position information of the target watermark and initial size information of the target watermark includes:
adding the initial position information and the offset generated by the moving operation to obtain new initial position information;
scaling the new initial position information based on the scaling corresponding to the scaling operation to obtain target position information of the target watermark; and multiplying the scaling ratio and the initial size information of the target watermark to obtain first size information.
14. The method of claim 13, wherein the determining the target position information and the target size information of the first type of watermark text based on the first position information and the first size information of the target watermark comprises:
acquiring initial position information of the first type of watermark characters and initial size information of the first type of watermark characters;
multiplying the initial position information of the first type of watermark characters by the scaling ratio, and adding the operation result and the first position information to obtain the target position information of the first type of watermark characters;
and multiplying the initial size information of the first type of watermark characters by the scaling ratio to obtain the target size information of the first type of watermark characters.
15. An image processing apparatus characterized by comprising:
the device comprises an acquisition unit, a comparison unit and a display unit, wherein the acquisition unit is used for responding to a trigger event for matching and superposing a to-be-processed image and a target watermark, acquiring a target area for displaying the target watermark in the to-be-processed image and acquiring the brightness of the target area;
the acquiring unit is further used for acquiring a reference watermark lightness matched with the lightness of the target area based on a negative correlation between the image lightness and the watermark lightness;
and the adjusting unit is used for adjusting the current watermark lightness of the target watermark according to the reference lightness if the current watermark lightness of the target watermark is not matched with the reference watermark lightness.
CN202110765849.8A 2021-07-06 2021-07-06 Image processing method and device Pending CN113822784A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110765849.8A CN113822784A (en) 2021-07-06 2021-07-06 Image processing method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110765849.8A CN113822784A (en) 2021-07-06 2021-07-06 Image processing method and device

Publications (1)

Publication Number Publication Date
CN113822784A true CN113822784A (en) 2021-12-21

Family

ID=78912606

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110765849.8A Pending CN113822784A (en) 2021-07-06 2021-07-06 Image processing method and device

Country Status (1)

Country Link
CN (1) CN113822784A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116363260A (en) * 2023-03-31 2023-06-30 北京百度网讯科技有限公司 Image generation method and device and electronic equipment

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116363260A (en) * 2023-03-31 2023-06-30 北京百度网讯科技有限公司 Image generation method and device and electronic equipment

Similar Documents

Publication Publication Date Title
CN107948733B (en) Video image processing method and device and electronic equipment
KR20130140138A (en) Icon generation method
CN108701351B (en) Image display enhancement method and device
CN111369644A (en) Face image makeup trial processing method and device, computer equipment and storage medium
JP2000134486A (en) Image processing unit, image processing method and storage medium
CN113660514A (en) Method and system for modifying user interface color in conjunction with video presentation
CN110149550B (en) Image data processing method and device and storage medium
CN113808120A (en) Image processing method, image processing device, electronic equipment and storage medium
CN113822784A (en) Image processing method and device
US20220044369A1 (en) Image processing method, terminal and non-transitory computer-readable storage medium
Shih et al. Exploiting perceptual anchoring for color image enhancement
CN111736941B (en) Picture processing method and device
CN112541955A (en) Image processing method, device and equipment
CN112999654A (en) Image processing method, image processing device, computer equipment and storage medium
CN112419218A (en) Image processing method and device and electronic equipment
KR20230041648A (en) Multi-frame depth-based multi-camera relighting of images
CN111462158A (en) Image processing method and device, intelligent device and storage medium
CN112395030A (en) Page processing method and device, electronic device and storage medium
CN111414221B (en) Display method and device
CN113487497A (en) Image processing method and device and electronic equipment
KR101911947B1 (en) Screen design method and screen design system for improving information readability and harmonizing background image
CN113411553A (en) Image processing method, image processing device, electronic equipment and storage medium
CN111968605A (en) Exposure adjusting method and device
CN113114930B (en) Information display method, device, equipment and medium
CN108257221B (en) Tone adjusting method, tone adjusting apparatus, storage medium, and electronic apparatus

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination