A certificate image fusion processing method, device and computer readable storage medium
By acquiring the connected component edge information of ID card images through deep learning, processing them in blocks and filtering them, the problem of unclear background pixel distinction in the transition area around the portrait in ID card image fusion is solved, achieving high-precision ID card image fusion and improving user experience.
Patent Information
- Application Number
- CN202310092007.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-01-16
- Publication Date
- 2026-06-19
- Estimated Expiration
- 2043-01-16
Smart Images

Figure CN115995112B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image processing technology, and in particular to a method, apparatus and computer-readable storage medium for fusion processing of document images. Background Technology
[0002] In the current technology, with the continuous development of smart terminal devices, users' demands for derivative functions of image capture are becoming increasingly diverse. In particular, the document image function based on image fusion is becoming increasingly popular among users.
[0003] However, the current ID photo function has certain shortcomings in accuracy. Specifically, when using the mask image extracted by the existing algorithm to fuse the background and foreground, if some background pixels in the transition area around the portrait are not well distinguished, the final fusion effect will be unsatisfactory.
[0004] Therefore, improving the processing accuracy of the transition area around the portrait during document image fusion processing has become an urgent technical problem to be solved. Summary of the Invention
[0005] To address the aforementioned technical deficiencies in the prior art, this invention proposes a document image fusion processing method, which includes:
[0006] When an initial ID image containing a human image is obtained, a human image mask image of the initial ID image is obtained based on a preset deep learning method, and the connected components of the human image mask image are calculated and the number of connected components is counted.
[0007] Obtain the edge information of the connected region with the largest area, and calculate the first image block of the portrait mask image based on the edge information. At the same time, set the pixels of the other connected regions as the background of the initial document image.
[0008] Combine the portrait mask image to obtain a second image block in the initial document image that corresponds to a random point on the main edge of the portrait image;
[0009] The portrait mask image is filtered based on the initial document image and the second image block to obtain an updated portrait mask image, and a preset document image fusion operation is performed based on the updated portrait mask image.
[0010] Optionally, the step of obtaining a second image patch in the initial document image corresponding to a randomly selected point on the main edge of the portrait image, based on the portrait mask image, includes:
[0011] Randomly select a starting point a(a_x, a_y) on the edge of the main body;
[0012] Starting from point a, search for all pixels F(x, y) within a preset region T of point a using an 8-neighborhood approach: |x - a_x| + |y - a_y| <T。
[0013] Optionally, the step of obtaining a second image patch in the initial document image by combining the portrait mask image with a randomly selected point on the main edge of the portrait image further includes:
[0014] The current search stops when the number of pixels satisfying the preset conditions among all pixels F(x, y) in the preset region T reaches a preset number;
[0015] Calculate the smallest bounding rectangle containing the inner line segment of point a, and use the smallest bounding rectangle as the second image block of the portrait mask image corresponding to point a.
[0016] Optionally, the step of obtaining a second image patch in the initial document image by combining the portrait mask image with a randomly selected point on the main edge of the portrait image further includes:
[0017] Save the calculated second image block, and set the edge points within the range of the saved second image block to zero, so that the zeroed edge points are not searched again;
[0018] Repeat the random point selection and edge point zeroing operations to obtain all the second image blocks of the subject edge.
[0019] Optionally, the step of filtering the portrait mask image based on the initial ID image and the second image block to obtain an updated portrait mask image, and performing a preset ID image fusion operation based on the updated portrait mask image, includes:
[0020] Obtain the source image block in the initial document image that corresponds to the second image block;
[0021] The source image block is used as a guide image to filter the second image block.
[0022] Optionally, the step of filtering the portrait mask image based on the initial document image and the second image block to obtain an updated portrait mask image, and performing a preset document image fusion operation based on the updated portrait mask image, further includes:
[0023] The filtering operation is performed on all the second image blocks in the portrait mask image;
[0024] Obtain the first original coordinate information of all the second image blocks after the filtering operation.
[0025] Optionally, the step of filtering the portrait mask image based on the initial document image and the second image block to obtain an updated portrait mask image, and performing a preset document image fusion operation based on the updated portrait mask image, further includes:
[0026] Obtain the second original coordinate information of the source image block corresponding to the second image block;
[0027] The second original coordinate information is replaced with the first original coordinate information to obtain the updated portrait mask image.
[0028] Optionally, the method further includes:
[0029] When the portrait mask image is obtained, the portrait mask image and the initial document image are divided into blocks according to the edge information of the portrait mask image;
[0030] Based on the coordinate information of the source image block in the initial document image, the second image block in the portrait mask image that corresponds one-to-one with the coordinate information is determined.
[0031] The present invention also proposes an identification image fusion processing device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the computer program is executed by the processor, it implements the steps of the identification image fusion processing method as described in any of the preceding claims.
[0032] The present invention also proposes a computer-readable storage medium storing an ID card image fusion processing program, which, when executed by a processor, implements the steps of the ID card image fusion processing method as described in any of the preceding claims.
[0033] The document image fusion processing method, device, and computer-readable storage medium of the present invention, when acquiring an initial document image containing a portrait image, obtains a portrait mask image of the initial document image based on preset deep learning, calculates the connected components of the portrait mask image, and counts the number of connected components; obtains the edge information of the connected component with the largest area, and calculates a first image block of the portrait mask image based on the edge information, while setting the pixels of the other connected components as the background of the initial document image; combines the portrait mask image to obtain a second image block in the initial document image corresponding to a randomly selected point on the main edge of the portrait image; filters the portrait mask image based on the initial document image and the second image block to obtain an updated portrait mask image, and performs a preset document image fusion operation based on the updated portrait mask image. This achieves a high-precision document image fusion processing scheme, greatly improving the portrait processing accuracy and final fusion effect during document image fusion, and enhancing the user experience of the document shooting function. Attached Figure Description
[0034] The present invention will be further described below with reference to the accompanying drawings and embodiments. In the accompanying drawings:
[0035] Figure 1 This is a schematic diagram of the hardware structure of a mobile terminal according to the present invention;
[0036] Figure 2 This is the first flowchart of the document image fusion processing method of the present invention;
[0037] Figure 3 This is the second flowchart of the document image fusion processing method of the present invention;
[0038] Figure 4 This is the third flowchart of the document image fusion processing method of the present invention;
[0039] Figure 5 This is the fourth flowchart of the document image fusion processing method of the present invention;
[0040] Figure 6 This is the fifth flowchart of the document image fusion processing method of the present invention;
[0041] Figure 7 This is the sixth flowchart of the document image fusion processing method of the present invention;
[0042] Figure 8 This is the seventh flowchart of the document image fusion processing method of the present invention;
[0043] Figure 9 This is the eighth flowchart of the document image fusion processing method of the present invention;
[0044] Figures 10-19 This is a schematic diagram of the image fusion processing method for document images according to the present invention. Detailed Implementation
[0045] It should be understood that the specific embodiments described herein are for illustrative purposes only and are not intended to limit the scope of the invention.
[0046] In the following description, the use of suffixes such as "module," "part," or "unit" to denote elements is solely for the purpose of illustrative purposes and has no specific meaning in itself. Therefore, "module," "part," or "unit" may be used interchangeably.
[0047] Terminals can be implemented in various forms. For example, the terminals described in this invention may include mobile terminals such as mobile phones, tablets, laptops, handheld computers, personal digital assistants (PDAs), portable media players (PMPs), navigation devices, wearable devices, smart bracelets, pedometers, etc., as well as fixed terminals such as digital TVs and desktop computers.
[0048] The following description will use a mobile terminal as an example. Those skilled in the art will understand that, apart from elements specifically designed for mobile purposes, the construction according to embodiments of the present invention can also be applied to fixed-type terminals.
[0049] Please see Figure 1 This is a schematic diagram of the hardware structure of a mobile terminal implementing various embodiments of the present invention. The mobile terminal 100 may include: an RF (Radio Frequency) unit 101, a WiFi module 102, an audio output unit 103, an A / V (Audio / Video) input unit 104, a sensor 105, a display unit 106, a user input unit 107, an interface unit 108, a memory 109, a processor 110, and a power supply 111, etc. Those skilled in the art will understand that... Figure 1 The mobile terminal structure shown does not constitute a limitation on the mobile terminal. The mobile terminal may include more or fewer components than shown, or combine certain components, or have different component arrangements.
[0050] The following is combined with Figure 1 A detailed introduction to each component of the mobile terminal:
[0051] The radio frequency unit 101 can be used for receiving and transmitting signals during information transmission or calls. Specifically, it receives downlink information from the base station and processes it with the processor 110; additionally, it transmits uplink data to the base station. Typically, the radio frequency unit 101 includes, but is not limited to, an antenna, at least one amplifier, a transceiver, a coupler, a low-noise amplifier, and a duplexer. Furthermore, the radio frequency unit 101 can also communicate wirelessly with networks and other devices. The aforementioned wireless communications may use any communication standard or protocol, including but not limited to GSM (Global System of Mobile communication), GPRS (General Packet Radio Service), CDMA2000 (Code Division Multiple Access 2000), WCDMA (Wideband Code Division Multiple Access), TD-SCDMA (Time Division-Synchronous Code Division Multiple Access), FDD-LTE (Frequency Division Duplexing-Long Term Evolution), and TDD-LTE (Time Division Duplexing-Long Term Evolution).
[0052] WiFi is a short-range wireless transmission technology. Mobile terminals, through the WiFi module 102, can help users send and receive emails, browse web pages, and access streaming media, providing users with wireless broadband internet access. Although Figure 1 WiFi module 102 is shown, but it is understood that it is not a necessary component of a mobile terminal and can be omitted as needed without changing the nature of the invention.
[0053] The audio output unit 103 can convert audio data received by the radio frequency unit 101 or the WiFi module 102 or stored in the memory 109 into audio signals and output them as sound when the mobile terminal 100 is in call signal receiving mode, call mode, recording mode, voice recognition mode, broadcast receiving mode, etc. Furthermore, the audio output unit 103 can also provide audio output related to specific functions performed by the mobile terminal 100 (e.g., call signal receiving sound, message receiving sound, etc.). The audio output unit 103 may include a speaker, a buzzer, etc.
[0054] The A / V input unit 104 is used to receive audio or video signals. The A / V input unit 104 may include a graphics processing unit (GPU) 1041 and a microphone 1042. The GPU 1041 processes image data of still images or videos acquired by an image capture device (such as a camera) in video capture mode or image capture mode. The processed image frames can be displayed on the display unit 106. The image frames processed by the GPU 1041 can be stored in the memory 109 (or other storage medium) or transmitted via the radio frequency unit 101 or the WiFi module 102. The microphone 1042 can receive sound (audio data) in operating modes such as telephone call mode, recording mode, and voice recognition mode, and can process such sound into audio data. The processed audio (voice) data can be converted into a format that can be transmitted to a mobile communication base station via the radio frequency unit 101 in telephone call mode. The microphone 1042 can implement various types of noise cancellation (or suppression) algorithms to eliminate (or suppress) noise or interference generated during the reception and transmission of audio signals.
[0055] The mobile terminal 100 also includes at least one sensor 105, such as a light sensor, a motion sensor, and other sensors. Specifically, the light sensor includes an ambient light sensor and a proximity sensor. The ambient light sensor can adjust the brightness of the display panel 1061 according to the ambient light level, and the proximity sensor can turn off the display panel 1061 and / or backlight when the mobile terminal 100 is moved to the ear. As a type of motion sensor, the accelerometer sensor can detect the magnitude of acceleration in various directions (generally three axes). When stationary, it can detect the magnitude and direction of gravity and can be used for applications that recognize the phone's posture (such as landscape / portrait switching, related games, magnetometer posture calibration), vibration recognition-related functions (such as pedometer, tapping), etc. Other sensors that may be configured in the phone, such as fingerprint sensors, pressure sensors, iris sensors, molecular sensors, gyroscopes, barometers, hygrometers, thermometers, and infrared sensors, will not be described in detail here.
[0056] The display unit 106 is used to display information input by the user or information provided to the user. The display unit 106 may include a display panel 1061, which may be configured in the form of a liquid crystal display (LCD), an organic light-emitting diode (OLED), or the like.
[0057] User input unit 107 can be used to receive input numerical or character information, and generate key signal inputs related to user settings and function control of the mobile terminal. Specifically, user input unit 107 may include touch panel 1071 and other input devices 1072. Touch panel 1071, also known as touch screen, can collect touch operations on or near the user (such as operations performed by the user using a finger, stylus, or any suitable object or accessory on or near touch panel 1071), and drive corresponding connection devices according to a pre-set program. Touch panel 1071 may include two parts: a touch detection device and a touch controller. The touch detection device detects the user's touch position and the signal generated by the touch operation, and transmits the signal to the touch controller; the touch controller receives touch information from the touch detection device, converts it into touch point coordinates, sends it to processor 110, and can receive and execute commands from processor 110. In addition, touch panel 1071 can be implemented using various types such as resistive, capacitive, infrared, and surface acoustic wave. In addition to the touch panel 1071, the user input unit 107 may also include other input devices 1072. Specifically, other input devices 1072 may include, but are not limited to, one or more of the following: physical keyboard, function keys (such as volume control buttons, power buttons, etc.), trackball, mouse, joystick, etc., without being limited here.
[0058] Furthermore, the touch panel 1071 may cover the display panel 1061. When the touch panel 1071 detects a touch operation on or near it, it transmits the information to the processor 110 to determine the type of touch event. Subsequently, the processor 110 provides corresponding visual output on the display panel 1061 based on the type of touch event. Although in Figure 1 In this embodiment, the touch panel 1071 and the display panel 1061 are two independent components to realize the input and output functions of the mobile terminal. However, in some embodiments, the touch panel 1071 and the display panel 1061 can be integrated to realize the input and output functions of the mobile terminal. The specific implementation is not limited here.
[0059] Interface unit 108 serves as an interface through which at least one external device can connect to mobile terminal 100. For example, the external device may include a wired or wireless headset port, an external power supply (or battery charger) port, a wired or wireless data port, a memory card port, a port for connecting a device with an identification module, an audio input / output (I / O) port, a video I / O port, a headphone port, and so on. Interface unit 108 may be used to receive input (e.g., data, power, etc.) from the external device and transmit the received input to one or more elements within mobile terminal 100, or it may be used to transmit data between mobile terminal 100 and the external device.
[0060] The memory 109 can be used to store software programs and various data. The memory 109 may primarily include a program storage area and a data storage area. The program storage area may store the operating system, applications required for at least one function (such as sound playback, image playback, etc.), etc.; the data storage area may store data created based on the use of the mobile phone (such as audio data, phonebook, etc.). Furthermore, the memory 109 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other volatile solid-state storage device.
[0061] The processor 110 is the control center of the mobile terminal. It connects various parts of the mobile terminal via various interfaces and lines. By running or executing software programs and / or modules stored in the memory 109, and by calling data stored in the memory 109, it performs various functions and processes data of the mobile terminal, thereby providing overall monitoring of the mobile terminal. The processor 110 may include one or more processing units; preferably, the processor 110 may integrate an application processor and a modem processor. The application processor mainly handles the operating system, user interface, and applications, while the modem processor mainly handles wireless communication. It is understood that the modem processor may not be integrated into the processor 110.
[0062] The mobile terminal 100 may also include a power supply 111 (such as a battery) that supplies power to various components. Preferably, the power supply 111 can be logically connected to the processor 110 through a power management system, thereby enabling functions such as charging, discharging, and power consumption management through the power management system.
[0063] although Figure 1 As not shown, the mobile terminal 100 may also include a Bluetooth module, etc., which will not be described in detail here.
[0064] Based on the above-described mobile terminal hardware structure, various embodiments of the method of the present invention are proposed.
[0065] Figure 2 This is a first flowchart of the document image fusion processing method of the present invention. This embodiment proposes a document image fusion processing method, which includes:
[0066] S1. When an initial ID image containing a human image is obtained, a human image mask image of the initial ID image is obtained based on a preset deep learning method, and the connected components of the human image mask image are calculated and the number of connected components is counted.
[0067] S2. Obtain the edge information of the connected region with the largest area, and calculate the first image block of the portrait mask image based on the edge information. At the same time, set the pixels of the other connected regions as the background of the initial document image.
[0068] S3. Combine the portrait mask image to obtain the second image block in the initial document image that corresponds to a random point on the main edge of the portrait image;
[0069] S4. Filter the portrait mask image based on the initial document image and the second image block to obtain an updated portrait mask image, and perform a preset document image fusion operation based on the updated portrait mask image.
[0070] In this embodiment, firstly, a portrait image is acquired, and an initial portrait mask image is obtained based on deep learning. The connected components of the mask image are calculated, and the number of connected components is counted. Then, the connected component A with the largest area is selected, and all pixels in other connected components are set as background. The edge information of connected component A is acquired, and the batch (image patch) of the mask (portrait mask image) is calculated based on the edge information. Next, the corresponding batch is obtained in the source image in the same way based on the acquired mask information. Finally, the mask is filtered by combining the batch information of the source image and the mask, thereby improving the mask. Finally, the ID photo image fusion is performed based on the acquired new portrait mask image.
[0071] Please refer to Figure 3 Optionally, the step of obtaining a second image patch in the initial document image corresponding to a randomly selected point on the main edge of the portrait image, in conjunction with the portrait mask image, includes:
[0072] S31. Randomly select a starting point a(a_x, a_y) on the edge of the main body;
[0073] S32. Starting from point a, search for all pixels F(x, y) within a preset region T of point a using an 8-neighborhood approach: |x-a_x|+|y-a_y| <T。
[0074] Please refer to Figure 4 Optionally, the step of obtaining a second image patch in the initial document image by combining the portrait mask image with a randomly selected point on the main edge of the portrait image further includes:
[0075] S33. When the number of pixels satisfying the preset conditions among all pixels F(x, y) in the preset area T reaches a preset number, stop the current search;
[0076] S34. Calculate the smallest bounding rectangle containing the inner line segment of point a, and use the smallest bounding rectangle as the second image block of the portrait mask image corresponding to point a.
[0077] Please refer to Figure 5 Optionally, the step of obtaining a second image patch in the initial document image by combining the portrait mask image with a randomly selected point on the main edge of the portrait image further includes:
[0078] S35. Save the calculated second image block, and set the edge points within the range of the saved second image block to zero, so that the zeroed edge points are not searched a second time;
[0079] S36. Repeat the operation of randomly selecting points and setting the edge points to zero to obtain all the second image blocks of the subject edge.
[0080] Please refer to Figure 6 Optionally, the step of filtering the portrait mask image based on the initial document image and the second image block to obtain an updated portrait mask image, and performing a preset document image fusion operation based on the updated portrait mask image, includes:
[0081] S41. Obtain the source image block in the initial document image that corresponds to the second image block;
[0082] S42. Use the source image block as a guide image to filter the second image block.
[0083] Please refer to Figure 7 Optionally, the step of filtering the portrait mask image based on the initial document image and the second image block to obtain an updated portrait mask image, and performing a preset document image fusion operation based on the updated portrait mask image, further includes:
[0084] S43. Perform the filtering operation on all the second image blocks in the portrait mask image;
[0085] S44. Obtain the first original coordinate information of all the second image blocks after the filtering operation.
[0086] Please refer to Figure 8 Optionally, the step of filtering the portrait mask image based on the initial document image and the second image block to obtain an updated portrait mask image, and performing a preset document image fusion operation based on the updated portrait mask image, further includes:
[0087] S45. Obtain the second original coordinate information of the source image block corresponding to the second image block;
[0088] S46. Replace the second original coordinate information with the first original coordinate information to obtain the updated portrait mask image.
[0089] Please refer to Figure 9 Optionally, the method further includes:
[0090] S11. When the portrait mask image is obtained, the portrait mask image and the initial document image are divided into blocks according to the edge information of the portrait mask image;
[0091] S12. Based on the coordinate information of the source image block in the initial document image, determine the second image block in the portrait mask image that corresponds one-to-one with the coordinate information.
[0092] In this embodiment, please refer to Figure 10 , Figure 11 as well as Figure 12 Considering the current limitations in the accuracy of ID photo functions, among other things... Figure 10 This is the original image. Figure 11 The mask image extracted by the current algorithm. Figure 12 This is the result of background and foreground fusion based on the mask image. It can be seen that in the current fusion result, some background pixels in the transition area around the portrait are not well distinguished, resulting in an unsatisfactory final fusion effect. To solve the above technical problem, this embodiment proposes a technical solution to improve the accuracy of ID photo image fusion. Please refer to... Figure 13 , Figure 14 as well as Figure 15 Specifically, firstly, based on the initially extracted portrait mask image, the portrait mask image and the source image (i.e., the initial ID image) are divided into blocks according to the edge information of the portrait mask image, such as... Figure 13 and Figure 14 As shown:
[0093] Batch_mask_i,ji,j=0,…,k;
[0094] Batch_src_i,ji,j=0,...k.
[0095] Where Batch_src_i,j represents the image batch (i.e., image block) extracted from the source image, and its coordinate information corresponds one-to-one with the coordinate information of Batch_mask_i,j.
[0096] Then, filtering is performed on each group of blocks (i.e., each batch of the portrait mask image and the source image corresponds one-to-one), and the resulting filtering effect is as follows. Figure 15As shown, it is clear that the final extraction accuracy has been significantly improved.
[0097] Finally, as Figure 16 and Figure 17 As shown, the segmented, enhanced portrait mask images are stitched together to form a complete image, thus obtaining the final fusion effect with improved accuracy.
[0098] In this embodiment, the algorithm for block division and filtering described above will be further explained below:
[0099] Based on deep learning, a human face mask image is calculated, such as... Figure 11 As shown in the image, the acquired mask image contains some errors in the transition area between the foreground and background of the portrait. Some background pixels are incorrectly classified as foreground pixels, which reduces the final fusion effect. Figure 12 As shown.
[0100] In this embodiment, the number of connected components in the mask image is calculated. If the number of connected components is greater than one, the connected component with the largest area is selected, and all other smaller connected components are set as the background. For example... Figure 18 As shown, due to various reasons, the initial mask may contain unexpected interfering parts, such as the white area in the upper left corner of a portrait, which might be unnecessary portrait information behind the background. These interfering factors need to be eliminated, leaving only the largest area of subject information.
[0101] In this embodiment, the edges of the connected components with the largest area are extracted. Since the mask image is a simple binary image, edges can be extracted from the mask, i.e., as shown below. Figure 19 As shown.
[0102] In this embodiment, the mask image patch to be extracted is obtained based on edge information. Specifically:
[0103] First, such as Figure 19 As shown, a starting point a(a_x, a_y) can be randomly selected on the edge of the main body. Starting from point a, all pixels within a region T of point a are searched using an 8-neighborhood approach:
[0104] F(x, y): |x - a_x| + |y - a_y| <T。
[0105] Then, when the number of pixels satisfying the condition F(x, y) reaches a certain number num, the current search is stopped, and the minimum bounding rectangle containing the inner line segment of point a is calculated. This minimum bounding rectangle is the batch calculated in the current mask a.
[0106] Finally, save the batch information by setting all edge points within the saved batch range to 0, so that they cannot be searched a second time.
[0107] In this embodiment, the above three steps are repeated to obtain all batches.
[0108] In this embodiment, with Figure 13 and Figure 14 To obtain a batch example, the next step is to process that batch in the mask (i.e. Figure 14 This embodiment introduces the concept of guided filtering to perform guided filtering on batch_current. Specifically:
[0109] First, using the source graph batch (hereinafter referred to as batch_src) corresponding to batch_current as the guide graph, batch_current is filtered. The purpose of using batch_src as the guide graph is to ensure that the filtering result preserves the gradient information of batch_src. Figure 13 The hair in the portrait shown carries very rich gradient information. Therefore, the filtering result is as follows: Figure 15 This significantly improves the accuracy of batch_curent.
[0110] Then, as shown in the steps above, guided filtering is performed on all batches within the mask.
[0111] Finally, all filtered batches within the human face mask are directly replaced with the original batches according to the previously saved coordinate information, thus obtaining the final high-precision mask_new.
[0112] In this embodiment, high-precision mask_new is used in the final image fusion.
[0113] The beneficial effect of this embodiment is that, upon acquiring an initial ID image containing a portrait image, a portrait mask image of the initial ID image is obtained based on preset deep learning, and the connected components of the portrait mask image are calculated and the number of connected components is counted; the edge information of the connected component with the largest area is obtained, and a first image block of the portrait mask image is calculated based on the edge information; simultaneously, the pixels of the other connected components are set as the background of the initial ID image; a second image block corresponding to a randomly selected point on the main edge of the portrait image is obtained in the initial ID image in combination with the portrait mask image; the portrait mask image is filtered based on the initial ID image and the second image block to obtain an updated portrait mask image, and a preset ID image fusion operation is performed based on the updated portrait mask image. This achieves a high-precision ID image fusion processing scheme, greatly improving the portrait processing accuracy and final fusion effect during ID image fusion, and enhancing the user experience of the ID photo shooting function.
[0114] Based on the above embodiments, the present invention also proposes a document image fusion processing device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the computer program is executed by the processor, it implements the steps of the document image fusion processing method as described in any of the above embodiments.
[0115] It should be noted that the above-described device embodiments and method embodiments belong to the same concept. The specific implementation process can be found in the method embodiments, and the technical features in the method embodiments are also applicable to the device embodiments, which will not be repeated here.
[0116] Based on the above embodiments, the present invention also proposes a computer-readable storage medium storing a document image fusion processing program, which, when executed by a processor, implements the steps of the document image fusion processing method as described in any of the above embodiments.
[0117] It should be noted that the above-described medium embodiments and method embodiments belong to the same concept. The specific implementation process can be found in the method embodiments, and the technical features in the method embodiments are also applicable to the medium embodiments, which will not be repeated here.
[0118] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.
[0119] The sequence numbers of the above embodiments of the present invention are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0120] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes several instructions to cause a terminal (which may be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in the various embodiments of the present invention.
[0121] The embodiments of the present invention have been described above with reference to the accompanying drawings. However, the present invention is not limited to the specific embodiments described above. The specific embodiments described above are merely illustrative and not restrictive. Those skilled in the art can make many other forms under the guidance of the present invention without departing from the spirit and scope of the claims. All of these forms are within the protection scope of the present invention.
Claims
1. A method for fusion processing of document images, characterized in that, The method includes: When an initial ID image containing a human image is obtained, a human image mask image of the initial ID image is obtained based on a preset deep learning method, and the connected components of the human image mask image are calculated and the number of connected components is counted. Obtain the edge information of the connected region with the largest area, and calculate the first image block of the portrait mask image based on the edge information. At the same time, set the pixels of the other connected regions as the background of the initial document image. Combine the portrait mask image to obtain a second image block in the initial document image that corresponds to a random point on the main edge of the portrait image; The portrait mask image is filtered based on the initial document image and the second image block to obtain an updated portrait mask image, and a preset document image fusion operation is performed based on the updated portrait mask image. The step of obtaining a second image block in the initial document image by combining the portrait mask image with a randomly selected point on the main edge of the portrait image includes: A starting point a(a_x, a_y) is randomly selected on the edge of the main body; Starting from point a, search for all pixels F(x, y) within a preset region T of point a using an 8-neighborhood approach: |x - a_x| + |y - a_y| <T; The current search stops when the number of pixels satisfying the preset conditions among all pixels F(x, y) in the preset region T reaches a preset number; Calculate the smallest bounding rectangle containing the inner line segment of point a, and use the smallest bounding rectangle as the second image block of the portrait mask image corresponding to point a; Save the calculated second image block, and set the edge points within the range of the saved second image block to zero, so that the zeroed edge points are not searched again; Repeat the random point selection and edge point zeroing operations to obtain all the second image blocks of the subject edge.
2. The document image fusion processing method according to claim 1, characterized in that, The step of filtering the portrait mask image based on the initial document image and the second image block to obtain an updated portrait mask image, and performing a preset document image fusion operation based on the updated portrait mask image, includes: Obtain the source image block in the initial document image that corresponds to the second image block; The source image block is used as a guide image to filter the second image block.
3. The method of claim 2, wherein The step of filtering the portrait mask image based on the initial document image and the second image block to obtain an updated portrait mask image, and performing a preset document image fusion operation based on the updated portrait mask image, further includes: The filtering operation is performed on all the second image blocks in the portrait mask image; Obtain the first original coordinate information of all the second image blocks after the filtering operation.
4. The method of claim 3, wherein The step of filtering the portrait mask image based on the initial document image and the second image block to obtain an updated portrait mask image, and performing a preset document image fusion operation based on the updated portrait mask image, further includes: Obtain the second original coordinate information of the source image block corresponding to the second image block; The second original coordinate information is replaced with the first original coordinate information to obtain the updated portrait mask image.
5. The method of claim 2, wherein The method further includes: When the portrait mask image is obtained, the portrait mask image and the initial document image are divided into blocks according to the edge information of the portrait mask image; Based on the coordinate information of the source image block in the initial document image, the second image block in the portrait mask image that corresponds one-to-one with the coordinate information is determined.
6. An identification image fusion processing apparatus characterized by comprising: The device includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program, when executed by the processor, implements the steps of the document image fusion processing method as described in any one of claims 1 to 5.
7. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a document image fusion processing program, which, when executed by a processor, implements the steps of the document image fusion processing method as described in any one of claims 1 to 5.
Citation Information
Patent Citations
Portrait extraction method, portrait extraction device and mobile terminal
CN111507994A
Image processing method and device, electronic equipment and computer readable storage medium
CN113658197A
