Cartoon style image conversion method and device, computer equipment and storage medium

文档序号:9189 发布日期:2021-09-17 浏览:45次 中文

1. A method for converting cartoon-style images, comprising the steps of:

receiving an image containing a human face;

carrying out segmentation processing on the image containing the face to obtain an image of an eye region and an image of a non-eye region;

converting the image of the eye area according to a preset lightweight neural network to obtain an eye image with a cartoon style;

performing cartoon style processing on the image of the non-eye area according to a traditional image algorithm to obtain an image with a processed cartoon style;

and splicing the eye image containing the cartoon style with the image processed by the cartoon style to obtain an image containing the cartoon style.

2. The method for transforming a cartoon-style image according to claim 1, wherein before the segmenting the image containing the face, the method further comprises:

and preprocessing the image containing the face according to a preset preprocessing rule to obtain a preprocessed image.

3. The method for converting a cartoon-style image according to claim 2, wherein the preprocessing the image containing the human face according to a preset preprocessing rule to obtain a preprocessed image comprises:

cutting the image containing the human face to obtain a cut image;

zooming the cut image to obtain a zoomed image;

and carrying out normalization processing on the image after the scaling processing to obtain the preprocessed image.

4. The method for converting a cartoon-style image according to claim 3, wherein the step of segmenting the image containing the human face to obtain an image of an eye region and an image of a non-eye region comprises:

acquiring coordinate data of an eye region in the preprocessed image;

and carrying out segmentation processing on the preprocessed image according to the coordinate data to obtain an image of an eye region and an image of a non-eye region.

5. The method for transforming a caricature-style image according to claim 4, wherein the obtaining coordinate data of an eye region in the pre-processed image comprises:

and inputting the preprocessed image into a preset human face detector to obtain the coordinate data.

6. The method for converting a cartoon-style image according to claim 1, wherein the step of converting the image of the eye region according to a preset lightweight neural network to obtain the image of the eye having the cartoon style comprises:

inputting the image of the eye region into a MobileNet of a preset Cycle GAN model for coding to obtain characteristic information of the image of the eye region;

inputting the characteristic information into Unet of the Cycle GAN model for decoding, and identifying the eye image containing the cartoon style according to a discriminator in the Cycle GAN model.

7. The method for converting a cartoon-style image according to claim 1, wherein the cartoon-style processing the image of the non-eye area according to a conventional image algorithm to obtain a cartoon-style processed image comprises:

performing edge detection on the image of the non-eye region to obtain a face contour of the non-eye region;

and processing the non-human face contour region in the non-eye region according to a k-means clustering algorithm to obtain the image with the cartoon style processed.

8. A comic-style image conversion apparatus, comprising:

a receiving unit for receiving an image containing a human face;

the first segmentation unit is used for carrying out segmentation processing on the image containing the human face to obtain an image of an eye region and an image of a non-eye region;

the conversion unit is used for carrying out conversion processing on the image of the eye area according to a preset light weight neural network to obtain an eye image containing a cartoon style;

the first processing unit is used for performing cartoon style processing on the image of the non-eye area according to a traditional image algorithm to obtain an image subjected to cartoon style processing;

and the splicing unit is used for splicing the eye image containing the cartoon style with the image processed by the cartoon style to obtain the image containing the cartoon style.

9. A computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, characterized in that the processor implements the method of transforming a caricature-style image according to any of claims 1 to 7 when executing the computer program.

10. A computer-readable storage medium, characterized in that it stores a computer program which, when executed by a processor, causes the processor to execute the method of converting a caricature-style image according to any one of claims 1 to 7.

Background

