Image processing method and device, storage medium and electronic device

By acquiring the pixel color distribution of the original image, converting the background color to a single background color, and using the color gamut deviation threshold to crop the transparent background, the problem of low image processing efficiency in intelligent poster generation is solved, and automated background removal and target image extraction are achieved.

CN122391389APending Publication Date: 2026-07-14HUNAN HAPPLY SUNSHINE INTERACTIVE ENTERTAINMENT MEDIA CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
HUNAN HAPPLY SUNSHINE INTERACTIVE ENTERTAINMENT MEDIA CO LTD
Filing Date
2026-04-10
Publication Date
2026-07-14

Smart Images

  • Figure CN122391389A_ABST
    Figure CN122391389A_ABST
Patent Text Reader

Abstract

The application discloses an image processing method and device, a storage medium and an electronic device. The method comprises the following steps: acquiring an original image containing an image identification object and a background image element; converting the background color of the background image element into a single background color based on the color distribution of the pixel points of the original image, and retaining the original color of the image identification object to obtain a pure background color image; traversing each pixel point in the pure background color image based on the single background color and a pre-set color gamut deviation threshold to obtain a transparent background image; and performing cutting on the transparent background image by positioning a target vertex of a rectangular region occupied by the image identification object to obtain a target image with a transparent color background. The application solves the technical problem of low image processing efficiency in the intelligent poster generation process.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of image processing technology, and more specifically, to an image processing method and apparatus, a storage medium and an electronic device. Background Technology

[0002] In the process of generating posters for various media platforms using an intelligent poster system, it is usually necessary to automatically generate personalized posters that meet various business needs by relying on a pre-created logo material library. The method of acquiring logo images from the material library and the image quality become key issues in the intelligent poster generation process.

[0003] In related technologies, AI image editing models are typically used to generate logo images with background colors, or tools such as image cutout tools or color gamut masks are used to manually cut out the logo from the original image. However, since the logo images obtained by traditional image cutout methods have the background color of the image, they cannot be directly integrated with the background template. Therefore, manual processing is still required to remove the background color of the logo image to obtain a target logo image that can be directly used for smart poster generation.

[0004] In other words, the image processing flow for obtaining logo image materials that can be directly used in the intelligent poster generation system using traditional methods is too complicated and consumes a lot of manpower and time, resulting in the technical problem of low image processing efficiency.

[0005] There is currently no effective solution to the above problems. Summary of the Invention

[0006] This application provides an image processing method and apparatus, a storage medium and an electronic device to at least solve the technical problem of low image processing efficiency in the process of generating smart posters.

[0007] According to one aspect of the embodiments of this application, an image processing method is provided, comprising: acquiring an original image containing an image identifier object and background image elements; converting the background color of the background image elements into a single background color based on the pixel color distribution of the original image, while retaining the original color of the image identifier object, to obtain a pure background color image; traversing each pixel in the pure background color image based on the single background color and a pre-set color gamut deviation threshold to obtain a transparent background image; and obtaining a target image with a transparent background by cropping the transparent background image.

[0008] According to another aspect of the embodiments of this application, an image processing apparatus is also provided, comprising: a first acquisition unit, configured to acquire an original image containing an image identifier object and background image elements; a first conversion unit, configured to convert the background color of the background image elements into a single background color based on the pixel color distribution of the original image, while retaining the original color of the image identifier object, to obtain a pure background color image; a first traversal unit, configured to traverse each pixel in the pure background color image based on the single background color and a preset color gamut deviation threshold, to obtain a transparent background image; and a cropping unit, configured to crop the transparent background image to obtain a target image with a transparent background.

[0009] According to another aspect of the embodiments of this application, a computer-readable storage medium is also provided, wherein a computer program is stored in the computer program for executing the above-described image processing method when the electronic device is run.

[0010] According to another aspect of the embodiments of this application, a computer program product is also provided, including a computer program that, when executed by a processor, implements the steps of the above-described method.

[0011] According to another aspect of the embodiments of this application, an electronic device is also provided, including a memory and a processor, wherein the memory stores a computer program and the processor is configured to execute the image processing method described above through the computer program.

[0012] Using the embodiments provided in this application, an image editing model is employed to obtain the color distribution of pixels with the same color value in the original image, determining the main background color of the original image. Then, based on this main background color, the background color of the original image is converted into a pure background color. According to the color value of the single background color and a pre-set color gamut deviation threshold, pixels in the pure background color image are traversed to obtain a transparent background image with a completely transparent background. Finally, by locating the four target vertices of the area occupied by the image identifier (i.e., the logo image), the transparent background image is cropped to obtain a target image with a transparent background containing only the image identifier. In other words, without manual intervention, the original image is adaptively converted into a pure background color image, and the background color is automatically removed based on the color gamut deviation threshold, thereby obtaining a target image with a fully displayed image identifier and a transparent background. This simplifies the image processing flow, reduces image processing time, and achieves the technical effect of improving image processing efficiency. Attached Figure Description

[0013] The accompanying drawings, which are provided to further illustrate this application and form part of this application, illustrate exemplary embodiments of this application and are used to explain this application, but do not constitute an undue limitation of this application.

[0014] Figure 1 This is a schematic diagram illustrating an application scenario of an optional image processing method according to an embodiment of this application;

[0015] Figure 2 This is a flowchart of an optional image processing method according to an embodiment of this application;

[0016] Figure 3 This is an overall schematic diagram of an optional image processing method according to an embodiment of this application;

[0017] Figure 4 This is a schematic diagram of an optional method for obtaining the color distribution of pixels according to an embodiment of this application;

[0018] Figure 5 This is a schematic diagram illustrating an optional method of converting an original image into a solid background color image according to an embodiment of this application;

[0019] Figure 6 This is a schematic diagram illustrating an optional method of converting a pure background color image into a transparent background image according to an embodiment of this application;

[0020] Figure 7 It is a flowchart showing the overall process of locating the vertices of the rectangular area occupied by the logo and cropping the image based on the vertices.

[0021] Figure 8 This is a flowchart of an image cropping method based on a combination of area determination and dynamic adjustment of color gamut deviation threshold;

[0022] Figure 9 This is a schematic diagram of the structure of an optional image processing apparatus according to an embodiment of this application;

[0023] Figure 10 This is a schematic diagram of the structure of an optional electronic device according to an embodiment of this application. Detailed Implementation

[0024] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort should fall within the scope of protection of the present application.

