An image processing method, apparatus, device and medium
By performing outline stroke and downsampling on the original image, the problem of low quality of image art effects in the prior art is solved, and high-quality pixel paintings or cartoon-style images are generated.
Patent Information
- Application Number
- CN202111506472.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-10
- Publication Date
- 2025-07-04
- Estimated Expiration
- 2041-12-10
AI Technical Summary
When the prior art generates images with a personalized style, the image art effect quality is low.
By combining contour stroke and downsampling of the original image, the original image is first contour stroked to enhance the contour area of the target object, and then downsampling the first image to generate the target image.
Improves the image quality and artistic effect of the target image after the conversion style, and can generate high-quality pixel painting or cartoon-style images.
Smart Images

Figure CN114170071B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of image processing technologies, and in particular, to an image processing method, apparatus, device, and medium. Background Art
[0002] Images with personalized styles, such as pixel-style images with a sense of the times, have become a common special effect in scenarios such as image processing or game production due to their unique and interesting artistic effects. Currently, it mainly relies on image segmentation technology to generate style images that meet user needs. However, the style images generated in this way often have low quality in terms of image artistic effects. Summary of the Invention
[0003] To solve the above technical problems or at least partially solve the above technical problems, the present disclosure provides an image processing method, apparatus, device, and medium.
[0004] An embodiment of the present disclosure provides an image processing method, the method including:
[0005] Obtain an original image including a target object; perform a preset process on the original image to obtain a first image that enhances the contour area of the target object; wherein, the preset process includes: contour tracing; perform downsampling on the first image, and obtain a target image corresponding to the original image based on the downsampling result.
[0006] Optionally, the preset process further includes a style process; performing the preset process on the original image includes:
[0007] Perform contour tracing on the original image to obtain a target mask image; wherein, the target mask image includes the contour area of the target object in the original image; perform a style process on the original image to obtain a stylized image; wherein, the style process includes: color space conversion, brightness gradation, and / or saturation adjustment; superimpose the target mask image and the stylized image to obtain a first image that enhances the contour area of the target object.
[0008] Optionally, for the contour tracing, performing the preset process on the original image includes:
[0009] Segment the target object of the original image to obtain a first mask image; wherein, the first mask image distinguishes the target object and the background by color; move the first mask image in multiple directions to obtain multiple second mask images; wherein, the directions at least include: horizontal and vertical directions extending outward from the first mask image; combine the first mask image and the multiple second mask images according to a Boolean operation to obtain an image after contour tracing.
[0010] Optionally, the downsampling of the first image and obtaining the target image corresponding to the original image based on the downsampling result includes:
[0011] Downsample the first image to obtain a first downsampled image; perform edge detection on the target object of the original image to obtain an edge image; downsample the edge image to obtain a second downsampled image; and obtain the target image corresponding to the original image based on the first downsampled image and the second downsampled image.
[0012] Optionally, the downsampling of the first image includes:
[0013] Perform Gaussian blur on the first image to obtain a Gaussian blurred image; and downsample the Gaussian blurred image.
[0014] Optionally, the downsampling of the edge image includes:
[0015] Map the initial coordinate range of the edge image to the size of the screen pixel count to obtain a mapped coordinate range; and stepify the pixel coordinates of the edge image within the mapped coordinate range.
[0016] Optionally, the method further includes: obtaining a region mask image corresponding to at least a part of the region of the target object with the image style to be generated;
[0017] The obtaining the target image corresponding to the original image based on the first downsampled image and the second downsampled image includes:
[0018] Segment the first downsampled image according to the region mask image to obtain a first region image including the at least a part of the region and a first background image not including the at least a part of the region; superimpose the edge pixels corresponding to the at least a part of the region in the second downsampled image on the first region image, and superimpose the superimposed image on the first background image to obtain a target image with enhanced brightness of the at least a part of the region.
[0019] Optionally, the obtaining the target image corresponding to the original image based on the first downsampled image and the second downsampled image includes:
[0020] Process the first downsampled image according to the region mask image to obtain a second region image including the at least partial region in the first downsampled image; process the first downsampled image according to the inverted region mask image corresponding to the region mask image to obtain a second background image not including the at least partial region in the first downsampled image; process the second downsampled image according to the region mask image to obtain a third region image including the at least partial region in the second downsampled image; obtain a region enhancement image enhancing the brightness of the at least partial region according to the second region image and the third region image; superimpose the region enhancement image and the second background image to obtain a target image corresponding to the original image.
[0021] Optionally, the target image includes a pixel art style image.
[0022] An embodiment of the present disclosure further provides an image processing apparatus, including:
[0023] An image acquisition module, configured to acquire an original image including a target object;
[0024] An image processing module, configured to perform a preset process on the original image to obtain a first image enhancing a contour region of the target object; wherein, the preset process includes: contour tracing;
[0025] A downsampling module, configured to downsample the first image, and obtain a target image corresponding to the original image based on a downsampling result.
[0026] An embodiment of the present disclosure further provides an electronic device, including: a processor; a memory for storing executable instructions of the processor; the processor is configured to read the executable instructions from the memory and execute the instructions to implement the image processing method provided by the embodiment of the present disclosure.
[0027] An embodiment of the present disclosure further provides a computer-readable storage medium, where the storage medium stores a computer program, and the computer program is used to execute the image processing method provided by the embodiment of the present disclosure.
[0028] The technical solution provided by the embodiment of the present disclosure has the following advantages compared with the prior art:
[0029] An image processing method, apparatus, device and medium provided by an embodiment of the present disclosure. The method first acquires an original image including a target object; then performs contour tracing on the original image to obtain a first image enhancing a contour region of the target object; and finally downsamples the first image, and obtains a target image corresponding to the original image based on the downsampling result.
[0030] Before downsampling the original image, the present technical solution first performs contour tracing on the original image to obtain a first image that enhances the contour region of the target object. Using the enhanced first image can better ensure the image quality. Then, downsampling is performed on the first image, and the resulting target image can transform the image style and present a picture effect different from the original image. The present technical solution combines two image processing means, namely contour tracing and downsampling, which can effectively improve the image quality and image artistic effect of the target image after style transformation. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] The accompanying drawings herein are incorporated into and constitute a part of this specification, showing embodiments consistent with the present disclosure, and are used together with the specification to explain the principles of the present disclosure.
[0032] To more clearly illustrate the technical solutions in the embodiments of the present disclosure or the prior art, the following will briefly introduce the accompanying drawings required for use in the description of the embodiments or the prior art. Obviously, for those of ordinary skill in the art, other drawings can also be obtained based on these drawings without creative efforts.
[0033] Figure 1 It is a schematic flowchart of an image processing method provided by an embodiment of the present disclosure;
[0034] Figure 2 It is a schematic diagram of an image processing process provided by an embodiment of the present disclosure;
[0035] Figure 3 It is a schematic diagram of an edge image provided by an embodiment of the present disclosure;
[0036] Figure 4 It is a schematic diagram of the change of a sampling area provided by an embodiment of the present disclosure;
[0037] Figure 5 It is a schematic diagram of a process of obtaining a target image provided by an embodiment of the present disclosure;
[0038] Figure 6 It is a schematic diagram of another process of obtaining a target image provided by an embodiment of the present disclosure;
[0039] Figure 7 It is a schematic diagram of the image superposition result provided by an embodiment of the present disclosure;
[0040] Figure 8 It is a schematic diagram of the structure of an image processing apparatus provided by an embodiment of the present disclosure;
[0041] Figure 9 It is a schematic diagram of the structure of an electronic device provided by an embodiment of the present disclosure. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0042] In order to more clearly understand the above-mentioned objects, features, and advantages of the present disclosure, the solutions of the present disclosure will be further described below. It should be noted that, without conflict, the embodiments of the present disclosure and the features in the embodiments can be combined with each other.
[0043] Many specific details are set forth in the following description in order to provide a thorough understanding of the present disclosure, but the present disclosure may also be implemented in other ways different from those described herein; obviously, the embodiments in the specification are only a part of the embodiments of the present disclosure, rather than all of the embodiments.
[0044] Currently, style images with artistic effects such as pixel art are mainly generated relying on image segmentation technology. This way that relies on a single image processing means is difficult to generate high-quality style images. Based on this, the embodiments of the present disclosure provide an image processing method, apparatus, device, and medium. This technology can be used in various scenarios that require converting image styles, such as image or video special effects gameplay, games, and live broadcasts. For ease of understanding, the embodiments of the present disclosure are introduced in detail below.
[0045] Figure 1 It is a schematic flowchart of an image processing method provided by an embodiment of the present disclosure. This method can be executed by an image processing device, where the device can be implemented by software and / or hardware and is generally integrated in an electronic device. As Figure 1 shown, this method includes:
[0046] Step S102, obtaining an original image including a target object. Wherein, the original image is an image including the target object and the surrounding environment (such as background, foreground) of the target object; the target object can be other objects such as pedestrians, vehicles, or animals and plants. The image area in the original image that includes the target object is the target area, and the image area other than the target area is the background area. In some possible acquisition methods, the original image can be an image captured in real time by an image acquisition device, or an image downloaded / crawled from the network, locally stored, or manually uploaded, or an image after analog-to-digital conversion by an image scanner, etc.
[0047] Step S104, performing a preset process on the original image to obtain a first image that enhances the contour area of the target object; wherein, the preset process includes: contour tracing.
[0048] Exemplarily, when performing contour tracing processing on the original image, it can be achieved in the following manner:
[0049] Segment the target object in the original image to obtain a first mask image; wherein, the first mask image distinguishes the target object and the background by color. Move the first mask image in multiple directions to expand the mask area of the target object in the first mask image outward, and determine the contour area of the target object according to the mask areas of the target object before and after expansion. Then, by means of image superposition or image blending, etc., and based on the original image and the contour area of the target object, obtain a first image that enhances the contour area of the target object. In the first image, the contour area of the target object is enhanced, or rather, the brightness difference between the contour area of the target object and the background area in the original image increases in the first image.
[0050] Step S106, downsample the first image, and obtain the target image corresponding to the original image based on the downsampling result.
[0051] In this embodiment, the first image can be downsampled according to downsampling algorithms such as FPS (farthest point sampling) or BalanceCascade algorithm, etc., and the target image corresponding to the original image is obtained based on the downsampling result. In a possible example, the target image includes, for example, a pixel art style image, having a pixel art effect similar to 8-bit pixel style.
[0052] In practical applications, if the original image is directly downsampled, the resulting downsampled image presents a picture effect similar to that taken by a low-pixel camera, which is blurry, unclear, and has pixel differences. Based on this, the image processing method provided by the embodiments of the present disclosure, for the obtained original image, before downsampling, first perform contour tracing on the original image to obtain a first image that enhances the contour area of the target object. The enhanced first image can better ensure the image quality in the subsequent image processing process. Then, downsample the enhanced first image, and the resulting target image can convert the image style and present a picture effect different from the original image. This technical solution combines the two image processing means of contour tracing and downsampling, and can effectively improve the image quality and image art effect of the target image after style conversion.
[0053] According to the above embodiments, the embodiments of the present disclosure further provide another image processing method by taking the target image as a pixel art style image as a representative example. The execution process of this method can refer to Figure 2 .
[0054] Since the original image is generally a realistic image, after the above embodiments perform contour tracing on the original image, although the pixelated effect of the image is improved, it is still in a realistic style, with a strong sense of reality and does not have the effect of a cartoon style. In this case, the preset processing in step S104 above may further include stylization processing; correspondingly, performing preset processing on the original image may include: performing contour tracing and stylization processing on the original image respectively, for example, referring to Figure 2 shown in pass1 as shown.
[0055] For the contour tracing process, it includes: performing contour tracing on the original image to obtain a target mask image. Among them, the target mask image includes the contour area of the target object in the original image.
[0056] The implementation process of contour tracing in this embodiment includes the following steps 1 to 3:
[0057] Step 1, segment the target object of the original image to obtain a first mask image; among them, the first mask image distinguishes the target object and the background by color.
[0058] Specifically, the target object of the original image can be segmented according to methods such as edge detection algorithms, gray threshold segmentation methods, region-based segmentation methods, etc. to obtain a first mask image. The first mask image distinguishes the regions corresponding to the target object and the background by color; exemplarily, taking the target object as a human body, correspondingly, the first mask image can also be called a human body mask image. The mask regions corresponding to the human body including parts such as the head, neck, body, and limbs in the first mask image are white, and the background region other than the human body in the first mask image is black.
[0059] Step 2, move the first mask image in multiple directions to obtain multiple second mask images. Among them, the directions at least include: horizontal and vertical directions extending outward from the first mask image. Of course, it can also include other directions such as 45-degree and 135-degree directions extending outward from the first mask image.
[0060] In a possible specific embodiment, along the horizontal and vertical directions extending outward from the first mask image (denoted as P), the first mask image P is moved in four directions: up, down, left, and right, to obtain the following second mask images offset in the up, down, left, and right directions respectively: P 上 、P 下 、P 左 、P 右 .
[0061] To reduce the computational complexity of image movement, an embodiment of moving the first mask image is provided herein. The original sampling coordinates of the first mask image are mapped to target sampling coordinates with an interval range of (0, 1). For example, for the first mask image with original sampling coordinates of 720×1280, it is mapped to target sampling coordinates with an interval range where both the horizontal and vertical coordinates are (0, 1). The pixel at the position (360, 640) in the original sampling coordinates is mapped to the position (0.5, 0.5) in the target sampling coordinates.
[0062] The first mask image mapped to the target sampling coordinates is moved in multiple directions. When a small movement is made to the first mask image in the target sampling coordinates, it corresponds to a relatively large movement distance for the pixel coordinates in the original sampling coordinates. Taking the position (0.5, 0.5) in the target sampling coordinates as an example, if the first mask image is moved to the left to the position (0.45, 0.5), then, when mapped back to the original sampling coordinates, it is equivalent to moving the pixel from the position (360, 640) to the position (324, 640). Referring to this method, the first mask image is moved in multiple directions to obtain multiple second mask images; compared with the first mask image, the mask area of the target object in each second mask image has expanded a certain contour area outward.
[0063] Step 3: Combine the first mask image and multiple second mask images according to boolean operations to obtain an image with the contour outlined.
[0064] Specifically, first, multiple second mask images are combined according to the boolean addition operation to obtain a third mask image. The third mask image obtained through boolean addition has expanded a certain contour area outward compared with the first mask image; it can be understood that the mask area of the target object in the third mask image has also expanded a certain contour area outward compared with the mask area of the target object in the first mask image. Then, the third mask image and the first mask image are subtracted according to the boolean subtraction operation to obtain an image with the contour outlined. In some implementation manners, this image with the contour outlined can be directly used as the first image for enhancing the contour area of the target object; in other implementation manners, this image with the contour outlined can also be used as the target mask image, and then the first image is obtained by combining it with the stylized image.
[0065] Such as Figure 2 In pass1, the stylized processing includes: performing stylized processing on the original image to obtain a stylized image. Among them, the stylized processing includes: color space conversion, brightness gradation, and / or saturation adjustment.
[0066] The original image is usually an image stored in the RGB (RGB color mode) color space. The color space of the original image is converted, and the original image is converted from the RGB color space to the HSL (Hue, Saturation, Lightness) color space to obtain an HSL image. The HSL image after color space conversion is convenient for adjusting brightness and saturation. In the era when 8-bit pixel style emerged, due to hardware limitations, the stored colors were limited, generally only able to store three color levels of red, green, and blue. However, with the development, the current images have very rich colors, so it is necessary to map the images with rich colors back to the three color levels corresponding to the 8-bit pixel style. Based on this, in this embodiment, the brightness value of the HSL image is stepped, and the stepped image is obtained. To further optimize the image effect, in this embodiment, the saturation of the stepped image can also be adjusted, and finally a stylized image with a cartoon style is obtained; the above saturation adjustment is such as reducing the saturation.
[0067] For the target mask image after contour stroking and the stylized image after stylization processing, the target mask image and the stylized image are superimposed to obtain a first image that enhances the contour area of the target object.
[0068] The above is for Figure 2 In the embodiment of the preset processing provided in pass1 above, by performing stylization processing on the original image, a stylized image with a cartoon style is generated. When the stylized image is superimposed with the target mask image to form a first image, it can not only enhance the contour area of the target object, but also reduce the realism of the first image and increase the cartoon style of the first image. When generating the target image using the first image with a cartoon style later, the target image can also have a cartoon style. The combination of the cartoon style and the 8-bit pixel style can further increase the interest of the image and better meet the user's pursuit of the retro-style image effect.
[0069] For the above step S106, there are multiple ways to obtain the target image, and several are provided as examples below.
[0070] In one embodiment of obtaining the target image, the first image can be downsampled to obtain a first downsampled image, and the first downsampled image is used as the target image corresponding to the original image.
[0071] In another embodiment of obtaining the target image, the following steps (1)-(4) can be included:
[0072] (1) The first image is downsampled to obtain a first downsampled image.
[0073] (2) Edge detection is performed on the target object of the original image to obtain an edge image.
[0074] Specifically, edge detection can be performed on the target object of the original image according to the Sobel operator edge detection algorithm, Roberts operator edge detection algorithm, Prewitt operator edge detection algorithm, Laplacian operator edge detection algorithm, etc., to obtain an edge image. For example Figure 3 In the provided example, using the sobel operator as the convolution kernel to perform convolution operation on the original image (left figure), an edge image (right figure) containing the edge contour line of the animal can be obtained. Through edge detection, it is possible to prevent the loss of significant features of the target object during the image downsampling process and ensure the integrity of the features.
[0075] (3) Downsample the edge image to obtain a second downsampled image.
[0076] This embodiment provides a specific implementation method for downsampling the edge image. Map the initial coordinate range of the edge image to the size of the screen pixel count to obtain the mapped coordinate range. For the convenience of image processing, the initial coordinate range is usually in the interval range of the horizontal and vertical coordinates in (0, 1). Taking the screen pixel count as 720×1280 as an example, the mapped coordinate range is in the interval range of the horizontal coordinate in (0, 720) and the vertical coordinate in (0, 1280).
[0077] Step the pixel coordinates of the edge image within the mapped coordinate range; the stepping specifically includes: dividing the pixel coordinates of the edge image by the mosaic unit; taking the integer of the division result and multiplying it by the mosaic unit again, which can make the sampling coordinates corresponding to the pixels belonging to the same mosaic unit consistent; finally, map the integer coordinates back to the initial coordinate range, thereby completing the stepping.
[0078] For example, the original sampling coordinate of the edge image within the initial coordinate range is (0.5, 0.5), and the coordinate within the mapped coordinate range obtained through mapping is (360, 640). Assuming that the mosaic unit contains 30*30 pixel points, then, during the stepping process, divide the above coordinates by the mosaic unit: (360 / 30, 640 / 30) = (12, 21.33333...), take the integer of the division result according to the floor function and multiply it by the mosaic unit again: floor(12, 21.33333...)*(30, 30) = (12, 21)*(30, 30) = (360, 630), and then map the integer coordinates back to the initial coordinate range: (360 / 720, 630 / 1280) = (0.5, 0.4921875), to obtain the sampling coordinate (0.5, 0.4921875) corresponding to the stepped original sampling coordinate (0.5, 0.5).
[0079] (4) Obtain a target image corresponding to the original image based on the first downsampled image and the second downsampled image.
[0080] In this embodiment, the superimposed image of the first downsampled image and the second downsampled image can be used as the target image corresponding to the original image.
[0081] Exemplarily, the first downsampled image and the second downsampled image can be superimposed, and the superimposed image can be used as the target image corresponding to the original image.
[0082] In another embodiment of obtaining the target image, reference can be made to Figure 2 pass2 to pass4 of, including the following steps I-IV:
[0083] Step I: Perform Gaussian blur on the first image to obtain a Gaussian blurred image.
[0084] In practical applications, any image has noise, and the manifestation degree is different on different models. Especially around the pixel points with obvious color changes, the noise is more obvious. In this case, the colors sampled within a sampling unit of a certain size (such as 30*30) are likely to have a large temporal span. For example Figure 4 in the adjacent two frames of images of, for the same sampling unit (black frame), since the position of the target object changes in each frame, the image within the sampling unit will change accordingly. Assuming that the average value of the four corner points of the selected image is used as the color value of the entire sampling unit, it is easy to have color jitter between frames. To improve this problem, Figure 2 in the pass2 part, perform Gaussian blur on the first image. For example, use the commonly used Gaussian convolution kernel in image processing to perform convolution operations on each pixel of the first image, so that the color values between each pixel are averaged, and a Gaussian blurred image is obtained, thereby preventing color jitter and further optimizing the image processing effect.
[0085] Step II: Downsample the Gaussian blurred image. Input the Gaussian blurred image into pass4 for downsampling processing, and the obtained downsampled image is used as the first downsampled image corresponding to the first image.
[0086] Step III: Perform edge detection and downsampling on the target object of the original image. This step is the same as steps (2) and (3) of the previous embodiment. For the sake of description, the image obtained after performing edge detection (pass3) and downsampling (pass4) on the target object of the original image is also used as the second downsampled image.
[0087] Step IV: Obtain a target image corresponding to the original image based on the first downsampled image and the second downsampled image; wherein, the target image includes a pixel art style image.
[0088] In this embodiment, the superimposed image of the first downsampled image and the second downsampled image can be used as the target image corresponding to the original image.
[0089] In addition, considering that some regions of the target object may have relatively rich and complex features, or the user has a higher attention to some regions, etc., in the pass4 part of this embodiment, a region mask image can also be input, and the region mask image, the first downsampled image, and the second downsampled image in the above-mentioned multiple embodiments are jointly used to obtain the target image corresponding to the original image.
[0090] In this case, this embodiment first obtains a region mask image corresponding to at least some regions of the target object where the image style is to be generated. Taking the target object as a human body, the region mask image can be a mask image covering the entire human body, or a mask image covering a part of the human body, such as a mask image of the human face.
[0091] Then, several embodiments of obtaining the target image based on the region mask image, the first downsampled image, and the second downsampled image are provided here.
[0092] Such as Figure 5 shown in a specific embodiment includes:
[0093] Step A1, segment the first downsampled image according to the region mask image to obtain a first region image including at least some regions and a first background image not including at least some regions. Specifically, the first region image is an image only including the facial region, and the first background image is an image including the region of the background where the human body is located and the non-facial regions of the human body.
[0094] Step A2, superimpose the edge pixels corresponding to at least some regions in the second downsampled image on the first region image, and superimpose the superimposed image on the first background image to obtain a target image with enhanced brightness of at least some regions.
[0095] Specifically, from the pixels corresponding to the edge contour line of the target object in the second downsampled image, obtain the edge pixels corresponding to the facial edge contour line, superimpose the edge pixels of the face on the pixels of the corresponding facial region in the first region image to obtain a superimposed image of the first region image and the second downsampled image; then superimpose the superimposed image on the first background image to obtain a target image with enhanced brightness of the facial features.
[0096] Such as Figure 6 shown in a specific embodiment includes:
[0097] Step B1: Process the first downsampled image according to the region mask image to obtain a second region image containing at least part of the region in the first downsampled image. The second region image is an image that only contains the facial region in the first downsampled image.
[0098] Step B2: Process the first downsampled image according to the inverted region mask image corresponding to the region mask image to obtain a second background image that does not contain at least part of the region in the first downsampled image.
[0099] Assume that the region mask image uses a color value of 1 to represent the facial region and a color value of 0 to represent the non-facial region. Then, the inverted region mask image has the opposite values, using 0 to represent the facial region and 1 to represent the non-facial region. The second background image can be obtained using the inverted region mask image, that is, an image containing the region of the background where the human body is located and the non-facial region of the human body in the first downsampled image. Refer to Figure 7 The right figure shows the second background image. The second background image can ensure that the non-facial region is not superimposed with edge information.
[0100] Step B3: Process the second downsampled image according to the region mask image to obtain a third region image containing at least part of the region in the second downsampled image.
[0101] Refer to Figure 7 The left figure shows the third region image containing the face, and this image contains prominent facial features.
[0102] Step B4: Obtain a region-enhanced image that enhances the brightness of at least part of the region according to the second region image and the third region image.
[0103] As Figure 7 shown in the middle figure, for the pixels at the same position in the second region image and the third region image, compare the brightness values of the two pixels, and determine the pixel with the smaller brightness value as the pixel at the same position in the region-enhanced image. For example, for the position of the eye edge in the second region image and the third region image, if the brightness value of the pixel at this position in the second region image is smaller, that is, the color is darker, then the pixel at the eye edge in the second region image is superimposed on the region-enhanced image. The region-enhanced image obtained in the above manner is closer to the true and natural brightness of the target object.
[0104] (V) Superimpose the region-enhanced image and the second background image to obtain the target image corresponding to the original image. Superimpose the face shown in the region-enhanced image and the non-face shown in the second background image to obtain the final target image.
[0105] In the above two embodiments shown in pass4, the segmentation technology is used as an auxiliary, and at least part of the area corresponding to the region mask image is specially processed. Only the edge information is superimposed on the face (that is, at least part of the area) to highlight the local features.
[0106] In summary, the image processing method provided by the above disclosed embodiments uses contour tracing and downsampling as the main processing means for the obtained original image to obtain a target image with an 8-bit pixel style; uses stylization processing, edge detection, Gaussian blur, etc. as auxiliary processing means to further enhance the pixel style and cartoon style of the pixelated image. Therefore, the technical solution can generate an image with a relatively high-quality pixel painting effect, increasing the interest of the image special effect gameplay.
[0107] Figure 8 The following is a schematic structural diagram of an image processing device provided by an embodiment of the present disclosure. The device can be implemented by software and / or hardware, and is generally integrated in an electronic device, and can generate an image with a personalized style such as a pixel painting effect by executing an image processing method. As Figure 8 shown, the device includes:
[0108] An image acquisition module 802, configured to acquire an original image including a target object;
[0109] An image processing module 804, configured to perform preset processing on the original image to obtain a first image that enhances the contour area of the target object; wherein, the preset processing includes: contour tracing;
[0110] A downsampling module 806, configured to perform downsampling on the first image, and obtain a target image corresponding to the original image based on the downsampling result.
[0111] In one embodiment, the preset processing further includes style processing; the image processing module 804 is specifically configured to:
[0112] Perform contour tracing on the original image to obtain a target mask image; wherein, the target mask image includes the contour area of the target object in the original image; perform style processing on the original image to obtain a stylized image; wherein, the style processing includes: color space conversion, lightness gradation, and / or saturation adjustment; superimpose the target mask image and the stylized image to obtain a first image that enhances the contour area of the target object.
[0113] In one embodiment, for contour tracing, the image processing module 804 is specifically configured to:
[0114] Segment the target object in the original image to obtain a first mask image; wherein, the first mask image distinguishes the target object and the background by color; move the first mask image in multiple directions to obtain multiple second mask images; wherein, the directions at least include: horizontal and vertical directions extending outward from the first mask image; combine the first mask image and the multiple second mask images according to a Boolean operation to obtain an image with a contoured stroke.
[0115] In one embodiment, the downsampling module 806 specifically includes:
[0116] A first downsampling unit for downsampling the first image to obtain a first downsampled image;
[0117] An edge detection unit for detecting the edge of the target object in the original image to obtain an edge image;
[0118] A second downsampling unit for downsampling the edge image to obtain a second downsampled image;
[0119] A target image acquisition unit for obtaining the target image corresponding to the original image based on the first downsampled image and the second downsampled image.
[0120] In one embodiment, the first downsampling unit is specifically configured to: perform Gaussian blur on the first image to obtain a Gaussian blurred image; perform downsampling on the Gaussian blurred image.
[0121] In one embodiment, the second downsampling unit is specifically configured to: map the initial coordinate range of the edge image to the size of the screen pixel count to obtain a mapped coordinate range; step the pixel coordinates of the edge image within the mapped coordinate range.
[0122] In one embodiment, the image processing device further includes: a mask acquisition module for acquiring a region mask image corresponding to at least part of the region in the target object where the image style is to be generated;
[0123] Correspondingly, the target image acquisition unit is specifically configured to: segment the first downsampled image according to the region mask image to obtain a first region image including at least part of the region and a first background image not including at least part of the region; superimpose the edge pixels corresponding to at least part of the region in the second downsampled image on the first region image, and superimpose the superimposed image on the first background image to obtain a target image with enhanced brightness of at least part of the region.
[0124] In one embodiment, the target image acquisition unit is specifically configured to:
[0125] Process the first downsampled image according to the region mask image to obtain a second region image including at least part of the region in the first downsampled image; process the first downsampled image according to the inverted region mask image corresponding to the region mask image to obtain a second background image not including at least part of the region in the first downsampled image; process the second downsampled image according to the region mask image to obtain a third region image including at least part of the region in the second downsampled image; obtain a region enhancement image enhancing the brightness of at least part of the region according to the second region image and the third region image; superimpose the region enhancement image and the second background image to obtain a target image corresponding to the original image.
[0126] In one embodiment, the target image includes a pixel art style image.
[0127] The image processing apparatus provided by the embodiments of the present disclosure can execute the image processing method provided by any embodiment of the present invention, and has functional modules and beneficial effects corresponding to the execution of the method.
[0128] Figure 9 It is a schematic structural diagram of an electronic device provided by an embodiment of the present disclosure. As Figure 9 shown, the electronic device 900 includes one or more processors 901 and a memory 902.
[0129] The processor 901 may be a central processing unit (CPU) or other form of processing unit with data processing capabilities and / or instruction execution capabilities, and may control other components in the electronic device 900 to execute desired functions.
[0130] The memory 902 may include one or more computer program products, and the computer program products may include various forms of computer-readable storage media, such as volatile memory and / or non-volatile memory. The volatile memory may include, for example, random access memory (RAM) and / or cache memory, etc. The non-volatile memory may include, for example, read-only memory (ROM), hard disk, flash memory, etc. One or more computer program instructions may be stored on the computer-readable storage medium, and the processor 901 may run the program instructions to implement the image processing method of the embodiments of the present disclosure described above and / or other desired functions. Various contents such as input signals, signal components, noise components, etc. may also be stored in the computer-readable storage medium.
[0131] In one example, the electronic device 900 may further include: an input device 903 and an output device 904, and these components are interconnected through a bus system and / or other forms of connection mechanisms (not shown).
[0132] In addition, the input device 903 may further include, for example, a keyboard, a mouse, and so on.
[0133] The output device 904 can output various information to the outside, including the determined distance information, direction information, etc. The output device 904 may include, for example, a display, a speaker, a printer, a communication network, and remote output devices connected thereto, and so on.
[0134] Of course, for the sake of simplicity, Figure 9 only some of the components related to the present disclosure in the electronic device 900 are shown in [the figure], and components such as a bus, an input / output interface, and so on are omitted. In addition, according to specific application scenarios, the electronic device 900 may further include any other appropriate components.
[0135] In addition to the above methods and devices, an embodiment of the present disclosure may also be a computer program product, which includes computer program instructions that, when run by a processor, cause the processor to execute the image processing method described in the embodiments of the present disclosure.
[0136] The computer program product may be written in any combination of one or more programming languages for programming code to perform the operations of the embodiments of the present disclosure. The programming languages include object-oriented programming languages such as Java, C++, etc., and also include conventional procedural programming languages such as the "C" language or similar programming languages. The program code may be executed entirely on the user's computing device, partially on the user's device, executed as a stand-alone software package, partially on the user's computing device and partially on a remote computing device, or entirely on a remote computing device or server.
[0137] In addition, an embodiment of the present disclosure may also be a computer-readable storage medium, on which computer program instructions are stored, and when the computer program instructions are run by a processor, the processor is caused to execute the image processing method provided in the embodiments of the present disclosure.
[0138] The computer-readable storage medium may adopt any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium may, for example, include but is not limited to an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the above. More specific examples (a non-exhaustive list) of the readable storage medium include: an electrical connection having one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.
[0139] An embodiment of the present disclosure also provides a computer program product, including computer programs / instructions, which, when executed by a processor, implement the methods in the embodiments of the present disclosure.
[0140] It should be noted that, in this document, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the term "comprising", "including" or any other variation thereof is intended to cover a non-exclusive inclusion, such that a process, method, article or device comprising a series of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article or device. Without further limitation, an element defined by the phrase "comprising a..." does not exclude the existence of additional identical elements in the process, method, article or device comprising the element.
[0141] The above are only specific embodiments of the present disclosure, enabling those skilled in the art to understand or implement the present disclosure. Various modifications to these embodiments will be obvious to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present disclosure. Therefore, the present disclosure will not be limited to the embodiments described herein, but rather to the broadest scope consistent with the principles and novel features disclosed herein.
Claims
1. An image processing method, characterized in that, Including: Obtain an original image including a target object; Perform a preset process on the original image to obtain a first image enhancing the contour area of the target object; wherein, the preset process includes: contour tracing; Downsample the first image, and obtain a target image corresponding to the original image based on the downsampling result; Wherein, the preset process further includes style processing; the performing a preset process on the original image to obtain a first image enhancing the contour area of the target object includes: Perform contour tracing and style processing on the original image respectively; Overlay the image after contour tracing and the image after style processing to obtain a first image enhancing the contour area of the target object.
2. The method according to claim 1, characterized in that, The preset process further includes style processing; the performing a preset process on the original image includes: Perform contour tracing on the original image to obtain a target mask image; wherein, the target mask image includes the contour area of the target object in the original image; Perform style processing on the original image to obtain a stylized image; wherein, the style processing includes: color space conversion, brightness gradation, and / or saturation adjustment; Overlay the target mask image and the stylized image to obtain a first image enhancing the contour area of the target object.
3. The method according to claim 1 or 2, characterized in that, Regarding the contour tracing, the performing a preset process on the original image includes: Segment the target object of the original image to obtain a first mask image; wherein, the first mask image distinguishes the target object and the background by color; Move the first mask image in multiple directions to obtain multiple second mask images; wherein, the directions at least include: horizontal and vertical directions extending outward from the first mask image; Combine the first mask image and the multiple second mask images according to Boolean operations to obtain an image after contour tracing.
4. The method according to claim 1, wherein The downsampling the first image and obtaining a target image corresponding to the original image based on the downsampling result includes: Downsample the first image to obtain a first downsampled image; Perform edge detection on the target object of the original image to obtain an edge image; Downsample the edge image to obtain a second downsampled image; Based on the first downsampled image and the second downsampled image, obtain a target image corresponding to the original image.
5. The method according to claim 4, characterized in that The downsampling the first image includes: Perform Gaussian blur on the first image to obtain a Gaussian blurred image; Downsample the Gaussian blurred image.
6. The method according to claim 4, characterized in that, The downsampling the edge image includes: Map the initial coordinate range of the edge image to the size of the screen pixel quantity to obtain a mapped coordinate range; Gradate the pixel coordinates of the edge image within the mapped coordinate range.
7. The method according to claim 4, characterized in that, The method further includes: Obtain a region mask image corresponding to at least part of the area of the target object where the image style to be generated is located; The obtaining a target image corresponding to the original image based on the first downsampled image and the second downsampled image includes: Segment the first downsampled image according to the region mask image to obtain a first region image including the at least partial region and a first background image not including the at least partial region; Overlay the edge pixels corresponding to the at least partial region in the second downsampled image on the first region image, and overlay the overlaid image with the first background image to obtain a target image enhancing the brightness of the at least partial region.
8. The method according to claim 7, wherein The obtaining of the target image corresponding to the original image based on the first downsampled image and the second downsampled image includes: Process the first downsampled image according to the region mask image to obtain a second region image including the at least partial region in the first downsampled image; Process the first downsampled image according to the inverted region mask image corresponding to the region mask image to obtain a second background image not including the at least partial region in the first downsampled image; Process the second downsampled image according to the region mask image to obtain a third region image including the at least partial region in the second downsampled image; Obtain a region enhancement image enhancing the brightness of the at least partial region according to the second region image and the third region image; Overlay the region enhancement image with the second background image to obtain the target image corresponding to the original image.
9. The method according to claim 1, characterized in that, The target image includes a pixel art style image.
10. An image processing apparatus, characterized in that, Including: An image acquisition module, configured to acquire an original image including a target object; An image processing module, configured to perform a preset process on the original image to obtain a first image enhancing the contour region of the target object; wherein, the preset process includes: contour tracing; A downsampling module, configured to downsample the first image and obtain the target image corresponding to the original image based on the downsampling result; Wherein, the preset process further includes style processing; the image processing module is further configured to: Perform contour tracing and style processing on the original image respectively; Overlay the image after contour tracing and the image after style processing to obtain a first image enhancing the contour region of the target object.
11. An electronic device, characterized in that, The electronic device includes: A processor; A memory for storing executable instructions of the processor; The processor is configured to read the executable instructions from the memory and execute the instructions to implement the image processing method according to any one of claims 1-9 above.
12. A computer-readable storage medium, characterized in that, The storage medium stores a computer program, which when executed by a computer device, causes the computer device to implement the image processing method according to any one of claims 1-9 above.
Citation Information
Patent Citations
Head portrait pixelated face color filling method and device and electronic equipment
CN111667553A
Image processing apparatus and method
JP2007028468A