Bitmap generation method and device for producing pet identity card, equipment and medium

Through the one-click generation of pet identity tablet maps, the problems of complex operations and inefficiency in the existing technology are solved, and efficient bitmap generation and production processes are realized, reducing enterprise costs.

CN120070665APending Publication Date: 2025-05-30ZIXUN TECHNOLOGY (FUJIAN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510108349.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-23
Publication Date
2025-05-30

AI Technical Summary

Technical Problem

The prior art is complex in generating an identity tablet map with pet images, requiring multiple steps and a lot of manual processing, resulting in inefficient production and extended delivery time.

Method used

Through the pictures uploaded by users, the required bitmaps are generated in one click, including cutting, style conversion, frame synthesis and RGBA bitmap merging, and other steps, which are directly used for production.

Benefits of technology

It greatly improves work efficiency, reduces the workload of artists, shortens the design cycle, and reduces the costs of enterprises.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120070665A_ABST
    Figure CN120070665A_ABST
Patent Text Reader

Abstract

The invention provides a bitmap generation method and device for producing a pet identity card, equipment and a medium, and the method comprises the steps: carrying out the matting of a picture uploaded by a user, and obtaining a needed main body picture in the picture; converting the main body picture into a required style picture; synthesizing an outer frame bitmap with a set size and shape with the style picture to obtain a synthesized RGB picture; according to the method, the synthesized RGB image is converted into the single-channel grey-scale image, then the single-channel grey-scale image and the synthesized RGB image are combined into the RGBA bitmap, the needed bitmap is generated in a one-key mode through the image uploaded by the user and is directly used for production, and the working efficiency is greatly improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to a method, a device, equipment and a medium for generating a bitmap for producing a pet identification card. Background Art

[0002] At present, when factories are producing ID cards with pet images, since some production equipment can only recognize bitmaps, they need to generate bitmaps first and then input the bitmaps into the equipment before production can be carried out. At present, factories need to process the bitmap drafts of ID cards with pet images in multiple steps, as follows:

[0003] 1. You need to use PS or other special cutout tools to cut out the pet photos provided by the customer, keep the head or the whole body in the photo according to the user's requirements, and remove the background;

[0004] 2. You need to use the photocopy filter of tools such as PS or gimp to binarize the cutout result, or use manual hand-drawing to obtain binary images of various styles;

[0005] 3. Select the corresponding font in PS and add strings such as pet names;

[0006] 4. Add a frame image;

[0007] 5. Adjust the position and size of the pet binary image and text image;

[0008] 6. Make it into a transparent picture;

[0009] 7. Save the final bitmap for production;

[0010] 2. Shortcomings of the prior art.

[0011] The existing technology is complex to operate and requires a lot of manual processing. When the factory has a large number of orders, it often faces a shortage of graphic designers and needs to outsource the orders, which in turn extends the delivery time. Summary of the invention

[0012] The technical problem to be solved by the present invention is to provide a method, device, equipment and medium for producing a bitmap for a pet ID card. The required bitmap can be generated in one click through pictures uploaded by users and directly used for production, thereby greatly improving work efficiency.

[0013] In a first aspect, the present invention provides a method for generating a bitmap for producing a pet identification tag, comprising the following steps:

[0014] Step 1: Cut out the picture uploaded by the user to obtain the main picture required in the picture;

[0015] Step 2: Convert the main picture to generate the required style picture;

[0016] Step 3: Synthesize the outer frame bitmap with the set size and shape with the style picture to obtain a synthesized RGB picture;

[0017] Step 4: Convert the synthesized RGB picture to a single-channel grayscale picture, and then merge it with the synthesized RGB picture into an RGBA bitmap.

[0018] In a second aspect, the present invention provides a bitmap generation method device for producing a pet identification tag, including:

[0019] A main body matte extraction module that extracts the uploaded picture of the user to obtain the required main body picture in the picture;

[0020] A style conversion module that converts the main body picture to generate the required style picture;

[0021] A synthesized RGB picture module that synthesizes the outer frame bitmap with the set size and shape with the style picture to obtain a synthesized RGB picture;

[0022] A synthesized RGBA picture module that converts the synthesized RGB picture to a single-channel grayscale picture, and then merges it with the synthesized RGB picture into an RGBA bitmap.

[0023] In a third aspect, the present invention provides an electronic device, including a memory, a processor, and a computer program stored on the memory and executable on the processor. When the processor executes the program, the method described in the first aspect is implemented.

[0024] In a fourth aspect, the present invention provides a computer-readable storage medium, on which a computer program is stored. When the program is executed by a processor, the method described in the first aspect is implemented.

[0025] One or more technical solutions provided by the present invention have at least the following technical effects or advantages:

[0026] The technical solution of the present invention enables relevant factory personnel such as salesmen and customer service to directly generate the final bitmap for production with one click according to the requirements given by customers, making the bitmap effect meet the requirements, and no longer requiring graphic designers to process, greatly reducing the workload of graphic designers.

[0027] The above description is only an overview of the technical solution of the present invention. In order to be able to understand the technical means of the present invention more clearly, it can be implemented according to the content of the description. And in order to make the above and other purposes, features and advantages of the present invention more obvious and understandable, the following specific embodiments of the present invention are specifically given. BRIEF DESCRIPTION OF THE DRAWINGS

[0028] The present invention will be further described below with reference to the accompanying drawings in conjunction with the embodiments.

[0029] Figure 1 It is the flowchart of the method in Embodiment 1 of the present invention;

[0030] Figure 2 It is the structural schematic diagram of the device in Embodiment 2 of the present invention. Specific embodiments

[0031] By providing a bitmap generation method, device, equipment and medium for producing pet identity cards, the required bitmaps can be synthesized in one key, greatly improving the production efficiency and reducing the enterprise cost.

[0032] Embodiment 1

[0033] As Figure 1 shown, this embodiment provides a bitmap generation method for producing pet identity cards, including the following steps:

[0034] Step 1: Perform matting on the picture uploaded by the user to obtain the required main picture in the picture;

[0035] Step 2: Convert the main picture to generate the required style picture;

[0036] Step 3: Synthesize the outer frame bitmap with the set size and shape and the style picture to obtain a synthesized RGB picture;

[0037] Step 4: Convert the synthesized RGB picture to a single-channel grayscale picture, and then merge it with the synthesized RGB picture into an RGBA bitmap.

[0038] In this embodiment, preferably, step 1 is specifically as follows: Judge the pixels of the picture uploaded by the user. If the pixels of the picture are less than 2000×2000, directly perform matting operation through the visual intelligence open platform to obtain the required main picture; if the pixels of the picture are greater than or equal to 2000×2000, use Imgproc.resize in OpenCV with the Imgproc.INTER_LANCZ0S4 algorithm to scale the picture proportionally to obtain a scaled picture; perform matting operation on the scaled picture through the visual intelligence open platform to obtain a first mask picture; use Imgproc.resize in OpenCV with the Imgproc.INTER_LANCZ0S4 algorithm to proportionally restore the first mask picture to the second mask picture of the original size; read the alpha channel of each pixel point in the picture uploaded by the user to obtain a first matrix, read the alpha channel of each pixel point in the second mask picture to obtain a second matrix, and call Core.min to merge the first matrix and the second matrix to obtain a third matrix; replace the alpha channel in the picture uploaded by the user with the third matrix to obtain the required main picture;

[0039] Due to the cropping size limit of Alibaba Cloud Vision Intelligence Open Platform, when the longest side exceeds 2000 pixels, it is necessary to perform proportional scaling. Call Imgproc.resize and use the Imgproc.INTER_LANCZOS4 algorithm for image scaling.

[0040] Call Imgproc.resize and use the Imgproc.INTER_LANCZOS4 algorithm for image scaling. This algorithm can reduce the impact of artifacts while maintaining edge sharpness.

[0041] Obtain the cropping result based on the black and white image + original image:

[0042] a. Take out the alpha channel of the original image. Call Core.min, which will take the minimum value of the transparency channels of the mask and the original image to ensure that the original information of the transparency channel is retained. Through this step of processing, the lines of the obtained cropping can be made more perfect;

[0043] b. Remove the alpha channel of the original image and add the black and white image as the new alpha channel for layer merging;

[0044] c. Set the color value of the transparent area to black. This step is to reduce the size of the cropping result image and save storage costs.

[0045] The core code is as follows:

[0046] / / Create a fully transparent matrix with the same size as the original image for comparison;

[0047] Mat compareAlpha = new Mat(outImg.size(), CvType.CV_8UC1, Scalar.all(0.0));

[0048] / / Used to save the comparison result;

[0049] Mat compareResult = new Mat();

[0050] / / Compare the alpha channel of the original image with alpha. The positions with a value of 0 in the obtained mask are the transparent positions in the original image;

[0051] Core.compare(outPlanes.get(3), compareAlpha, compareResult, Core.CMP_EQ);

[0052] / / Create a fully black matrix with the same size as the original image;

[0053] Mat black = new Mat(outImg.size(), outImg.type(), Scalar.all(0));

[0054] / / Copy the black part in black to the corresponding position in outImg according to the mask;

[0055] Core.bitwise_and(black, outImg, outImg, compareResult);

[0056] In this embodiment, preferably, step 2 is specifically as follows: Obtain a style map of a set style, where the style map includes multiple pictures of the same set item in different proportions in the picture to obtain training data; Pass each style map through a multi-modal model to label it with a set format style label to form a corresponding label file; Set the number of training rounds, learning rate, and training image pixels, and then input the training data and the label file to perform Lora model training to obtain the required Lora style model; Then input the main picture, set prompt words, and the Lora style model into the diffusion model to generate the required style picture, and the diffusion model can be the StableDiffusion model.

[0057] In this embodiment, preferably, step 3 is specifically as follows: If text needs to be added, read the vector graphics of each character in the required string from a specified font file, and scale the vector graphics of each character according to the specified output size; Arrange the corresponding character vector graphics in the order of characters in the string, and convert the arranged string vector map into a character bitmap; Synthesize the character bitmap, the outer frame bitmap of the set size and shape, and the style picture to obtain a synthesized RGB picture;

[0058] If text does not need to be added, synthesize the outer frame bitmap of the set size and shape and the style picture to obtain a synthesized RGB picture.

[0059] Based on the same inventive concept, the present application also provides an apparatus corresponding to the method in Embodiment 1, as detailed in Embodiment 2.

[0060] Embodiment 2

[0061] As Figure 2 shown, in this embodiment, a bitmap generation method and apparatus for producing a pet identification tag are provided, including:

[0062] A main body matting module that mats the picture uploaded by the user to obtain the required main picture in the picture;

[0063] A style conversion module that converts the main picture into the required style picture;

[0064] The RGB image synthesis module synthesizes the outer frame bitmap with a set size and shape and the style image to obtain a synthesized RGB image;

[0065] The RGBA image synthesis module converts the synthesized RGB image into a single-channel grayscale image, and then merges it with the synthesized RGB image into an RGBA bitmap.

[0066] In this embodiment, preferably, the main body matte extraction module specifically: judges the pixels of the image uploaded by the user. If the pixels of the image are less than 2000×2000, directly perform matte extraction operation through the Visual Intelligence Open Platform to obtain the required main body image; if the pixels of the image are greater than or equal to 2000×2000, use the Imgproc.resize in OpenCV with the Imgproc.INTER_LANCZ0S4 algorithm to scale the image proportionally to obtain a scaled image; perform matte extraction operation on the scaled image through the Visual Intelligence Open Platform to obtain a first mask image; use the Imgproc.resize in OpenCV with the Imgproc.INTER_LANCZ0S4 algorithm to restore the first mask image proportionally to the original size to obtain a second mask image; read the alpha channel of each pixel point in the image uploaded by the user to obtain a first matrix, read the alpha channel of each pixel point in the second mask image to obtain a second matrix, and call Core.min to merge the first matrix and the second matrix to obtain a third matrix; replace the alpha channel in the image uploaded by the user with the third matrix to obtain the required main body image.

[0067] In this embodiment, preferably, the style conversion module specifically: obtains a style image of a set style, and the style image includes multiple images of the same set item in different proportions in the picture to obtain training data; tags each style image through a multimodal model according to a set format style label to form a corresponding label file; sets the number of training rounds, learning rate, and training image pixels, and then inputs the training data and the label file for Lora model training to obtain the required Lora style model; then inputs the main body image, set prompt words, and the Lora style model into a diffusion model to generate the required style image.

[0068] In this embodiment, preferably, the RGB image synthesis module specifically: if text needs to be added, reads the vector graphics of each character in the required string from a specified font file, and scales the vector graphics of each character according to the specified output size; arranges the corresponding character vector graphics in the order of characters in the string, and converts the arranged string vector graphics into a character bitmap; synthesizes the character bitmap, the outer frame bitmap with a set size and shape, and the style image to obtain a synthesized RGB image;

[0069] If no text needs to be added, the outline bitmap of the set size and shape is synthesized with the style picture to obtain a synthesized RGB picture.

[0070] Since the device introduced in the second embodiment of the present invention is the device adopted for implementing the method of the first embodiment of the present invention, based on the method introduced in the first embodiment of the present invention, those skilled in the art can understand the specific structure and variations of the device, so it will not be elaborated here. Any device adopted for the method of the first embodiment of the present invention belongs to the scope protected by the present invention.

[0071] Based on the same inventive concept, this application provides an electronic device embodiment corresponding to the first embodiment, as detailed in the third embodiment.

[0072] Embodiment Three

[0073] This embodiment provides an electronic device, including a memory, a processor, and a computer program stored on the memory and executable on the processor. When the processor executes the computer program, any implementation manner in the first embodiment can be realized.

[0074] Since the electronic device introduced in this embodiment is the device adopted for implementing the method in the first embodiment of this application, based on the method introduced in the first embodiment of this application, those skilled in the art can understand the specific implementation manners and various variations of the electronic device in this embodiment. Therefore, how the electronic device realizes the method in the embodiments of this application will not be introduced in detail here. Any device adopted by those skilled in the art for implementing the method in the embodiments of this application belongs to the scope protected by this application.

[0075] Based on the same inventive concept, this application provides a storage medium corresponding to the first embodiment, as detailed in the fourth embodiment.

[0076] Embodiment Four

[0077] This embodiment provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, any implementation manner in the first embodiment can be realized.

[0078] The technical solutions provided in the embodiments of this application at least have the following technical effects or advantages:

[0079] In this embodiment, the final production bitmap can be generated with one key by the user uploading a picture and setting a style. When the user confirms that the effect of the bitmap meets the requirements, there is no need for graphic designers to process it, greatly reducing the workload of graphic designers; this greatly improves the production efficiency, shortens the design cycle before production, and does not require the participation of graphic designers, greatly reducing the cost of the enterprise.

[0080] Those skilled in the art should understand that the embodiments of the present invention can be provided as a method, a system, or a computer program product. Therefore, the present invention can take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present invention can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk memory, CD-ROM, optical memory, etc.) that contain computer-usable program code.