[0025] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0026] The technical solutions in this application will comply with legal regulations during implementation. When operating according to the technical solutions in the embodiments, the data used will not involve user privacy, ensuring that the operation process is compliant and legal while guaranteeing data security. In addition, when the above embodiments of this application are applied to specific products or technologies, user permission or consent is required, and the collection, use, and processing of related data must comply with the relevant regulations and standards of the relevant countries or regions.

[0027] According to one aspect of the embodiments of this application, an image processing method is provided. As an optional implementation, the above-described image processing method may be applied to, but is not limited to, [examples of other methods]. Figure 1 The application scenarios shown are as follows. In, for example... Figure 1 In the application scenario shown, the target terminal 102 can communicate with the server 106 via network 104, but is not limited to this. The server 106 can perform operations on the database 108, such as write or read data operations. The target terminal 102 may include, but is not limited to, a human-computer interaction screen, a processor, and a memory. The human-computer interaction screen may be used to display the target image processed using the technical solution of this application on the target terminal 102. The processor may be used to respond to the human-computer interaction operation, execute the corresponding operation, or generate corresponding instructions and send the generated instructions to the server 106. The memory is used to store relevant processing data, such as pixel color distribution, pure background color images, and transparent background images.

[0028] Optionally, in this embodiment, the target terminal can be a terminal configured with a target client, which may include, but is not limited to, at least one of the following: mobile phone (such as Android phone, iOS phone, etc.), laptop computer, tablet computer, PDA, MID (Mobile Internet Devices), PAD, desktop computer, smart TV, etc. The target client may be a video client, instant messaging client, browser client, educational client, etc. The network may include, but is not limited to, wired network and wireless network, wherein the wired network includes: local area network, metropolitan area network and wide area network, and the wireless network includes: Bluetooth, WIFI and other networks that enable wireless communication. The server may be a single server, a server cluster composed of multiple servers, or a cloud server.

[0029] The technical solution of this application can be widely applied to image processing scenarios in large-scale intelligent poster automated generation, e-commerce platform product image compliance review, and content generation systems. For example, in the intelligent poster system of a media platform, a large number of personalized posters need to be generated daily, automatically merging program logos, key figures, etc., with background templates. Using the technical solution of this application, a logo image with a transparent background can be quickly generated, thereby achieving accurate synthesis of the logo image and the background template and improving image processing efficiency.

[0030] As described in the above embodiments, there is a technical problem of low image processing efficiency when applying traditional data acquisition methods to the intelligent poster generation process. To solve this problem, this application proposes an image processing method. Figure 2 This is a flowchart of an image processing method according to an embodiment of the present application, which includes the following steps S202 to S208.

[0031] It should be noted that the image processing methods shown in steps S202 to S208 can be, but are not limited to, executed by an electronic device, wherein the electronic device can be, but is not limited to, as shown in the example below. Figure 1 The target terminal or server shown.

[0032] Step S202: Obtain the original image containing the image identifier object and background image elements;

[0033] Step S204: Based on the pixel color distribution of the original image, the background color of the background image elements is converted into a single background color, while retaining the original color of the image identifier object, to obtain a pure background color image;

[0034] Step S206: Based on a single background color and a pre-set color gamut deviation threshold, traverse each pixel in the pure background color image to obtain a transparent background image;

[0035] Step S208: By cropping the transparent background image, a target image with a transparent background is obtained.

[0036] The background image elements may include, but are not limited to, one or more background colors. In this embodiment, at least one of the background colors included is uniformly converted into a single background color.

[0037] The above pixel distribution may, but is not limited to, represent the statistical result of the number of pixels with the same color value in the original image.

[0038] For ease of understanding, this application embodiment uses a poster logo as the image identifier object to explain the detailed process of the above image processing method. In practical application scenarios, the image identifier object can also be a product image on a product details page, etc., and this application embodiment does not limit this.

[0039] The original image may, but is not limited to, an image containing multiple image elements, where the multiple image elements include, but are not limited to, image identifier objects and background image elements. For example... Figure 3 As shown in (a), the original image is assumed to include elements such as people, trees, and logo. Among them, people, trees, and the image background are background image elements, and the logo is the image identifier.

[0040] The background image elements may have one or more colors, such as... Figure 3 As shown in (a), the figure is in various colors (black hair, yellow clothes, black eyes, etc.), and the background of the original image is blue with green trees.

[0041] The prompt for the pre-input image editing model (i.e., the image Edit model) is "Retrieve the logo from the given image and output it with a green background, ensuring the logo's height does not exceed half the height of the original image." Following this prompt, the model outputs a pure logo image or image with a green background.

[0042] To obtain a logo image with a completely transparent background (i.e., the target image), this embodiment typically employs an image editing model, such as QWEN_EDIT or FLUX, to process the original image with its complex and diverse colors into an image with a solid background (which can also be understood as a solid background color image). During this process, the pixel color distribution of the number of pixels with the same color value in the original image is pre-calculated.

[0043] The pixel color distribution includes the statistical results of the number of pixels with the same color value. For example, the number of pixels with the first color value is M1, the number of pixels with the second color value is M2, and the number of pixels with the third color value is M3, and M1>M2>M3. Then, using the image editing model, the original image is converted into a single background color indicated by the first color value, resulting in a pure background color image with only the main background color (i.e., a single background color).

[0044] It's important to note that the primary background color (such as green) defined in the prompt is not limited to colors present in the original image. For example, assuming the original image's background color is red and blue and does not contain green, the prompt can still determine the solid background color as green. Here, the solid background is not a single pixel, but these background pixels are all near the color gamut of the primary background color (the solid background color determined by the distribution of pixel colors).

[0045] Based on the preset color gamut deviation threshold and the target color value corresponding to a single background color, a color range is set, and the value of the alpha channel of the pixels located in the color range is set to 0, resulting in a transparent background image with a transparent background color.

[0046] By scanning the pixels of the transparent background image, four extreme coordinates are obtained, and the four pixels containing these four extreme coordinates are determined as the minimum bounding rectangle of the logo area in the image. By locating the target vertices of the rectangular area occupied by the image identifier (i.e., the area of ​​the minimum bounding rectangle), the transparent background image is cropped to obtain a logo image (i.e., the target image) containing only the image identifier with a transparent background. The image cropping process will be described in detail below with specific examples.

[0047] To facilitate understanding, the following will be combined with... Figure 3 The overall schematic diagram shown illustrates the image processing method described above.