The origin of the cartoon can be traced back to a long time, the cartoon already exists in the period of intelligence of human society, and the cartoon is not only taken as a life record but also a popular entertainment mode and an ideal consignment for people. The cartoon is not only a favorite of children but also a favorite of people of different grades and different ages, and in the heart of most people, the cartoon is not only a recreational relaxation mode, but also can bring more profound significance, is transferred to different cultures of people and makes people feel enthusiasm and dream. In the last century of the twentieth century, the era of the rapid development of cartoons can be said, and the rapid development of the cartoons in nearly one hundred years can be seen in both the cartoons of the heroic sense of the united states such as the well-known romance superman and the like and the Japanese cartoon remembered by the youth of the young people of the generation. In the prior art, when a common face image is converted into a cartoon face image, three generation models are needed to be used for respectively converting eyebrows, noses and hairs, so that the operation speed is low and the efficiency is low in the conversion process.

Disclosure of Invention

The embodiment of the invention provides a cartoon style image conversion method, a cartoon style image conversion device, computer equipment and a storage medium, and solves the problems of low operation speed and low efficiency in the process of converting a human face cartoon in the prior art.

In a first aspect, an embodiment of the present invention provides a method for converting a cartoon-style image, including:

receiving an image containing a human face;

carrying out segmentation processing on the image containing the face to obtain an image of an eye region and an image of a non-eye region;

converting the image of the eye area according to a preset lightweight neural network to obtain an eye image with a cartoon style;

performing cartoon style processing on the image of the non-eye area according to a traditional image algorithm to obtain an image with a processed cartoon style;

and splicing the eye image containing the cartoon style with the image processed by the cartoon style to obtain an image containing the cartoon style.

Preferably, in the converting of the cartoon-style image, before the segmenting the image including the human face, the method further includes: and preprocessing the image containing the face according to a preset preprocessing rule to obtain a preprocessed image.

More preferably, in the converting of the cartoon-style image, the preprocessing the image including the human face according to a preset preprocessing rule to obtain a preprocessed image includes:

cutting the image containing the human face to obtain a cut image;

zooming the cut image to obtain a zoomed image;

and carrying out normalization processing on the image after the scaling processing to obtain the preprocessed image.

Preferably, in the converting of the cartoon-style image, the segmenting the image including the human face to obtain an image of an eye region and an image of a non-eye region includes:

acquiring coordinate data of an eye region in the preprocessed image;

and carrying out segmentation processing on the preprocessed image according to the coordinate data to obtain an image of an eye region and an image of a non-eye region.

Preferably, in the converting of the cartoon-style image, the acquiring coordinate data of the eye area in the preprocessed image includes: and inputting the preprocessed image into a preset human face detector to obtain the coordinate data.

Preferably, in the converting of the cartoon-style image, the converting the image of the eye region according to a preset lightweight neural network to obtain an eye image having a cartoon style includes:

inputting the image of the eye region into MobileNet of a preset Cycle GAN model for coding to obtain the characteristic information of the image of the eye region

Inputting the characteristic information into Unet of the Cycle GAN model for decoding, and identifying the eye image containing the cartoon style according to a discriminator in the Cycle GAN model.

Preferably, in the converting of the cartoon-style image, the performing cartoon-style processing on the image of the non-eye area according to a conventional image algorithm to obtain a cartoon-style processed image includes:

performing edge detection on the image of the non-eye region to obtain a face contour of the non-eye region;

and processing the non-human face contour region in the non-eye region according to a k-means clustering algorithm to obtain the image with the cartoon style processed.

In a second aspect, an embodiment of the present invention provides a device for converting a cartoon-style image, including:

a receiving unit for receiving an image containing a human face;

the first segmentation unit is used for carrying out segmentation processing on the image containing the human face to obtain an image of an eye region and an image of a non-eye region;

the conversion unit is used for carrying out conversion processing on the image of the eye area according to a preset light weight neural network to obtain an eye image containing a cartoon style;

the first processing unit is used for performing cartoon style processing on the image of the non-eye area according to a traditional image algorithm to obtain an image subjected to cartoon style processing;

and the splicing unit is used for splicing the eye image containing the cartoon style with the image processed by the cartoon style to obtain the image containing the cartoon style.

In a third aspect, an embodiment of the present invention further provides a computer device, including a memory, a processor, and a computer program stored on the memory and executable on the processor, where the processor implements the method for converting the cartoon-style image according to the first aspect when executing the computer program.