[0081] The present invention is described with reference to the flowcharts and / or block diagrams of methods, apparatuses (systems), and computer program products according to the embodiments of the present invention. It should be understood that each flow and / or block in the flowchart and / or block diagram, and the combination of flows and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing devices to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing devices generate means for implementing the functions specified in one Figure 1 flow or multiple flows and / or blocks Figure 1 or multiple blocks.

[0082] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer-readable memory generate a manufactured article including instruction means, and the instruction means implement the functions specified in one Figure 1 flow or multiple flows and / or blocks Figure 1 or multiple blocks.

[0083] These computer program instructions can also be loaded onto a computer or other programmable data processing device, so that a series of operation steps are executed on the computer or other programmable device to generate a computer-implemented process, and thus the instructions executed on the computer or other programmable device provide steps for implementing the functions specified in one Figure 1 flow or multiple flows and / or blocks Figure 1 or multiple blocks.

[0084] Although the specific embodiments of the present invention have been described above, those skilled in the art should understand that the specific embodiments we described are illustrative rather than used to limit the scope of the present invention. Equivalent modifications and variations made by those skilled in the art in accordance with the spirit of the present invention should be covered by the scope protected by the claims of the present invention.

Claims

1. A method for generating a bitmap for producing a pet identification card, characterized in that: The steps include: Step 1: Cut out the picture uploaded by the user to obtain the main picture required in the picture; Step 2: Convert the main image into the required style image; Step 3, synthesizing the frame bitmap of set size and shape with the style image to obtain a synthesized RGB image; Step 4: convert the synthesized RGB image into a single-channel grayscale image, and then merge it with the synthesized RGB image into an RGBA bitmap.