[0048] Assuming the original image is as follows Figure 3 As shown in (a), after processing according to the image Edit model, a statistical result is obtained to represent the number of pixels with the same color value in the original image, and the target color value with the largest number is determined from it.

[0049] The target color indicated by the target color value is used to determine the main background color, such as green. The original image is then converted to... Figure 3 The pure background color image shown in (b) means that all image elements except the image identifier (including the image material in the background and the background color) are uniformly converted to the target color.

[0050] Based on a pre-set color gamut deviation threshold, a pure background color image is converted into a transparent background image with a transparent background, such as... Figure 3 As shown in (c). Figure 3 As shown in (d), by locating four vertices with non-zero alpha channel values ​​and extreme coordinates, and cropping the rectangular area occupied by these four vertices, a target image with a fully displayed logo image and a transparent background is obtained. (Refer to...) Figure 3 As shown in (e). Additionally, to ensure the quality of the target image, the edges of the initially cropped target image are usually smoothed. Specifically, this can involve removing isolated background pixels that may be present in the edges of the target image, resulting in a smoother image as shown in (e). Figure 3 The target image shown in (f) is able to fully display the logo and has a transparent background.

[0051] Using the embodiments provided in this application, an image editing model is employed to obtain the color distribution of pixels with the same color value in the original image, determining the main background color of the original image. Then, based on this main background color, the background color of the original image is converted into a pure background color. According to the color value of the single background color and a pre-set color gamut deviation threshold, pixels in the pure background color image are traversed to obtain a transparent background image with a completely transparent background. Finally, by locating the four target vertices of the area occupied by the image identifier (i.e., the logo image), the transparent background image is cropped to obtain a target image with a transparent background containing only the image identifier. In other words, without manual intervention, the original image is adaptively converted into a pure background color image, and the background color is automatically removed based on the color gamut deviation threshold, thereby obtaining a target image with a fully displayed image identifier and a transparent background. This simplifies the image processing flow, reduces image processing time, and achieves the technical effect of improving image processing efficiency.

[0052] As an optional example, the above method of converting the background color of background image elements to a single background color based on the pixel color distribution of the original image includes:

[0053] Iterate through each pixel in the original image to obtain a set of color values ​​composed of the concatenated color values ​​of each pixel;

[0054] The stitched color value of each pixel is determined as the first key value. Based on the first key value, a pre-created set of key value pairs is searched to obtain a statistical result of the number of pixels with the same color value.

[0055] Based on the statistical results, the target color value with the largest number of pixels is determined from the set of color values, and the background color of the background image elements is converted into the main background color indicated by the target color value.

[0056] It should be noted that the above key-value pair set includes a first key value representing the spliced ​​color value and a second key value representing the number of pixels, and the first key value and the second key value have a mapping relationship.

[0057] After obtaining the above statistical results, at least one background color contained in the background image element can be converted into the above main background color in the following way: Based on the statistical results, the target color value corresponding to the number of pixels with the largest value is determined from the color value set, and the color indicated by the target color value is determined as the main background color; at least one background color contained in the background image element is converted into the main background color, wherein the main background color is a single background color.

[0058] As an optional implementation, the above iterates through each pixel in the original image to obtain a set of color values ​​composed of the concatenated color values ​​of each pixel, including:

[0059] Iterate through each pixel in the original image to obtain the multi-channel color value of each pixel in multiple color channels;

[0060] The multi-channel color values ​​of each pixel are concatenated to obtain each concatenated color value in the color value set.

[0061] By iterating through each pixel in the original image, the color values ​​of its three channels (R (red), G (green), and B) are extracted, such as... Figure 4 As shown, the color values ​​of pixel 1 are (r1, g1, b1), pixel 2 are (r2, g2, b2), and pixel 3 are (r3, g3, b3), etc.

[0062] For each pixel, the color values ​​of its R, G, and B channels are concatenated to obtain, as shown below. Figure 4 The various concatenated color values ​​C1, C2, C3, etc. are shown. Among them, C1 is the string obtained by concatenating r1, g1, and b1, and this string is determined as the concatenated color value.

[0063] In this embodiment, a pixelMapValue data structure is pre-created. It iterates through all pixels in the original image, concatenating the R, G, and B values ​​of each pixel into a string, which is then used as the key in a key-value pair. The set of key-value pairs indicated by this data structure is searched to determine if a key corresponding to the concatenated color value of each pixel exists. If the key exists, the key-value pair is retrieved from the data structure, the value is incremented by 1, and then the pair is added back in. The purpose of incrementing the value here is to count the number of pixels with the same color value.

[0064] Following the above method, the number of pixels with the same color value in the original image can be determined. For example, the number of pixels with color values ​​(r1, g1, b1) is value1, the number of pixels with color values ​​(r2, g2, b2) is value2, the number of pixels with color values ​​(r3, g3, b3) is value3, and so on. This yields the pixel color distribution.

[0065] like Figure 5 As shown, based on the statistical results of the color distribution indication of pixels with the same color value, the value is sorted, assuming that the largest value, value1, is obtained. Then, using the image editing model, the original image is processed into a solid background image with a solid background color of (r1, g1, b1).

[0066] In other words, by traversing the pixels of the original image once, we can calculate all the output pixels and the frequency of each pixel. In the solid-color background logo image generated by the image Edit model, the color that appears most frequently is the dominant hue of the original image's background. By traversing the above pixelMapValue data structure, we obtain the maximum value and find the corresponding target key value. The target key value corresponds to (r... i ,g i ,b i The target color value is the primary background color (which can also be understood as a single background color). All remaining image elements in the original image, except for the image identifier, as well as the background color, are converted to the color indicated by the target color value, resulting in a pure background color image.

[0067] It should be noted that the solid color background mentioned in this embodiment is not a single pixel, but these background pixels are all near the color gamut of the main background color.

[0068] In summary, this embodiment collaboratively constructs a lightweight and robust background color recognition mechanism, which solves the limitations of manually setting thresholds in traditional methods. It provides a stable and reusable clean background input for subsequent automatic transparency processing, and is an indispensable pre-processing step for achieving accurate logo extraction.

[0069] As an optional example, the above method, based on a single background color and a pre-set color gamut deviation threshold, iterates through each pixel in a pure background color image to obtain a transparent background image, including:

[0070] Obtain the pre-set initial color gamut deviation threshold;

[0071] Based on the initial color gamut deviation threshold and the target color value of a single background color, a target color range is constructed;