In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium, where the computer-readable storage medium stores a computer program, and the computer program, when executed by a processor, causes the processor to execute the method for converting a cartoon-style image according to the first aspect.

The embodiment of the invention provides a method, a device and computer equipment for converting cartoon style images, wherein the method comprises the steps of receiving an image containing a human face; carrying out segmentation processing on the image containing the face to obtain an image of an eye region and an image of a non-eye region; converting the image of the eye area according to a preset lightweight neural network to obtain an eye image with a cartoon style; performing cartoon style processing on the image of the non-eye area according to a traditional image algorithm to obtain an image with a processed cartoon style; and splicing the eye image containing the cartoon style with the image processed by the cartoon style to obtain an image containing the cartoon style. According to the method, based on the difference of the cartoon and the human eyes in the original photo, the light neural network is adopted to convert the eyes in the image containing the human face to obtain the eyes with the cartoon style, meanwhile, the traditional image processing method is adopted to process the non-eye area and splice the non-eye area with the converted eyes with the cartoon style, so that the image containing the human face can be converted into the image with the cartoon style, the conversion efficiency of the cartoon style image is greatly improved, and the calculation amount is reduced.

Drawings

In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings needed to be used in the description of the embodiments are briefly introduced below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts.

Fig. 1 is a flowchart illustrating a method for converting a cartoon-style image according to an embodiment of the present invention;

FIG. 2 is another flowchart illustrating a method for converting a cartoon-style image according to an embodiment of the present invention;

FIG. 3 is a sub-flow diagram illustrating a method for converting a cartoon-style image according to an embodiment of the present invention;

FIG. 4 is a schematic view of another sub-flow of a method for converting a cartoon-style image according to an embodiment of the present invention;

FIG. 5 is a schematic view of another sub-flow of a method for converting a cartoon-style image according to an embodiment of the present invention;

FIG. 6 is a schematic view of another sub-flow of a method for converting a cartoon-style image according to an embodiment of the present invention;

FIG. 7 is a schematic block diagram of a cartoon-style image conversion apparatus provided by an embodiment of the present invention;

FIG. 8 is a schematic block diagram of a computer device provided by an embodiment of the present invention.

Detailed Description

The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, not all, embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.

It will be understood that the terms "comprises" and/or "comprising," when used in this specification and the appended claims, specify the presence of stated features, integers, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and/or groups thereof.

It is also to be understood that the terminology used in the description of the invention herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the invention. As used in the specification of the present invention and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise.

It should be further understood that the term "and/or" as used in this specification and the appended claims refers to and includes any and all possible combinations of one or more of the associated listed items.

Referring to fig. 1, fig. 1 is a flowchart illustrating a method for converting a cartoon-style image according to an embodiment of the present invention. The parameter adjusting method based on the residual error Kalman filtering model is applied to electronic equipment with a touch screen, and is executed through application software installed in a user terminal, wherein the user terminal is the electronic equipment used for executing the cartoon style image conversion method, such as a tablet computer, a mobile phone, a notebook computer, a desktop computer, intelligent wearable equipment (such as an intelligent watch and an intelligent bracelet) and the like. The following describes the method of converting the comic-style image in detail.

As shown in fig. 1, the method includes the following steps S110 to S150.

And S110, receiving an image containing a human face.

An image containing a human face is received. Specifically, the image containing the human face is an image without a cartoon style, and the image containing the human face may be an RGB image, a gray-scale image, or a YCBCR image. In the embodiment of the present invention, the image containing a human face is an RGB image, and after receiving the image containing a human face, the user terminal may perform cartoon style conversion on the image containing a human face, so as to obtain a cartoon style image of the image containing a human face. The RGB image uses R, G, B three components to identify the color of a pixel, R, G, B represents three different basic colors of red, green and blue, and any color can be synthesized by three primary colors. The graphic file format stores the RGB image as a 24-bit image, with the red, green, and blue components occupying 8 bits each.