2. The method for generating a bitmap for producing a pet identification card according to claim 1, characterized in that: The step 1 is specifically as follows: judging the pixels of the picture uploaded by the user, if the pixels of the picture are less than 2000×2000, directly performing a cutout operation through the visual intelligence open platform to obtain the required main picture; if the pixels of the picture are greater than or equal to 2000×2000, using Imgproc.resize in OpenCV and using the Imgproc.INTER_LANCZ0S4 algorithm to scale the picture in equal proportion to obtain a scaled picture; performing a cutout operation on the scaled picture through the visual intelligence open platform to obtain a first mask picture; restoring the first mask picture to a second mask picture of the original size in equal proportion through Imgproc.resize in OpenCV and using the Imgproc.INTER_LANCZ0S4 algorithm; reading out the transparent channel of each pixel in the picture uploaded by the user to obtain a first matrix, reading out the transparent channel of each pixel in the second mask picture to obtain a second matrix, calling Core.min to merge the first matrix with the second matrix to obtain a third matrix; The transparent channel in the picture uploaded by the user is replaced by the third matrix to obtain the required main picture.

3. The method for generating a bitmap for producing a pet ID tag according to claim 1, characterized in that: The step 2 is specifically as follows: obtaining a style map of a set style, wherein the style map includes multiple pictures of the same set object in different proportions in the pictures, and obtaining training data; labeling each of the style maps according to a set format style label through a multimodal model to form a corresponding label file; setting the number of training rounds, learning rate, and training image pixels, and then inputting the training data and the label file to perform Lora model training to obtain the required Lora style model; and then inputting the main picture, the set prompt words, and the Lora style model into the diffusion model to generate the required style picture.