[0072] Iterate through each pixel in the pure background color image and set the alpha channel values ​​of at least some pixels whose multi-channel color values ​​are within the target color range to 0 to obtain a transparent background image.

[0073] The upper limit of the target color range is obtained by adding the initial gamut deviation threshold to the color values ​​of each color channel in the target color value, while the lower limit is obtained by subtracting the initial gamut deviation threshold from the color values ​​of each color channel. The meaning of the upper and lower limits will be explained below with reference to specific embodiments.

[0074] Assuming an initial color gamut deviation threshold is preset, this value is not a fixed constant (such as 40 or 30 in traditional methods), but an adjustable starting parameter. In this embodiment, the initial value is set to 40. This threshold serves as the starting point for the "exploration range," used to construct a target color range centered on the main background color.

[0075] For example, if the primary background color determined using the above method is (10, 240, 50), then with this color value as the center, each color channel is added to or subtracted by 40 to obtain a color gamut range consisting of a lower limit (0, 200, 10) and an upper limit (50, 255, 100). This target color range covers all background candidate pixels that may be affected by slight rendering errors, compression artifacts, or lighting reflections, ensuring that no pixels in the real background are missed (i.e., removing background colors carried by pixels as much as possible) while preserving the logo body as much as possible. In such cases... Figure 6 In the example shown, assuming the initial color gamut deviation threshold Q=40, then the upper limit of the target color range is (50,255,100) and the lower limit is (0,200,10).

[0076] The process iterates through all pixels in the pure background image, determining whether their RGB values ​​fall within the target color range. If a pixel's R, G, and B channel values ​​are all within the range, it is identified as a "background pixel," and its Alpha (transparency channel) value is set to 0 (completely transparent), making all pixels except those representing image objects "completely transparent." For example, a pixel with values ​​(18, 242, 55) has R=18 (between 0 and 50), G=242 (between 200 and 255), and B=55 (between 10 and 100), falling within the target color range, and is therefore marked as a transparent background. This process does not rely on manually setting multiple color regions; instead, it uses a unified and scalable target color range to coarsely screen the background of the entire image.

[0077] It's easy to understand that during the background transparency process, the pixels whose transparency channel is set to 0 retain their initial color in the RGB channels, such as... Figure 3The trees shown are still green, but they are made invisible through a transparency process.

[0078] The aforementioned background color transparency processing provides an intermediate image for subsequent "area constraint cropping". Since the initial color gamut deviation threshold of 40 may be too large or too small, it can lead to incomplete background removal or accidental deletion of main subject pixels (the pixel color of the logo). Therefore, the technical solution of this application uses the initial color gamut deviation threshold as a benchmark, and then dynamically adjusts it (e.g., by increasing it by 10) through an area verification mechanism to form a closed-loop optimization. However, in this embodiment, only this initial mask based on the initial color gamut deviation threshold needs to be completed to provide a quantifiable and reproducible transparent layer for the entire process.

[0079] As an optional example, the above method of cropping a transparent background image to obtain a target image with a transparent background includes:

[0080] Traverse all pixels in the transparent background image whose transparency channel value is non-zero, determine the maximum horizontal coordinate value, minimum horizontal coordinate value, maximum vertical coordinate value, and minimum vertical coordinate value, and locate four target vertices, wherein the horizontal coordinate value of each of the four target vertices is the maximum horizontal coordinate value or the minimum horizontal coordinate value, and the vertical coordinate value of each target vertex is the maximum vertical coordinate value or the minimum vertical coordinate value.

[0081] The target image is obtained by cropping the rectangular region formed by the four target vertices in the transparent background image.

[0082] After obtaining the transparent background image according to the above embodiments, this application also provides a method for determining the target vertices in the rectangular region occupied by the image identifier object. Specifically, as shown... Figure 7 As shown.

[0083] S702, scans pixels in a transparent background image;

[0084] S704, obtain the pixel coordinate values ​​(or simply coordinate values) of each pixel in the transparent background image, including the first pixel coordinate value in the x-axis direction and the second pixel coordinate value in the y-axis direction;

[0085] S706, determine the maximum value of maxX (which can also be understood as the maximum horizontal coordinate value) and the minimum value of minX (which can also be understood as the minimum horizontal coordinate value) along the x-axis direction, as well as the maximum value of maxY (which can also be understood as the maximum vertical coordinate value) and the minimum value of minY (which can also be understood as the minimum vertical coordinate value) along the y-axis direction.

[0086] S708, based on maxX, minX, maxY and minY, determines 4 vertices or 4 pixels with the top left corner as (minX, minY), the top right corner as (maxX, minY), the bottom left corner as (minX, maxY), and the bottom right corner as (maxX, maxY);

[0087] These four vertices are the four vertices of the rectangular area occupied by the logo. These four vertices can be used to determine the smallest bounding rectangle of the logo area in the transparent background image. The connected region formed by this rectangle is the complete outline range of the logo after removing the solid color background.

[0088] In the above, minX represents the minimum value along the horizontal coordinate axis, maxX represents the maximum value along the horizontal coordinate axis, minY represents the minimum value along the vertical coordinate axis, and maxY represents the maximum value along the vertical coordinate axis. The horizontal and vertical coordinate axes can be, but are not limited to, coordinate axes in a two-dimensional coordinate system of the planar region where the original image is located.

[0089] S710 determines the logo image area based on the four located vertices;

[0090] S712, based on 4 vertices, crops the transparent background image to obtain a target image with a transparent background containing only the logo.

[0091] Unlike traditional methods that crop by 50% from the image center or use a fixed scaling ratio, this application's embodiments dynamically generate the cropping range based on the actual content distribution, ensuring that the logo is completely preserved regardless of whether it is off-center, top-center, elongated, or irregularly shaped, without including any irrelevant background. For example, if the logo is a circle with a wavy notch in the lower right corner, traditional methods may cut off part of the edge due to center cropping, while this application's technical solution can accurately capture the rightmost and bottommost pixels of the wavy notch, completely preserving this feature, allowing the output image to be losslessly scaled and overlaid in subsequent poster compositing.

[0092] This approach avoids the problem of traditional AI image cutout methods being unable to handle logos with variable positions and sizes. Since logos output by models like QWEN-EDIT may be located in any corner of the image and vary in size, using a fixed cropping frame could lead to content truncation or the introduction of invalid transparent areas. However, through extreme value localization, the system achieves content-driven cropping, ensuring the output image size perfectly matches the logo's true outline, providing zero-redundancy intermediate processing results for subsequent reuse of transparent layers.