And S120, carrying out segmentation processing on the image containing the face to obtain an image of an eye region and an image of a non-eye region.

And carrying out segmentation processing on the image containing the face to obtain an image of an eye region and an image of a non-eye region. Specifically, after receiving the image containing the face, the user terminal scans the image containing the face to obtain pixel information of eyes in the face in the image containing the face, so that the image containing the face can be segmented to be divided into an image of the eye region and an image of a non-eye region, and then the image of the eye region is converted, so that the image of the eye region can have a cartoon style.

In another embodiment, as shown in fig. 2, step S120 is preceded by step S120 a.

S120a, preprocessing the image containing the human face according to a preset preprocessing rule to obtain a preprocessed image.

And preprocessing the image containing the face according to a preset preprocessing rule to obtain a preprocessed image. Specifically, the preprocessing rule is rule information for preprocessing the image containing the face, and after the image containing the face is preprocessed according to the preprocessing rule, the amount of computation of subsequent terminal equipment on the image containing the face can be further reduced, so that the efficiency of cartoon style conversion on the image containing the face is improved.

In another embodiment, as shown in FIG. 3, step S120a includes sub-step S120a 1.

And S120a1, performing cutting processing on the image containing the human face to obtain a cut image.

And cutting the image containing the human face to obtain a cut image. In the embodiment of the present invention, the image containing the face is an RGB image, that is, the image containing the face is three-channel data, the range of the three-channel data is 0 to 255, and after the user terminal receives the image containing the face, in order to reduce the amount of calculation of the user terminal on the image containing the face, the image containing the face needs to be clipped, so that the cartoon style conversion is performed better. After the image containing the human face is cut, the size of the cut image is not more than 320mm x 240 mm.

And S120a2, carrying out zooming processing on the cut image to obtain a zoomed image.

And carrying out zooming processing on the cut image to obtain a zoomed image. In the embodiment of the present invention, after the image containing the face is cut, in order to further reduce the calculation amount of the user terminal, the image after the cutting needs to be scaled. And after the image after the cropping processing is subjected to scaling processing, the size of the obtained image after the scaling processing is not more than 320mm x 240 mm.

S120a3, carrying out normalization processing on the image after the scaling processing to obtain the image after the preprocessing.

And carrying out normalization processing on the image after the scaling processing to obtain the preprocessed image. In the embodiment of the invention, after the image containing the human face is cut and zoomed, the average value 127 is subtracted from the three-channel data of the zoomed image, so that the range of the data of the zoomed image is changed from 0-255 to-127-128, the center of the data of the zoomed image is changed to be (0, 0) as the center, then the changed data is divided by 255, and then the normalization of the zoomed image can be completed, so that the data range of the image containing the human face is changed to be-0.5.

In another embodiment, as shown in fig. 4, step S120 comprises sub-steps S121, S122.

And S121, acquiring coordinate data of the eye region in the preprocessed image.

And acquiring coordinate data of the eye region in the preprocessed image. In the embodiment of the invention, the coordinate data is obtained by inputting the preprocessed image into a preset human face detector. The face detector is used for detecting coordinate data of an eye region in the preprocessed image, the face detector can be used for detecting key points in the preprocessed image, so that the coordinate data of the eye region can be acquired from the preprocessed image, after the coordinate data is acquired, the preprocessed image can be segmented, and then the image of the eye region and the image of a non-eye region are acquired. The face detector is a Haar cascade classifier, the Haar cascade classifier scans and compares the preprocessed image from left to right and from top to bottom by adopting a rectangular frame, and coordinate data of the eye area can be searched from the preprocessed image.

And S122, carrying out segmentation processing on the preprocessed image according to the coordinate data to obtain an image of an eye region and an image of a non-eye region.