4. The method for generating a bitmap for producing a pet identification card according to claim 1, characterized in that: The step 3 specifically includes: if text needs to be added, the vector graphics of each character in the required string are read from the specified font file, and the vector graphics of each character are scaled according to the specified output size; Arrange the corresponding character vector graphics according to the order of characters in the string, and convert the arranged string vector graphics into character bitmaps; The character bitmap, the frame bitmap with set size and shape are synthesized with the style image to obtain a synthesized RGB image; If no text needs to be added, the frame bitmap of the set size and shape is synthesized with the style image to obtain a synthesized RGB image.

5. A method and device for producing a bitmap for producing a pet identification card, characterized in that: include: The main image cutout module cuts out the image uploaded by the user to obtain the main image required in the image; Style conversion module, converting the main image into the required style image; A synthetic RGB image module is used to synthesize the frame bitmap of a set size and shape with the style image to obtain a synthetic RGB image; The synthetic RGBA image module converts the synthetic RGB image into a single-channel grayscale image, and then merges it with the synthetic RGB image into an RGBA bitmap.

6. The method and device for producing a bitmap for producing a pet ID tag according to claim 5, characterized in that: The subject cutout module is specifically as follows: the pixels of the picture uploaded by the user are judged. If the pixels of the picture are less than 2000×2000, the cutout operation is directly performed through the visual intelligence open platform to obtain the required subject picture; if the pixels of the picture are greater than or equal to 2000×2000, the picture is scaled in proportion using the Imgproc.resize in OpenCV and the Imgproc.INTER_LANCZ0S4 algorithm to obtain a scaled picture; the scaled picture is cutout through the visual intelligence open platform to obtain a first mask picture; the first mask picture is proportionally restored to a second mask picture of the original size through the Imgproc.resize in OpenCV and the Imgproc.INTER_LANCZ0S4 algorithm; the transparent channel of each pixel in the picture uploaded by the user is read out to obtain a first matrix, the transparent channel of each pixel in the second mask picture is read out to obtain a second matrix, and Core.min is called to merge the first matrix with the second matrix to obtain a third matrix; The transparent channel in the picture uploaded by the user is replaced by the third matrix to obtain the required main picture.

7. The method and device for producing a bitmap for producing a pet ID tag according to claim 5, characterized in that: The style conversion module is specifically as follows: obtaining a style map of a set style, wherein the style map includes multiple pictures of the same set object in different proportions in the picture, and obtaining training data; labeling each of the style maps according to the set format style label through a multimodal model to form a corresponding label file; setting the number of training rounds, learning rate and training image pixels, and then inputting the training data and the label file to perform Lora model training to obtain the required Lora style model; and then inputting the main picture, the set prompt words and the Lora style model into the diffusion model to generate the required style picture.

8. The method and device for producing a bitmap for producing a pet ID tag according to claim 5, characterized in that: The synthetic RGB image module specifically includes: if text needs to be added, the vector graphics of each character in the required string are read from the specified font file, and the vector graphics of each character are scaled according to the specified output size; Arrange the corresponding character vector graphics according to the order of characters in the string, and convert the arranged string vector graphics into character bitmaps; The character bitmap, the frame bitmap with set size and shape are synthesized with the style image to obtain a synthesized RGB image; If no text needs to be added, the frame bitmap of the set size and shape is synthesized with the style image to obtain a synthesized RGB image.

9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the method according to any one of claims 1 to 4 is implemented.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 4 is implemented.