[0093] As an optional implementation, the above-described method of cropping the rectangular region formed by the four target vertices in the transparent background image to obtain the target image includes:

[0094] Determine the rectangular area of ​​the rectangular region;

[0095] Determine the ratio between the area of ​​the rectangle and the total area occupied by the transparent background image, where the area occupied by the transparent background image is equal to the area occupied by the original image;

[0096] Based on the ratio and the initial color gamut deviation threshold, the transparent background image is adaptively cropped to obtain the target image.

[0097] In order to ensure that background pixels are completely removed during the cropping process of the area occupied by the image identification object, this application embodiment also proposes an adaptive threshold adjustment system with content proportion as feedback signal. The content proportion may refer to, but is not limited to, the ratio between the rectangular area of ​​the rectangular region formed by the target vertices and the total area occupied by the transparent background image. Here, the transparent background image has the same size as the original image.

[0098] Based on the description in the above embodiments, when the prompt is "Get the Logo from the given image and output it with a green background, the height of the Logo shall not exceed half the height of the original image," it means that the area of ​​the rectangular region cannot exceed the total area. (Target threshold) If the value is greater than or equal to the target threshold, it indicates that the background or background pixels have not been completely removed. In this case, the cropping area will be further adjusted by dynamically adjusting the color gamut deviation threshold.

[0099] In other words, during the cropping process of transparent background images, it is necessary to combine area proportion determination and dynamic adjustment of color gamut deviation threshold to optimize the cropping result in real time.

[0100] As an optional implementation, the above-mentioned adaptive cropping of the transparent background image based on the ratio and the initial color gamut deviation threshold to obtain the target image includes at least one of the following:

[0101] If the ratio is less than the target threshold, the image within the rectangular region containing only the image identifier object is identified as the target image, where the target threshold is obtained according to the pre-input image processing instructions;

[0102] If the ratio is greater than or equal to the target threshold, the initial color gamut deviation threshold is incrementally adjusted to obtain the incremental color gamut deviation threshold. Based on the incremental color gamut deviation threshold, each pixel in the pure background color image is traversed to obtain an updated transparent background image with a transparent background. If the ratio between the area of ​​the updated rectangle region determined by the target updated vertex in the updated transparent background image and the total area is less than the target threshold, the adjustment of the initial color gamut deviation threshold is stopped.

[0103] Specifically, such as Figure 8As shown, it includes the following steps:

[0104] S802, obtain the prompt words for the pre-output image editing model;

[0105] The target threshold is determined based on the size parameters in the prompt, namely, the logo's height is less than half the height of the original image.

[0106] S804, calculate the rectangular area S0 of the rectangular region defined by the 4 vertices;

[0107] The four vertices may be, but are not limited to, determined by the extreme coordinate positioning method in the above embodiments, which will not be elaborated here.

[0108] S806, calculate the ratio between the area of ​​the rectangle S0 and the total area occupied by the transparent background image;

[0109] S808, determine whether the above ratio is less than the target threshold;

[0110] If yes, proceed to step S818; otherwise, proceed to step S810.

[0111] S810, adjusts the initial color gamut deviation threshold according to a preset deviation (or fixed increment);

[0112] For example, if the preset deviation is set to 10, the initial color gamut deviation threshold is adjusted from 40 to 50 to obtain the incremental color gamut deviation threshold.

[0113] It should be noted that this adjustment process may be done once or multiple times, but each adjustment is an incremental adjustment based on the incremental deviation threshold after the previous adjustment.

[0114] S812, based on the adjusted incremental color gamut deviation threshold, re-execute the background mask operation;

[0115] For example, perform a new round of transparency processing on the pure background color image to generate an updated transparent background image; then relocate the target update vertex in the updated transparent background image and calculate the ratio between the area of ​​the new rectangular region and the total area, referring to step S814.

[0116] S814, reposition the four new vertices and calculate the ratio R between the area of ​​the rectangular region formed by the new vertices and the total area. i ;

[0117] Where i is a positive integer greater than or equal to 1.

[0118] S816, Determine R i Is it less than the target threshold?

[0119] If so, proceed to step S818; otherwise, jump to step S810 and iteratively update the value of the color gamut deviation threshold until the ratio between the area of ​​the rectangle determined by the adjusted color gamut deviation threshold (i.e., the incremental color gamut deviation threshold) and the total area is less than the target threshold, then stop adjusting the color gamut deviation threshold.

[0120] S818, crop the transparent background image to obtain the target image with a transparent background that contains only the logo.

[0121] This is because when the ratio is less than the target threshold, the system automatically determines that the background residue has been largely removed from the currently cropped logo body area. Further expanding the initial color gamut deviation threshold may lead to the loss of edge details in the logo image. Therefore, the final target image is obtained by directly cropping the rectangular area formed by the current target vertices to obtain an image containing only the logo body.

[0122] For example, suppose the logo is a magazine brand logo with finely jagged edges and a cutout structure. When the initial color gamut deviation threshold is 40, the content occupies 18% (the target threshold is set to 20%). Although slightly below the threshold, there are no obvious background blemishes visible to the naked eye. The system immediately terminates the optimization process and outputs the cropping result to avoid damaging edge details by blindly increasing the threshold and to ensure the integrity of the brand logo.

[0123] In other words, in this embodiment, by traversing the pixels in the transparent background image, four variables (i.e., four extreme coordinates) minX, maxX, minY, and maxY are located. The maximum and minimum X values ​​and Y values ​​are obtained by traversing all points in the image. Then, the rectangles formed by the four vertices (minX, minY), (minX, maxY), (maxX, minY), and (maxX, maxY) are calculated, and their areas are calculated. If the area is greater than or equal to one-quarter of the total area of ​​the original image, the initial color gamut deviation threshold is increased by 10 each time until the obtained Logo area is less than one-quarter of the total area. In other words, based on the four vertices of the rectangular area occupied by the Logo, the image is cropped to obtain a transparent background image that meets the Logo's height and dimensions as required by the prompt, achieving a clean background cropping effect.

[0124] As an optional example, after obtaining the target image with a transparent background by cropping the transparent background image, the above method further includes:

[0125] Sequentially obtain each pixel from the target image as the current pixel;

[0126] If at least two of the four neighboring pixels adjacent to the current pixel have an alpha channel value of 0, then the alpha channel value of the current pixel is set to 0.