And carrying out segmentation processing on the preprocessed image according to the coordinate data to obtain an image of an eye region and an image of a non-eye region. In the embodiment of the invention, after the coordinate data of the eye region in the preprocessed image is determined by the Haar cascade classifier, the image of the eye region in the preprocessed image is segmented, so that the preprocessed image can be segmented into the image of the eye region and the image of the non-eye region, and the subsequent processing of the cartoon style of the image of the eye region and the image of the non-eye region is facilitated.

S130, converting the image of the eye area according to a preset light weight neural network to obtain an eye image with a cartoon style.

And converting the image of the eye area according to a preset light weight neural network to obtain an eye image with a cartoon style. Specifically, the lightweight neural network reduces the parameter quantity of the network on the basis of the original deep neural network, so that the lightweight neural network can perform rapid operation, and further the efficiency of cartoon conversion can be improved. In the embodiment of the invention, because the difference between the cartoon containing the human face and the original image is lower, the eyes are the most different places, and the eyes are the most important part in the visual perception of human subjectivity. Therefore, the light neural network is adopted to convert the images of the eye regions to obtain the eye images with cartoon styles, and the effect of the images with human faces after cartoon conversion is ensured.

In another embodiment, as shown in fig. 5, step S130 includes sub-steps S131 and S132.

S131, inputting the image of the eye area into a MobileNet of a preset Cycle GAN model for convolution processing to obtain the characteristic information of the image of the eye area.

And inputting the image of the eye area into a MobileNet of a preset Cycle GAN model for convolution processing to obtain the characteristic information of the image of the eye area. Specifically, the Cycle GAN (cyclic generation countermeasure network) model is trained in advance and used for cartoon conversion of the eyes in the image containing the human face, and the cyclic generation countermeasure network is a powerful computer algorithm, has the potential of improving a digital ecosystem, and can convert information from one representation form to another representation form. In the embodiment of the present invention, the encoder in the Cycle GAN model is MobileNet, MobileNet is a lightweight convolutional neural network, the basic unit of MobileNet is depth separable convolution (depth separable convolution), and depth separable convolution is actually a decomposable convolution operation (decomposed convolution), which can be decomposed into two smaller operations: the method comprises the steps of depth convolution (depthwise convolution) and point-by-point convolution (pointwise convolution), wherein each convolution kernel only pays attention to information of a single channel during depth convolution, each convolution kernel can be combined with information of a plurality of channels during point-by-point convolution, and images of the eye area are subjected to convolution processing through MobileNet of a Cycle GAN model, so that the calculation amount of a user terminal is reduced, the operation speed is improved, and meanwhile, the accuracy of coding the images of the eye area is guaranteed.

S132, inputting the characteristic information into Unet of the Cycle GAN model for decoding, and identifying the eye image containing the cartoon style according to a discriminator in the Cycle GAN model.

Inputting the characteristic information into Unet of the Cycle GAN model for decoding, and identifying the eye image containing the cartoon style according to a discriminator in the Cycle GAN model. In the embodiment of the invention, an encoder in the Cycle GAN model is in a net architecture, MobileNet in the Cycle GAN model performs convolution operation on the image of the eye area to obtain characteristic information of the image of the eye area, then decodes the characteristic information through the net of the Cycle GAN model to obtain a plurality of eye images containing a cartoon style, and then performs identification and screening on the eye images containing the cartoon style through a discriminator in the Cycle GAN model to obtain the eye images containing the cartoon style, so that the cartoon style conversion of the eye area in the image containing the human face can be completed.

And S140, performing cartoon style processing on the image of the non-eye area according to a traditional image algorithm to obtain a cartoon style processed image.

And performing cartoon style processing on the image of the non-eye area according to a traditional image algorithm to obtain a cartoon style processed image. Specifically, the conventional image algorithm is an algorithm for performing image denoising, image transformation, image analysis, image compression, image enhancement, image blurring processing and the like on an image in the prior art, and the traditional image algorithm is used for performing cartoon style processing on the image in the non-eye area, so that the calculation amount of a user terminal can be reduced, and the cartoon style characteristics of the non-eye area in the image containing the human face are ensured.