[0127] The reason for setting up the processing procedure in this embodiment is that the edges of the transparent background Logo image obtained by cropping according to the above embodiment may have residual pixels with a background color (i.e., main background color) similar to the Logo color, and may appear at fixed points of the Logo image.

[0128] The so-called fixed point of the logo image can refer to, but is not limited to, isolated edge pixels (or isolated noise or pseudo-edge pixels surrounded by the background) that belong to the logo area but are surrounded by a transparent background on all four sides (or two or more sides). It is a pseudo-edge point of the logo and is noise that needs to be removed.

[0129] Specifically, the process iterates through the pixels in the target image and, for each current pixel, checks if the alpha channel values ​​of its four surrounding pixels (i.e., neighboring pixels) are 0. If two or more neighboring pixels have 0 values, the current pixel is designated as a fixed point, and its alpha channel value is set to 0. This effectively deletes the current pixel (making it visually invisible or only invisible to the naked eye), with the goal of cleaning up the noise around the logo image edges.

[0130] This is because during the process of setting the original image to a pure background color (green background) based on the prompt, a single background color may contain multiple different color values, but all of these different color values ​​are displayed as green, resulting in complex colors (such as light green, dark green, etc.). This leads to the possibility of missing some background pixels during the background transparency process, resulting in isolated background pixels on the edges of the cropped logo image. If a logo image with such pseudo-pixels is directly used for smart poster generation, it will affect the visual quality and brand professionalism.

[0131] After converting the original image to a solid background color image, converting the solid background color image to a transparent background image, locating the Logo image region in the transparent background image, and processing the edge pixels of the Logo image, this application embodiment also provides a bicubic interpolation method to perform edge processing on the target image to obtain a smoothed target image.

[0132] Specifically, the edges of the logo image obtained in the above manner may be relatively rough or lack smoothness, visually appearing as burrs, spots, artifacts, etc. Bicubic interpolation is used to enlarge the size of the target image to twice that of the original target image, expanding the edge transition area from discrete pixels to a continuous sub-pixel grayscale gradient. Then, bilinear interpolation is used to proportionally reduce the image back to its original resolution. Anti-aliasing is achieved through downsampling, thereby smoothing edge visual noise (the irregular jagged edges of the image disappear) while preserving the integrity of the logo outline structure, and improving the rendering quality and visual purity of the transparent background logo image.

[0133] This method requires no deep learning model and does not rely on external data. It can achieve automated and highly consistent processing using only standard image processing operators, making it suitable for batch generation scenarios of massive logo materials.

[0134] In other words, the specific steps to smooth the edges of a logo image by enlarging and reducing it are as follows: first, the original target image is enlarged by a factor of 2 using bicubic interpolation, and then it is reduced back to its original size using bilinear interpolation. This process transforms jagged edges into a smooth transition through subpixel reconstruction and anti-aliasing, resulting in a pure logo image with a transparent background and clear, clean edges, thus improving visual quality.

[0135] The transparent background logo image obtained in the above manner can be directly used in the subsequent intelligent poster synthesis system, avoiding manual removal of background color and manual edge processing, thus improving image processing efficiency and enhancing the production efficiency of intelligent posters.

[0136] As can be seen from the description of the above embodiments, the technical solution of this application generates a logo image with a solid color background through an image editing model, and finally obtains a clear and complete logo image with a transparent background. The main steps include: (1) calculating the background color distribution and obtaining the set of pixel colors; (2) setting the initial color gamut deviation threshold through the automatic calculation technology of color gamut range deviation and removing the background color to obtain a transparent background image; (3) locating the four vertices of the logo rectangular area in the transparent background image and cropping them; (4) removing isolated noise points of the edge pixels of the logo image with a transparent background; (5) smoothing the edges of the logo image by using the image enlargement and reduction method to remove edge jaggedness, etc.

[0137] Using the above method, high-quality logo images with clear edges, completely transparent backgrounds, and no residual colors can be automatically generated without human intervention.

[0138] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that this application is not limited to the described order of actions, as some steps may be performed in other orders or simultaneously according to this application. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are preferred embodiments, and the actions and modules involved are not necessarily essential to this application.

[0139] According to another aspect of the embodiments of this application, as follows is also provided Figure 9 An image processing apparatus is shown, the apparatus comprising:

[0140] The first acquisition unit 902 is used to acquire the original image containing the image identifier object and background image elements;

[0141] The first conversion unit 904 is used to convert the background color of the background image elements into a single background color based on the pixel color distribution of the original image, while retaining the original color of the image identification object, to obtain a pure background color image;

[0142] The first traversal unit 906 is used to traverse each pixel in the pure background color image based on a single background color and a pre-set color gamut deviation threshold to obtain a transparent background image.

[0143] The cropping unit 908 is used to obtain a target image with a transparent background by cropping the transparent background image.

[0144] Optionally, the first conversion unit 904 includes:

[0145] The first processing module is used to traverse each pixel in the original image and obtain a set of color values ​​composed of the spliced ​​color values ​​of each pixel.

[0146] The second processing module is used to determine the spliced ​​color value of each pixel as the first key value, and based on the first key value, search the pre-created set of key value pairs to obtain the statistical result of the number of pixels with the same color value.

[0147] The third processing module is used to determine the target color value with the largest number of pixels from the set of color values ​​based on statistical results, and to convert the background color of the background image elements into the main background color indicated by the target color value.

[0148] Optionally, the first processing module mentioned above includes:

[0149] The first traversal submodule is used to traverse each pixel in the original image and obtain the multi-channel color value of each pixel in multiple color channels.

[0150] The splicing submodule is used to splice the multi-channel color values ​​of each pixel to obtain each spliced ​​color value in the color value set.

[0151] Optionally, the first traversal unit 906 mentioned above includes:

[0152] The first acquisition module is used to acquire a pre-set initial color gamut deviation threshold.

[0153] The building module is used to construct the target color range based on the initial color gamut deviation threshold and the target color value of a single background color;

[0154] The first traversal module is used to traverse each pixel in the pure background color image and set the values ​​of the transparent channels of at least some pixels whose multi-channel color values ​​are within the target color range to 0, thereby obtaining a transparent background image.

[0155] Optionally, the above-mentioned cutting unit 908 includes:

[0156] The second traversal module is used to traverse each pixel in the transparent background image whose transparency channel value is non-zero, determine the maximum horizontal coordinate value, minimum horizontal coordinate value, maximum vertical coordinate value, and minimum vertical coordinate value, and locate four target vertices. The horizontal coordinate value of each of the four target vertices is the maximum or minimum horizontal coordinate value, and the vertical coordinate value of each target vertex is the maximum or minimum vertical coordinate value.

[0157] The fourth processing module is used to crop the rectangular region formed by the four target vertices in the transparent background image to obtain the target image.

[0158] Optionally, the third processing module mentioned above includes:

[0159] The first processing submodule is used to determine the rectangular area of ​​the rectangular region;

[0160] The second processing submodule is used to determine the ratio between the area of ​​the rectangle and the total area occupied by the transparent background image, wherein the area occupied by the transparent background image is equal to the area occupied by the original image;

[0161] The cropping submodule is used to adaptively crop a transparent background image based on a ratio and an initial color gamut deviation threshold to obtain the target image.

[0162] Optionally, the third processing module mentioned above further includes:

[0163] The third processing submodule is configured to perform at least one of the following: if the ratio is less than a target threshold, determine the image within a rectangular region containing only the image identifier object as the target image, wherein the target threshold is obtained according to a pre-input image processing instruction;

[0164] If the ratio is greater than or equal to the target threshold, the initial color gamut deviation threshold is incrementally adjusted to obtain the incremental color gamut deviation threshold. Based on the incremental color gamut deviation threshold, each pixel in the pure background color image is traversed to obtain an updated transparent background image with a transparent background. If the ratio between the area of ​​the updated rectangle region determined by the target updated vertex in the updated transparent background image and the total area is less than the target threshold, the adjustment of the initial color gamut deviation threshold is stopped.

[0165] Optionally, the above-mentioned device further includes:

[0166] The second acquisition unit is used to sequentially acquire each pixel from the target image as the current pixel after obtaining the target image with a transparent background by cropping the transparent background image;

[0167] The first processing unit is configured to set the value of the current transparent channel of the current pixel to 0 when at least two of the four neighboring pixels adjacent to the current pixel have a transparent channel value of 0.

[0168] It should be noted that the embodiments of the image processing apparatus described here can refer to the embodiments of the image processing method described above, and will not be repeated here.

[0169] According to another aspect of the embodiments of this application, an electronic device for implementing the above-described image processing method is also provided. This electronic device may be... Figure 1 The target terminal or server is shown. This embodiment uses the electronic device as an example to illustrate the concept. Figure 10 As shown, the electronic device includes a memory 1002 and a processor 1004. The memory 1002 stores a computer program, and the processor 1004 is configured to execute the steps of any of the above method embodiments via the computer program.

[0170] Optionally, the aforementioned electronic device may be located in at least one of a plurality of network devices of the computer.

[0171] Optionally, the processor described above can be configured to perform the following steps via a computer program:

[0172] S1, Obtain the original image containing the image identifier object and background image elements;

[0173] S2, based on the pixel color distribution of the original image, convert the background color of the background image elements into a single background color, while retaining the original color of the image identifier object, to obtain a pure background color image;

[0174] S3, based on a single background color and a pre-set color gamut deviation threshold, traverses each pixel in the pure background color image to obtain a transparent background image;

[0175] S4: By cropping the transparent background image, the target image with a transparent background is obtained.

[0176] Alternatively, as those skilled in the art will understand, Figure 10 The structure shown is for illustrative purposes only. Figure 10 This does not limit the structure of the aforementioned electronic devices or electronic equipment. For example, electronic devices or electronic equipment may also include components that are more... Figure 10 The more or fewer components shown (such as network interfaces, etc.), or having the same Figure 10 The different configurations shown.

[0177] The memory 1002 can be used to store software programs and modules, such as the program instructions / modules corresponding to the image processing method and apparatus in this embodiment. The processor 1004 executes various functional applications and data processing by running the software programs and modules stored in the memory 1002, thereby implementing the aforementioned image processing method. The memory 1002 may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 1002 may further include memory remotely located relative to the processor 1004, and these remote memories can be connected to the terminal via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof. Specifically, the memory 1002 may be used, but is not limited to, to store target acquisition strategies, current gateway nodes, and adjusted wiper parameters, etc. As an example, such as... Figure 10 As shown, the memory 1002 may include, but is not limited to, the first acquisition unit 902, the first conversion unit 904, the first traversal unit 906, and the positioning unit 908 in the image processing device. Furthermore, it may include, but is not limited to, other module units in the image processing device, which will not be elaborated upon in this example.

[0178] Optionally, the transmission device 1006 described above is used to receive or send data via a network. Specific examples of the network described above may include wired networks and wireless networks. In one example, the transmission device 1006 includes a Network Interface Controller (NIC), which can be connected to other network devices and a router via a network cable to communicate with the Internet or a local area network. In another example, the transmission device 1006 is a Radio Frequency (RF) module, used for wireless communication with the Internet.

[0179] In addition, the above-mentioned electronic device also includes: a display 1008 for displaying a target image with a transparent background or transparent bottom obtained by processing according to the technical solution of this application; and a connection bus 1010 for connecting various module components in the above-mentioned electronic device.

[0180] In other embodiments, the target terminal or server described above can be a node in a distributed system. This distributed system can be a blockchain system, formed by connecting multiple nodes through network communication. The nodes can form a point-to-point network, and any type of computing device, such as a server or target terminal, can become a node in the blockchain system by joining this point-to-point network.

[0181] According to another aspect of this application, a computer program product or computer program is provided, comprising computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the image processing method provided in various optional implementations of the above-described server verification processing, wherein the computer program is configured to execute the steps in any of the above-described method embodiments at runtime.

[0182] Optionally, in this embodiment, the computer-readable storage medium described above may be configured to store a computer program for performing the following steps:

[0183] S1, Obtain the original image containing the image identifier object and background image elements;

[0184] S2, based on the pixel color distribution of the original image, convert the background color of the background image elements into a single background color, while retaining the original color of the image identifier object, to obtain a pure background color image;

[0185] S3, based on a single background color and a pre-set color gamut deviation threshold, traverses each pixel in the pure background color image to obtain a transparent background image;

[0186] S4, by cropping the transparent background image, a target image with a transparent background is obtained. Optionally, in the embodiments of this application, the term "module" or "unit" refers to a computer program or part of a computer program with a predetermined function, which works with other related parts to achieve a predetermined goal, and can be implemented wholly or partially using software, hardware (such as processing circuitry or memory), or a combination thereof. Similarly, a processor (or multiple processors or memory) can be used to implement one or more modules or units. Furthermore, each module or unit can be part of an overall module or unit that includes the functionality of that module or unit.