In another embodiment, as shown in fig. 6, step S140 includes sub-steps S141, S142.

S141, carrying out edge detection on the image of the non-eye area to obtain the face contour of the non-eye area.

And carrying out edge detection on the image of the non-eye region to obtain the face contour of the non-eye region. Specifically, the edge detection is used for detecting a face contour in the image of the non-eye region, so as to obtain the face contour of the non-eye region, wherein the edge detection is essentially a filtering algorithm, and is different from the selection of a filter, and the filtering rules are completely consistent. The edge detection includes: a first-order edge detection operator, a Sobel edge detection operator, a Canny edge detection operator, and a second-order edge detection operator. In this embodiment, a Canny edge detection operator is adopted to perform edge detection on the image of the non-eye region, so as to obtain a face contour of the non-eye region. The Canny edge detection algorithm not only has strict definition, but also can provide good and reliable detection, and the specific flow of the Canny edge detection operator is as follows: using a Gaussian filter to smooth the image and filter out noise; calculating the gradient strength and direction of each pixel point in the image; applying Non-Maximum Suppression (Non-Maximum Suppression) to eliminate spurious responses caused by edge detection; applying Double-Threshold (Double-Threshold) detection to determine true and potential edges; edge detection is finally accomplished by suppressing isolated weak edges.

And S142, processing the non-human face contour region in the non-eye region according to a k-means clustering algorithm to obtain the cartoon style processed image.

And processing the non-human face contour region in the non-eye region according to a k-means clustering algorithm to obtain the image with the cartoon style processed. Specifically, the K-means clustering algorithm is a clustering analysis algorithm for iterative solution, and the K-means clustering algorithm comprises the steps of dividing data into K groups in advance, randomly selecting K objects as initial clustering centers, calculating the distance between each object and each seed clustering center, and allocating each object to the nearest clustering center. In the embodiment of the invention, the pixels of the non-human face contour region in the non-eye region are subjected to clustering analysis by a k-means clustering algorithm, so that the regions with small pixel difference are clustered into the same pixel, and further colors similar to a cartoon style can be obtained, and then the human face contour of the non-eye region is added to obtain the image processed by the cartoon style.

S150, the eye image with the cartoon style is spliced with the image with the cartoon style processed to obtain an image with the cartoon style.

And splicing the eye image containing the cartoon style with the image processed by the cartoon style to obtain an image containing the cartoon style. In the embodiment of the invention, the light-weight neural network is used for independently processing the cartoon style of the eye area in the image containing the face, meanwhile, the traditional image processing algorithm is used for processing the cartoon style of the non-face area in the image containing the face, and finally, the images obtained by the light-weight neural network and the non-face area are spliced, so that the cartoon style conversion of the image containing the face can be completed, the cartoon conversion efficiency is improved, the calculated amount is reduced, and the cartoon effect of the image obtained after conversion is ensured.

In the method for converting the cartoon style image, provided by the embodiment of the invention, the image containing the face is received; carrying out segmentation processing on the image containing the face to obtain an image of an eye region and an image of a non-eye region; converting the image of the eye area according to a preset lightweight neural network to obtain an eye image with a cartoon style; performing cartoon style processing on the image of the non-eye area according to a traditional image algorithm to obtain an image with a processed cartoon style; and splicing the eye image containing the cartoon style with the image processed by the cartoon style to obtain an image containing the cartoon style. According to the method, based on the difference of the cartoon and the human eyes in the original photo, the light neural network is adopted to convert the eyes in the image containing the human face to obtain the eyes with the cartoon style, meanwhile, the traditional image processing method is adopted to process the non-eye area and splice the non-eye area with the converted eyes with the cartoon style, so that the image containing the human face can be converted into the image with the cartoon style, the conversion efficiency of the cartoon style image is greatly improved, and the calculation amount is reduced.

The embodiment of the invention also provides a cartoon-style image conversion device 100, which is used for executing any embodiment of the cartoon-style image conversion method.