[0187] Optionally, in this embodiment, those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be implemented by a program instructing the hardware related to the target terminal. The program can be stored in a computer-readable storage medium, which may include: flash drive, read-only memory (ROM), random access memory (RAM), disk or optical disk, etc.

[0188] The sequence numbers of the embodiments in this application are merely for description and do not represent the superiority or inferiority of the embodiments. If the integrated units in the above embodiments are implemented as software functional units and sold or used as independent products, they can be stored in the aforementioned computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause one or more computer devices (which may be personal computers, servers, or network devices, etc.) to execute all or part of the steps of the methods in the various embodiments of this application.

[0189] In the above embodiments of this application, the descriptions of each embodiment have their own emphasis. Parts not described in detail in a certain embodiment can be referred to in the relevant descriptions of other embodiments. It should be understood that the disclosed client can be implemented in other ways in the several embodiments provided in this application. The device embodiments described above are merely illustrative; for example, the division of units is only a logical functional division. In actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the displayed or discussed mutual coupling or direct coupling or communication connection may be through some interfaces; the indirect coupling or communication connection of units or modules may be electrical or other forms.

[0190] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs. Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated units described above can be implemented in hardware or as software functional units.

[0191] The above are merely preferred embodiments of this application. It should be noted that those skilled in the art can make various improvements and modifications without departing from the principles of this application, and these improvements and modifications should also be considered within the scope of protection of this application.

Claims

1. An image processing method, characterized in that, include: Get the original image containing the image identifier object and background image elements; Based on the pixel color distribution of the original image, the background color of the background image elements is converted into a single background color, while retaining the original color of the image identifier object, to obtain a pure background color image; Based on the single background color and the preset color gamut deviation threshold, each pixel in the pure background color image is traversed to obtain a transparent background image; By cropping the transparent background image, a target image with a transparent background is obtained.

2. The method according to claim 1, characterized in that, The step of converting the background color of the background image elements into a single background color based on the pixel color distribution of the original image includes: By iterating through each pixel in the original image, a set of color values ​​composed of the combined color values ​​of each pixel is obtained. The spliced ​​color value of each pixel is determined as the first key value, and based on the first key value, a pre-created set of key value pairs is searched to obtain a statistical result of the number of pixels with the same color value. Based on the statistical results, the target color value with the largest number of pixels is determined from the set of color values, and the background color of the background image element is converted into the main background color indicated by the target color value.

3. The method according to claim 2, characterized in that, The process of traversing each pixel in the original image to obtain a set of color values ​​composed of the concatenated color values ​​of each pixel includes: Traverse each pixel in the original image to obtain the multi-channel color value of each pixel in multiple color channels; The multi-channel color values ​​of each pixel are concatenated to obtain each concatenated color value in the color value set.

4. The method according to claim 1, characterized in that, The process of obtaining a transparent background image by traversing each pixel in the pure background color image based on the single background color and a pre-set color gamut deviation threshold includes: Obtain the pre-set initial color gamut deviation threshold; Based on the initial color gamut deviation threshold and the target color value of the single background color, a target color range is constructed; The transparent background image is obtained by traversing each pixel in the pure background color image and setting the value of the transparent channel of at least some pixels whose multi-channel color values ​​are located within the target color range to 0.

5. The method according to claim 1, characterized in that, The step of cropping the transparent background image to obtain the target image with a transparent background includes: Traverse all pixels in the transparent background image whose transparency channel value is non-zero, determine the maximum horizontal coordinate value, minimum horizontal coordinate value, maximum vertical coordinate value, and minimum vertical coordinate value, and locate four target vertices, wherein the horizontal coordinate value of each of the four target vertices is the maximum horizontal coordinate value or the minimum horizontal coordinate value, and the vertical coordinate value of each target vertex is the maximum vertical coordinate value or the minimum vertical coordinate value. The target image is obtained by cropping the rectangular region formed by the four target vertices in the transparent background image.

6. The method according to claim 5, characterized in that, The process of cropping the rectangular region formed by the four target vertices in the transparent background image to obtain the target image includes: Determine the rectangular area of ​​the rectangular region; Determine the ratio between the area of ​​the rectangle and the total area occupied by the transparent background image, wherein the area occupied by the transparent background image is equal to the area occupied by the original image; Based on the ratio and the initial color gamut deviation threshold, the transparent background image is adaptively cropped to obtain the target image.

7. The method according to claim 6, characterized in that, The adaptive cropping of the transparent background image based on the ratio and the initial color gamut deviation threshold to obtain the target image includes at least one of the following: If the ratio is less than a target threshold, the image within the rectangular region containing only the image identifier object is determined as the target image, wherein the target threshold is obtained according to a pre-input image processing instruction; If the ratio is greater than or equal to the target threshold, the initial color gamut deviation threshold is incrementally adjusted to obtain an incremental color gamut deviation threshold. Based on the incremental color gamut deviation threshold, each pixel in the pure background color image is traversed to obtain an updated transparent background image with a transparent background. If the ratio between the area of ​​the updated rectangle region determined by the target updated vertex in the updated transparent background image and the total area is less than the target threshold, the adjustment of the initial color gamut deviation threshold is stopped.

8. The method according to any one of claims 1 to 7, characterized in that, After obtaining the target image with a transparent background by cropping the transparent background image, the method further includes: Each pixel in the target image is sequentially obtained as the current pixel; If at least two of the four neighboring pixels adjacent to the current pixel have an alpha channel value of 0, then the alpha channel value of the current pixel is set to 0.

9. An image processing apparatus, characterized in that, include: The first acquisition unit is used to acquire the original image containing the image identifier object and background image elements; The first conversion unit is used to convert the background color of the background image elements into a single background color based on the pixel color distribution of the original image, while retaining the original color of the image identification object, to obtain a pure background color image; The first traversal unit is used to traverse each pixel in the pure background color image based on the single background color and a preset color gamut deviation threshold to obtain a transparent background image. The cropping unit is used to crop the transparent background image to obtain a target image with a transparent background.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes a stored program, wherein the program can be executed by a terminal device or computer at runtime as described in any one of claims 1 to 8.

11. An electronic device comprising a memory and a processor, characterized in that, The memory stores a computer program, and the processor is configured to perform the method as described in any one of claims 1 to 8 through the computer program.