Specifically, referring to fig. 7, fig. 7 is a schematic block diagram of a cartoon-style image conversion apparatus 100 according to an embodiment of the present invention.

As shown in fig. 7, the apparatus 100 for converting a cartoon-style image includes a receiving unit 110, a first dividing unit 120, a converting unit 130, a first processing unit 140, and a splicing unit 150.

The receiving unit 110 is configured to receive an image including a human face.

The first segmentation unit 120 is configured to perform segmentation processing on the image including the face to obtain an image of an eye region and an image of a non-eye region.

In another embodiment of the present invention, the apparatus 100 for converting a cartoon-style image further includes: and a preprocessing unit.

And the preprocessing unit is used for preprocessing the image containing the face according to a preset preprocessing rule to obtain a preprocessed image.

In other inventive embodiments, the preprocessing unit includes: the device comprises a clipping unit, a scaling unit and a normalization unit.

The cutting unit is used for cutting the image containing the human face to obtain a cut image; the zooming unit is used for zooming the cut image to obtain a zoomed image; and the normalization unit is used for performing normalization processing on the zoomed image to obtain the preprocessed image.

In other inventive embodiments, the first dividing unit 120 includes: an acquisition unit and a second segmentation unit.

An acquisition unit, configured to acquire coordinate data of an eye region in the preprocessed image; and the second segmentation unit is used for carrying out segmentation processing on the preprocessed image according to the coordinate data to obtain an image of an eye region and an image of a non-eye region.

And the conversion unit 130 is configured to perform conversion processing on the image of the eye region according to a preset lightweight neural network to obtain an eye image with a cartoon style.

In other inventive embodiments, the conversion unit 130 includes: a first input unit and a second input unit.

The first input unit is used for inputting the image of the eye area into a MobileNet of a preset Cycle GAN model for coding processing to obtain characteristic information of the image of the eye area, and the second input unit is used for inputting the characteristic information into a Unet of the Cycle GAN model for decoding and identifying the eye image containing the cartoon style according to a discriminator in the Cycle GAN model.

The first processing unit 140 is configured to perform cartoon style processing on the image of the non-eye area according to a conventional image algorithm to obtain a cartoon style processed image.

In another embodiment of the present invention, the first processing unit 140 includes: a detection unit and a second processing unit.

The detection unit is used for carrying out edge detection on the image of the non-eye area to obtain a human face contour of the non-eye area; and the second processing unit is used for processing the non-human face contour region in the non-eye region according to a k-means clustering algorithm to obtain the image with the cartoon style processed.

And the splicing unit 150 is used for splicing the eye image containing the cartoon style with the image processed by the cartoon style to obtain an image containing the cartoon style.

The cartoon-style image conversion device 100 provided by the embodiment of the invention is used for receiving the image containing the human face; carrying out segmentation processing on the image containing the face to obtain an image of an eye region and an image of a non-eye region; converting the image of the eye area according to a preset lightweight neural network to obtain an eye image with a cartoon style; performing cartoon style processing on the image of the non-eye area according to a traditional image algorithm to obtain an image with a processed cartoon style; and splicing the eye image containing the cartoon style with the image processed by the cartoon style to obtain an image containing the cartoon style.

Referring to fig. 8, fig. 8 is a schematic block diagram of a computer device according to an embodiment of the present invention.

Referring to fig. 8, the device 500 includes a processor 502, memory, and a network interface 505 connected by a system bus 501, where the memory may include a storage medium 503 and an internal memory 504.

The storage medium 503 may store an operating system 5031 and a computer program 5032. The computer program 5032, when executed, may cause the processor 502 to perform a method of converting a caricature-style image.

The processor 502 is used to provide computing and control capabilities that support the operation of the overall device 500.

The internal memory 504 provides an environment for running the computer program 5032 in the non-volatile storage medium 503, and when the computer program 5032 is executed by the processor 502, the processor 502 may be caused to execute a method for converting a cartoon-style image.

The network interface 505 is used for network communication, such as providing transmission of data information. Those skilled in the art will appreciate that the configuration shown in fig. 8 is a block diagram of only a portion of the configuration associated with aspects of the present invention and does not constitute a limitation of the apparatus 500 to which aspects of the present invention may be applied, and that a particular apparatus 500 may include more or less components than those shown, or may combine certain components, or have a different arrangement of components.

Wherein the processor 502 is configured to run the computer program 5032 stored in the memory to implement the following functions: receiving an image containing a human face; carrying out segmentation processing on the image containing the face to obtain an image of an eye region and an image of a non-eye region; converting the image of the eye area according to a preset lightweight neural network to obtain an eye image with a cartoon style; performing cartoon style processing on the image of the non-eye area according to a traditional image algorithm to obtain an image with a processed cartoon style; and splicing the eye image containing the cartoon style with the image processed by the cartoon style to obtain an image containing the cartoon style.

Those skilled in the art will appreciate that the embodiment of the apparatus 500 illustrated in fig. 8 does not constitute a limitation on the specific construction of the apparatus 500, and in other embodiments, the apparatus 500 may include more or fewer components than those illustrated, or some components may be combined, or a different arrangement of components. For example, in some embodiments, the apparatus 500 may only include the memory and the processor 502, and in such embodiments, the structure and function of the memory and the processor 502 are the same as those of the embodiment shown in fig. 8, and are not repeated herein.

It should be understood that in the present embodiment, the Processor 502 may be a Central Processing Unit (CPU), and the Processor 502 may also be other general-purpose processors 502, a Digital Signal Processor 502 (DSP), an Application Specific Integrated Circuit (ASIC), an off-the-shelf Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic device, discrete hardware component, etc. The general-purpose processor 502 may be a microprocessor 502 or the processor 502 may be any conventional processor 502 or the like.

In another embodiment of the present invention, a computer storage medium is provided. The storage medium may be a nonvolatile computer-readable storage medium or a volatile storage medium. The storage medium stores a computer program 5032, wherein the computer program 5032 when executed by the processor 502 performs the steps of: receiving an image containing a human face; carrying out segmentation processing on the image containing the face to obtain an image of an eye region and an image of a non-eye region; converting the image of the eye area according to a preset lightweight neural network to obtain an eye image with a cartoon style; performing cartoon style processing on the image of the non-eye area according to a traditional image algorithm to obtain an image with a processed cartoon style; and splicing the eye image containing the cartoon style with the image processed by the cartoon style to obtain an image containing the cartoon style.

It is clear to those skilled in the art that, for convenience and brevity of description, the specific working processes of the above-described apparatuses, devices and units may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again. Those of ordinary skill in the art will appreciate that the elements and algorithm steps of the examples described in connection with the embodiments disclosed herein may be embodied in electronic hardware, computer software, or combinations of both, and that the components and steps of the examples have been described in a functional general in the foregoing description for the purpose of illustrating clearly the interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention.

In the embodiments provided by the present invention, it should be understood that the disclosed apparatus, device and method can be implemented in other ways. For example, the above-described embodiments of the apparatus are merely illustrative, and for example, the division of the units is only a logical division, and there may be other divisions when the actual implementation is performed, or units having the same function may be grouped into one unit, for example, a plurality of units or components may be combined or may be integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may also be an electric, mechanical or other form of connection.

The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment of the present invention.

In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.

The integrated unit, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a storage medium. Based on such understanding, the technical solution of the present invention essentially contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product stored in a storage medium and including instructions for causing a device 500 (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: various media capable of storing program codes, such as a usb disk, a removable hard disk, a Read-Only Memory (ROM), a magnetic disk, or an optical disk.

While the invention has been described with reference to specific embodiments, the invention is not limited thereto, and various equivalent modifications and substitutions can be easily made by those skilled in the art within the technical scope of the invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.

完整详细技术资料下载
上一篇:石墨接头机器人自动装卡簧、装栓机
下一篇:一种图像背景替换方法、系统、电子设备及存储介质

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!