CN108615253B - Image generation method, device and computer readable storage medium - Google Patents
Image generation method, device and computer readable storage medium Download PDFInfo
- Publication number
- CN108615253B CN108615253B CN201810323324.7A CN201810323324A CN108615253B CN 108615253 B CN108615253 B CN 108615253B CN 201810323324 A CN201810323324 A CN 201810323324A CN 108615253 B CN108615253 B CN 108615253B
- Authority
- CN
- China
- Prior art keywords
- image
- template
- similarity
- pixel point
- binary
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T11/00—2D [Two Dimensional] image generation
- G06T11/80—Creating or modifying a manually drawn or painted image using a manual input device, e.g. mouse, light pen, direction keys on keyboard
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T11/00—2D [Two Dimensional] image generation
- G06T11/001—Texturing; Colouring; Generation of texture or colour
Abstract
The invention provides an image generation method, an image generation device and a computer readable storage medium, wherein the image generation method comprises the steps of collecting a drawing image drawn on a screen of a terminal device; performing gray level calculation on the drawn image by adopting a weighted average algorithm to obtain a gray level image; carrying out binarization processing on the gray level image to obtain a binary image; respectively calculating the similarity between the binary image and a plurality of template images prestored in a template image database; and acquiring the template image corresponding to the maximum similarity in the plurality of template images and pushing the template image to the screen of the terminal equipment. The method can effectively reduce the difficulty of electronic painting, has simple image processing process, reduces the image calculation processing amount of electronic painting products, and improves the quality of drawn images.
Description
Technical Field
The present invention relates to the field of image processing technologies, and in particular, to an image generation method and apparatus, and a computer-readable storage medium.
Background
With the popularization of social electronization, more and more people begin to use electronic products, such as mobile phones, tablets, computers, electronic drawing boards, etc., to draw, however, the existing drawing products or tools on the market at present have complex and time-consuming operation steps, such as: the user needs to create a blank drawing board on the touch screen, select the drawing type, and set drawing parameters (color, thickness, brush shape and transparency) to complete drawing. Secondly, there is a difference between the illustration and the user drawing content, which is mainly reflected in: after the user finishes drawing, the touch screen identifies and displays the illustration similar to the drawing according to the drawing content, but the illustration strokes are more standard and have fixed forms, and the illustration strokes are different from the strokes and forms drawn by the user, so that on one hand, the drawing difficulty is increased, on the other hand, the image processing process is complex, the image calculation processing amount of the drawing product or tool drawn by the user is increased, and the output drawing image effect is poor.
Disclosure of Invention
The invention aims to provide an image generation method, an image generation device and a computer readable storage medium, which can effectively reduce the difficulty of electronic painting, have simple image processing process, reduce the image calculation processing amount of electronic painting products and improve the quality of drawn images.
The embodiment of the invention provides an image generation method, which comprises the following steps:
collecting a drawing image drawn on a screen of a terminal device;
performing gray level calculation on the drawn image by adopting a weighted average algorithm to obtain a gray level image;
carrying out binarization processing on the gray level image to obtain a binary image;
respectively calculating the similarity between the binary image and a plurality of template images prestored in a template image database;
and acquiring the template image corresponding to the maximum similarity in the template images and pushing the template image to the screen of the terminal equipment.
Preferably, the binarizing the grayscale image to obtain a binary image specifically includes:
judging whether the gray value of any pixel point of the gray image is larger than a first threshold value, if so, updating the gray value of any pixel point to a first set gray value, and if not, updating the gray value of any pixel point to a second set gray value to obtain the binary image;
and the first threshold is the gray average value of all pixel points in the gray image.
Preferably, the calculating the similarity between the binary image and a plurality of template images pre-stored in a template image database includes:
calculating the distance between each pixel point of the binary image and each pixel point of any template image by adopting an Euclidean distance algorithm;
and calculating the similarity between the binary image and any one template image according to the distance between each pixel point of the binary image and each pixel point of any one template image.
Preferably, after calculating the similarity between the binary image and any one of the template images according to the distance between each pixel point of the binary image and each pixel point of any one of the template images, the method further includes:
obtaining template images with the similarity larger than a second threshold value in the plurality of template images, and sequencing the template images according to the sequence of the similarity from large to small;
acquiring a first set number of template images from the sequenced template images according to the sequence of similarity from large to small to generate a first image set to be screened;
carrying out image blocking processing on the binary image to obtain a plurality of block images;
respectively calculating the similarity between the plurality of block images and any template image in the first image set to be screened;
and calculating the average similarity of the plurality of block images corresponding to any template image in the first image set to be screened according to the similarity of the plurality of block images corresponding to any template image in the first image set to be screened, wherein the average similarity is the similarity of the binary image and any template image.
Preferably, the image generation method further includes:
an acquired color image;
inputting the color image into a square matrix with a set size, and adjusting pixels of the color image;
and carrying out gray processing and binarization processing on the color image to obtain the template image and storing the template image into the template image database.
Preferably, the calculating, by using the euclidean distance algorithm, a distance between each pixel point of the binary image and each pixel point of any one of the template images specifically includes:
according to the formulaCalculating each pixel point and any pixel point of the binary imageThe distance between each pixel point of the template image is defined;
where x, y are two points in a two-dimensional space.
Preferably, the calculating the similarity between the binary image and any one of the template images according to the distance between each pixel point of the binary image and each pixel point of any one of the template images specifically includes:
according to the formulaAnd calculating the similarity between the binary image and any one template image.
An embodiment of the present invention further provides an image generating apparatus, including:
the image acquisition module is used for acquiring a drawing image drawn on a screen of the terminal equipment;
the gray processing module is used for carrying out gray calculation on the drawn image by adopting a weighted average algorithm to obtain a gray image;
the binary processing module is used for carrying out binary processing on the gray level image to obtain a binary image;
the similarity calculation module is used for respectively calculating the similarity between the binary image and a plurality of template images prestored in a template image database;
and the image pushing module is used for acquiring the template image corresponding to the maximum similarity in the plurality of template images and pushing the template image to the screen of the terminal equipment.
An embodiment of the present invention further provides an image generation apparatus, which includes a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, and the processor executes the computer program to implement the image generation method as described above.
An embodiment of the present invention further provides a computer-readable storage medium, where the computer-readable storage medium includes a stored computer program, and when the computer program runs, a device on which the computer-readable storage medium is located is controlled to execute the above-mentioned image generation method.
Compared with the prior art, the image generation method provided by the embodiment of the invention has the beneficial effects that: the image generation method comprises the steps of collecting a drawing image drawn on a screen of the terminal equipment; performing gray level calculation on the drawn image by adopting a weighted average algorithm to obtain a gray level image; carrying out binarization processing on the gray level image to obtain a binary image; respectively calculating the similarity between the binary image and a plurality of template images prestored in a template image database; and acquiring the template image corresponding to the maximum similarity in the plurality of template images and pushing the template image to the screen of the terminal equipment. The method can effectively reduce the difficulty of electronic painting, has simple image processing process, reduces the image calculation processing amount of electronic painting products, and improves the quality of the drawn image. The embodiment of the invention also provides an image generation device and a computer readable storage medium.
Drawings
FIG. 1 is a flow chart of an image generation method provided by an embodiment of the invention;
fig. 2 is a schematic diagram of an image generating apparatus according to 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 only a part of the embodiments of the present invention, and not all of the embodiments. 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.
Please refer to fig. 1, which is a flowchart illustrating an image generating method according to an embodiment of the present invention, the image generating method includes:
s100: collecting a drawing image drawn on a screen of a terminal device;
s200: performing gray level calculation on the drawn image by adopting a weighted average algorithm to obtain a gray level image;
s300: carrying out binarization processing on the gray level image to obtain a binary image;
s400: respectively calculating the similarity between the binary image and a plurality of template images prestored in a template image database;
s500: and acquiring the template image corresponding to the maximum similarity in the plurality of template images and pushing the template image to the screen of the terminal equipment.
In the embodiment, before drawing, drawing setting such as drawing type selection and painting brush parameter setting is not needed, and drawing is only needed on a screen of the terminal equipment, so that the drawing operation is simple, the drawing difficulty is reduced, and the drawing time is effectively shortened; the method comprises the steps that a sensor of the terminal equipment receives a drawing image drawn on a screen by a user and sends the drawing image to a processor of the terminal equipment for graying processing, binarization processing and similarity matching processing with a template image, and finally the template image with the highest similarity is pushed to the screen of the terminal equipment, so that the automatic optimization generation effect of the drawing image is realized, the image processing process is simple, the image calculation processing amount of an electronic drawing product is reduced, and the quality of the drawing image is improved. The terminal equipment is equipment such as cell-phone, flat board, drawing board, touch screen.
Calculating the gray value of each pixel point of the drawing image by adopting a weighted average formula f (i, j) ═ 0.30R (i, j) +0.59G (i, j) +0.11B (i, j); i, j is the position of any pixel, R (i, j) is the red component of the pixel, G (i, j) is the green component of the pixel, and B (i, j) is the blue component of the pixel. And generating the gray image according to the gray value of each pixel point of the drawn image. The gray value of each pixel point is within the range of 0-255 through the formula, and the gray image presents three color states of black, white and gray. After the drawing image is subjected to graying processing, only one gray value is left in the drawing image, so that the processing efficiency of the subsequent drawing image can be greatly improved, and the texture characteristic information of the drawing image is not influenced.
Specifically, a screen of the terminal device is provided with a first display window and a second display window, the first display window displays a binary image corresponding to the drawing image, and the second display window displays the pushed template image. When the terminal equipment displays the template image with the highest similarity with the drawing image drawn by the user, the first display window only keeps the texture features of the drawing image, namely the binary image corresponding to the drawing image, so that the difference between the template image and the drawing image can be effectively reduced, the effect of drawing by combining the user and the system is realized, and the user is guided to draw more clearly.
In an alternative embodiment, S300: performing binarization processing on the gray level image to obtain a binary image, which specifically comprises the following steps:
judging whether the gray value of any pixel point of the gray image is larger than a first threshold value, if so, updating the gray value of any pixel point to a first set gray value, and if not, updating the gray value of any pixel point to a second set gray value to obtain the binary image;
and the first threshold is the gray average value of all pixel points in the gray image.
In this embodiment, the first set gradation value is 0 (black) and the second set gradation value is 255 (white). The gray level image is further subjected to binarization processing to obtain a gray level binary image, so that the drawn image can be simplified, the data volume of the drawn image is reduced, the outline of the drawn image is highlighted, and the accuracy of similarity matching with the template image is improved.
In other embodiments, the first set gray value of the pixel point of the binary image is updated to 0, the second set gray value of the pixel point of the binary image is updated to 1, and the updated binary image is obtained and stored in the local database. The storage pressure of the terminal equipment can be relieved by mapping the gray value of the binary image to be 0 or 1 and adopting 1 as a code to represent the binary image.
In an alternative embodiment, S400: respectively calculating the similarity of the binary image and a plurality of template images prestored in a template image database, and specifically comprising the following steps of:
calculating the distance between each pixel point of the binary image and each pixel point of any template image by adopting an Euclidean distance algorithm;
and calculating the similarity between the binary image and any one template image according to the distance between each pixel point of the binary image and each pixel point of any one template image.
In this embodiment, it can be understood that, when the distance between each pixel point of the binary image and each pixel point of any one of the template images is smaller, the similarity between the binary image and any one of the template images is larger.
In an optional embodiment, after calculating the similarity between the binary image and any one of the template images according to the distance between each pixel point of the binary image and each pixel point of any one of the template images, the method further includes:
obtaining template images with the similarity larger than a second threshold value in the plurality of template images, and sequencing the template images according to the sequence of the similarity from large to small;
acquiring a first set number of template images from the sequenced template images according to the sequence of similarity from large to small to generate a first image set to be screened;
carrying out image blocking processing on the binary image to obtain a plurality of block images;
respectively calculating the similarity between the plurality of block images and any template image in the first image set to be screened;
and calculating the average similarity of the plurality of block images corresponding to any template image in the first image set to be screened according to the similarity of the plurality of block images corresponding to any template image in the first image set to be screened, wherein the average similarity is the similarity of the binary image and any template image.
In an optional embodiment, the image generating method further comprises:
an acquired color image;
inputting the color image into a grid matrix with a set size, and adjusting pixels of the color image;
and carrying out graying processing and binarization processing on the color image to obtain the template image and storing the template image into the template image database.
In this embodiment, the color image is converted into the template image by using the same graying process and binarization process as the above drawing image, and the graying process and binarization process of the color image will not be described here.
In an optional embodiment, the calculating, by using an euclidean distance algorithm, a distance between each pixel point of the binary image and each pixel point of any one of the template images specifically includes:
according to the formulaCalculating the distance between each pixel point of the binary image and each pixel point of any template image;
where x, y are two points in a two-dimensional space.
In an optional embodiment, the calculating, according to a distance between each pixel point of the binary image and each pixel point of any one of the template images, a similarity between the binary image and any one of the template images specifically includes:
according to the formulaAnd calculating the similarity between the binary image and any one template image.
Please refer to fig. 2, which is a schematic diagram of an image generating apparatus according to an embodiment of the present invention, the image generating apparatus includes:
the image acquisition module 1 is used for acquiring a drawing image drawn on a screen of the terminal equipment;
the gray processing module 2 is used for carrying out gray calculation on the drawn image by adopting a weighted average algorithm to obtain a gray image;
a binary processing module 3, configured to perform binarization processing on the grayscale image to obtain a binary image;
the similarity calculation module 4 is used for calculating the similarity between the binary image and a plurality of template images prestored in a template image database respectively;
and the image pushing module 5 is configured to obtain a template image corresponding to the maximum similarity in the template images and push the template image to the screen of the terminal device.
In the embodiment, before drawing, drawing setting such as drawing type selection and painting brush parameter setting is not needed, and drawing is only needed on a screen of the terminal equipment, so that the drawing operation is simple, the drawing difficulty is reduced, and the drawing time is effectively shortened; the sensor of the terminal equipment receives a drawing image drawn on a screen by a user and sends the drawing image to the processor of the terminal equipment for graying processing, binarization processing and similarity matching processing with the template image, and finally the template image with the highest similarity is pushed to the screen of the terminal equipment, so that the automatic optimization generation effect of the drawing image is realized, the image processing process is simple, the image calculation processing amount of an electronic drawing product is reduced, and the quality of the drawing image is improved. The terminal equipment is equipment such as cell-phone, flat board, drawing board, touch screen.
Calculating the gray value of each pixel point of the drawing image by adopting a weighted average formula f (i, j) ═ 0.30R (i, j) +0.59G (i, j) +0.11B (i, j); i, j is the position of any pixel, R (i, j) is the red component of the pixel, G (i, j) is the green component of the pixel, and B (i, j) is the blue component of the pixel. And generating the gray image according to the gray value of each pixel point of the drawn image. The gray value of each pixel point is within the range of 0-255 through the formula, and the gray image presents three color states of black, white and gray. After the drawing image is subjected to graying processing, only one gray value is left in the drawing image, so that the processing efficiency of the subsequent drawing image can be greatly improved, and the texture characteristic information of the drawing image is not influenced.
Specifically, a screen of the terminal device is provided with a first display window and a second display window, the first display window displays a binary image corresponding to the drawing image, and the second display window displays the pushed template image. When the terminal equipment displays the template image with the highest similarity with the drawing image drawn by the user, the first display window only keeps the texture features of the drawing image, namely the binary image corresponding to the drawing image, so that the difference between the template image and the drawing image can be effectively reduced, the effect of drawing by combining the user and the system is realized, and the user is guided to draw more clearly.
In an optional embodiment, the binary processing module 3 is configured to determine whether a gray value of any one pixel of the gray image is greater than a first threshold, update the gray value of the any one pixel to a first set gray value if the gray value of the any one pixel of the gray image is greater than the first threshold, and update the gray value of the any one pixel to a second set gray value if the gray value of the any one pixel of the gray image is not greater than the first set gray value to obtain the binary image;
the first threshold is the gray average value of all pixel points in the gray image.
In this embodiment, the first set gradation value is 0 (black) and the second set gradation value is 255 (white). The gray level image is further subjected to binarization processing to obtain a gray level binary image, so that the drawn image can be simplified, the data volume of the drawn image is reduced, the outline of the drawn image is highlighted, and the accuracy of similarity matching with the template image is improved.
In other embodiments, the first set gray value of the pixel point of the binary image is updated to 0, the second set gray value of the pixel point of the binary image is updated to 1, and the updated binary image is obtained and stored in the local database. The storage pressure of the terminal equipment can be relieved by mapping the gray value of the binary image to be 0 or 1 and adopting 1 as a code to represent the binary image.
In an alternative embodiment, the similarity calculation module 4 comprises:
the distance calculation unit is used for calculating the distance between each pixel point of the binary image and each pixel point of any template image by adopting an Euclidean distance algorithm;
and the first similarity calculation unit is used for calculating the similarity between the binary image and any one template image according to the distance between each pixel point of the binary image and each pixel point of any one template image.
In this embodiment, it can be understood that, when the distance between each pixel point of the binary image and each pixel point of any one of the template images is smaller, the similarity between the binary image and any one of the template images is larger.
In an optional embodiment, the image generating apparatus further comprises:
the image sorting module is used for acquiring the template images with the similarity greater than a second threshold value in the plurality of template images and sorting the template images according to the sequence of the similarity from large to small;
the image set generation module is used for acquiring a first set number of template images from the sequenced template images according to the sequence of similarity from large to small so as to generate a first image set to be screened;
the image blocking module is used for carrying out image blocking processing on the binary image to obtain a plurality of blocked images;
the second image calculating unit is used for respectively calculating the similarity between the plurality of blocked images and any template image in the first image set to be screened;
and calculating the average similarity of the plurality of block images corresponding to any template image in the first image set to be screened according to the similarity of the plurality of block images corresponding to any template image in the first image set to be screened, wherein the average similarity is the similarity of the binary image and any template image.
In an optional embodiment, the image generating apparatus further comprises:
the template image acquisition module is used for acquiring a color image;
the pixel adjusting module is used for inputting the color image into a grid matrix with a set size and adjusting pixels of the color image;
and the image processing module is used for carrying out gray processing and binarization processing on the color image to obtain the template image and storing the template image into the template image database.
In this embodiment, the color image is converted into the template image by using the same graying process and binarization process as the above drawing image, and the graying process and binarization process of the color image will not be described here.
In an alternative embodiment, the distance calculation unit is configured to calculate the distance according to a formula Calculating the distance between each pixel point of the binary image and each pixel point of any template image;
where x, y are two points in a two-dimensional space.
In an alternative embodiment, the first similarity calculation unit is configured to calculate the first similarity according to a formulaAnd calculating the similarity between the binary image and any one template image.
An embodiment of the present invention further provides an image generating apparatus, which includes a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, and the processor implements the image generating method as described above when executing the computer program.
Illustratively, the computer program may be partitioned into one or more modules/units that are stored in the memory and executed by the processor to implement the invention. The one or more modules/units may be a series of computer program instruction segments capable of performing specific functions, which are used to describe the execution process of the computer program in the image generation apparatus. For example, the computer program may be divided into an image acquisition module 1, a gray processing module 2, a binary processing module 3, a similarity calculation module 4, and an image pushing module 5 as shown in fig. 2, where the specific functions of the modules are as follows: the image acquisition module 1 is used for acquiring a drawing image drawn on a screen of the terminal equipment; the gray processing module 2 is used for carrying out gray calculation on the drawn image by adopting a weighted average algorithm to obtain a gray image; a binary processing module 3, configured to perform binarization processing on the grayscale image to obtain a binary image; the similarity calculation module 4 is used for calculating the similarity between the binary image and a plurality of template images prestored in a template image database respectively; and the image pushing module 5 is configured to obtain a template image corresponding to the maximum similarity in the plurality of template images and push the template image to the screen of the terminal device.
The image generating device can be a desktop computer, a notebook, a palm computer, a cloud server and other computing devices. The image generation device may include, but is not limited to, a processor, a memory. It will be appreciated by those skilled in the art that the schematic diagram is merely an example of an image generating apparatus, and does not constitute a limitation to the image generating apparatus, and may include more or less components than those shown, or combine some components, or different components, for example, the image generating apparatus may further include an input and output device, a network access device, a bus, etc.
The Processor may be a Central Processing Unit (CPU), other general purpose Processor, a Digital Signal Processor (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, discrete hardware components, etc. The general purpose processor may be a microprocessor or the processor may be any conventional processor or the like, which is the control center of the image generating apparatus and connects the various parts of the entire image generating apparatus using various interfaces and lines.
The memory may be used to store the computer programs and/or modules, and the processor may implement various functions of the image generation apparatus by running or executing the computer programs and/or modules stored in the memory and calling data stored in the memory. The memory may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required by at least one function (such as a sound playing function, an image playing function, etc.), and the like; the storage data area may store data (such as audio data, a phonebook, etc.) created according to the use of the cellular phone, and the like. In addition, the memory may include high speed random access memory, and may also include non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), at least one magnetic disk storage device, a Flash memory device, or other volatile solid state storage device.
Wherein, the module/unit integrated with the image generating device can be stored in a computer readable storage medium if it is implemented in the form of software functional unit and sold or used as a stand-alone product. Based on such understanding, all or part of the flow of the method according to the embodiments of the present invention may also be implemented by a computer program, which may be stored in a computer-readable storage medium, and when the computer program is executed by a processor, the steps of the method embodiments may be implemented. Wherein the computer program comprises computer program code, which may be in the form of source code, object code, an executable file or some intermediate form, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, U.S. disk, removable hard disk, magnetic diskette, optical disk, computer Memory, Read-Only Memory (ROM), Random Access Memory (RAM), electrical carrier wave signal, telecommunications signal, and software distribution medium, etc. It should be noted that the computer-readable medium may contain suitable additions or subtractions depending on the requirements of legislation and patent practice in jurisdictions, for example, in some jurisdictions, computer-readable media may not include electrical carrier signals or telecommunication signals in accordance with legislation and patent practice.
It should be noted that the above-described device embodiments are merely illustrative, where the units described as separate parts may or may not be physically separate, and the parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment. In addition, in the drawings of the embodiment of the apparatus provided by the present invention, the connection relationship between the modules indicates that there is a communication connection therebetween, and may be specifically implemented as one or more communication buses or signal lines. One of ordinary skill in the art can understand and implement it without inventive effort.
The embodiment of the present invention further provides a computer-readable storage medium, where the computer-readable storage medium includes a stored computer program, and when the computer program runs, the apparatus where the computer-readable storage medium is located is controlled to execute the image generation method as described above.
Compared with the prior art, the image generation method provided by the embodiment of the invention has the beneficial effects that: the image generation method comprises the steps of collecting a drawing image drawn on a screen of the terminal equipment; performing gray level calculation on the drawn image by adopting a weighted average algorithm to obtain a gray level image; carrying out binarization processing on the gray level image to obtain a binary image; respectively calculating the similarity between the binary image and a plurality of template images prestored in a template image database; and acquiring the template image corresponding to the maximum similarity in the template images and pushing the template image to the screen of the terminal equipment. The method can effectively reduce the difficulty of electronic painting, has simple image processing process, reduces the image calculation processing amount of electronic painting products, and improves the quality of drawn images. The embodiment of the invention also provides an image generation device and a computer readable storage medium.
While the foregoing is directed to the preferred embodiment of the present invention, it will be understood by those skilled in the art that various changes and modifications may be made without departing from the spirit and scope of the invention.
Claims (8)
1. An image generation method, characterized by comprising:
collecting a drawing image drawn on a screen of a terminal device; performing gray level calculation on the drawn image by adopting a weighted average algorithm to obtain a gray level image;
carrying out binarization processing on the gray level image to obtain a binary image;
respectively calculating the similarity between the binary image and a plurality of template images prestored in a template image database;
calculating the distance between each pixel point of the binary image and each pixel point of any template image by adopting an Euclidean distance algorithm; calculating the similarity between the binary image and any one template image according to the distance between each pixel point of the binary image and each pixel point of any one template image; the template image is a binary image;
after calculating the similarity between the binary image and any one of the template images according to the distance between each pixel point of the binary image and each pixel point of any one of the template images, the method further includes:
obtaining template images with the similarity larger than a second threshold value in the plurality of template images, and sequencing the template images according to the sequence of the similarity from large to small;
acquiring a first set number of template images from the sequenced template images according to the sequence of similarity from large to small to generate a first image set to be screened;
carrying out image blocking processing on the binary image to obtain a plurality of block images;
respectively calculating the similarity between the plurality of block images and any template image in the first image set to be screened;
calculating the average similarity of the plurality of block images corresponding to any template image in the first image set to be screened according to the similarity of the plurality of block images corresponding to any template image in the first image set to be screened, wherein the average similarity is the similarity of the binary image and any template image;
and acquiring the template image corresponding to the maximum similarity in the template images and pushing the template image to the screen of the terminal equipment.
2. The image generation method according to claim 1, wherein the binarizing the grayscale image to obtain a binary image specifically includes:
judging whether the gray value of any pixel point of the gray image is larger than a first threshold value, if so, updating the gray value of any pixel point to a first set gray value, and if not, updating the gray value of any pixel point to a second set gray value to obtain the binary image;
and the first threshold is the gray average value of all pixel points in the gray image.
3. The image generation method of claim 1, further comprising:
an acquired color image;
inputting the color image into a grid matrix with a set size, and adjusting pixels of the color image;
and carrying out graying processing and binarization processing on the color image to obtain the template image and storing the template image into the template image database.
4. The image generation method according to claim 1, wherein the calculating, by using the euclidean distance algorithm, a distance between each pixel point of the binary image and each pixel point of any one of the template images specifically includes:
according to the formulaCalculating the distance between each pixel point of the binary image and each pixel point of any template image;
where x, y are two points in a two-dimensional space.
5. The image generation method according to claim 4, wherein the calculating a similarity between the binary image and any one of the template images according to a distance between each pixel point of the binary image and each pixel point of any one of the template images specifically includes:
6. An image generation apparatus, comprising:
the image acquisition module is used for acquiring a drawing image drawn on a screen of the terminal equipment;
the gray level processing module is used for carrying out gray level calculation on the drawn image by adopting a weighted average algorithm to obtain a gray level image;
the binary processing module is used for carrying out binary processing on the gray level image to obtain a binary image;
the similarity calculation module is used for respectively calculating the similarity between the binary image and a plurality of template images prestored in a template image database;
calculating the distance between each pixel point of the binary image and each pixel point of any template image by adopting an Euclidean distance algorithm; calculating the similarity between the binary image and any one template image according to the distance between each pixel point of the binary image and each pixel point of any one template image; the template image is a binary image;
the image pushing module is used for acquiring the template image corresponding to the maximum similarity in the plurality of template images and pushing the template image to the screen of the terminal equipment;
after calculating the similarity between the binary image and any one of the template images according to the distance between each pixel point of the binary image and each pixel point of any one of the template images, the method further includes:
obtaining template images with the similarity larger than a second threshold value in the plurality of template images, and sequencing the template images according to the sequence of the similarity from large to small;
acquiring a first set number of template images from the sequenced template images according to the sequence of similarity from large to small to generate a first image set to be screened;
carrying out image blocking processing on the binary image to obtain a plurality of block images;
respectively calculating the similarity between the plurality of block images and any template image in the first image set to be screened;
and calculating the average similarity of the plurality of block images corresponding to any template image in the first image set to be screened according to the similarity of the plurality of block images corresponding to any template image in the first image set to be screened, wherein the average similarity is the similarity of the binary image and any template image.
7. An image generation apparatus comprising a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, the processor implementing the image generation method of any one of claims 1 to 5 when executing the computer program.
8. A computer-readable storage medium, comprising a stored computer program, wherein the computer program, when executed, controls an apparatus in which the computer-readable storage medium is located to perform the image generation method according to any one of claims 1 to 5.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810323324.7A CN108615253B (en) | 2018-04-12 | 2018-04-12 | Image generation method, device and computer readable storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810323324.7A CN108615253B (en) | 2018-04-12 | 2018-04-12 | Image generation method, device and computer readable storage medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN108615253A CN108615253A (en) | 2018-10-02 |
CN108615253B true CN108615253B (en) | 2022-09-13 |
Family
ID=63659778
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201810323324.7A Active CN108615253B (en) | 2018-04-12 | 2018-04-12 | Image generation method, device and computer readable storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN108615253B (en) |
Families Citing this family (9)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109741418B (en) * | 2018-11-20 | 2023-08-04 | 广东智媒云图科技股份有限公司 | Low polygon style drawing acquisition method and device |
CN109727299A (en) * | 2018-11-20 | 2019-05-07 | 广东智媒云图科技股份有限公司 | A kind of control mechanical arm combines the method drawn a picture, electronic equipment and storage medium |
CN109886781B (en) * | 2019-01-31 | 2023-05-09 | 广东智媒云图科技股份有限公司 | Product recommendation method, device, equipment and storage medium based on painting behaviors |
CN109993202B (en) * | 2019-02-15 | 2023-08-22 | 广东智媒云图科技股份有限公司 | Line manuscript type graph similarity judging method, electronic equipment and storage medium |
CN109948653B (en) * | 2019-02-15 | 2023-08-25 | 广东智媒云图科技股份有限公司 | Image similarity judging method, electronic equipment and storage medium |
CN110175257B (en) * | 2019-04-15 | 2023-06-16 | 广东智媒云图科技股份有限公司 | Method for matching line manuscript images, electronic equipment and storage medium |
CN110390668B (en) * | 2019-06-26 | 2022-02-01 | 石家庄铁道大学 | Bolt looseness detection method, terminal device and storage medium |
CN110569907B (en) * | 2019-09-10 | 2022-03-04 | 网易(杭州)网络有限公司 | Method and device for identifying splicing pattern, computer storage medium and electronic equipment |
CN112001430A (en) * | 2020-08-07 | 2020-11-27 | 海尔优家智能科技(北京)有限公司 | Refrigerator food material detection method and device, storage medium and electronic device |
Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102231093A (en) * | 2011-06-14 | 2011-11-02 | 伍斌 | Screen locating control method and device |
CN102473318A (en) * | 2009-07-30 | 2012-05-23 | 伊斯曼柯达公司 | Processing digital templates for image display |
CN103150557A (en) * | 2013-02-26 | 2013-06-12 | 北京航空航天大学 | Machine vision-based display terminal operation response matching detection device |
CN103902988A (en) * | 2014-04-21 | 2014-07-02 | 梁爽 | Method for rough draft shape matching based on Modular product graph and maximum clique |
CN105956579A (en) * | 2016-05-27 | 2016-09-21 | 国创科视科技股份有限公司 | Rapid finger vein identification method integrating fuzzy template and point characteristics |
CN106952257A (en) * | 2017-03-21 | 2017-07-14 | 南京大学 | A kind of curved surface label open defect detection method based on template matches and Similarity Measure |
Family Cites Families (12)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2008075359A2 (en) * | 2006-12-21 | 2008-06-26 | Yeda Research And Development Co. Ltd. | Method and apparatus for matching local self-similarities |
CN101706873B (en) * | 2009-11-27 | 2012-05-30 | 东软集团股份有限公司 | Identification method and device of digital-class limitation marking |
JP4930607B2 (en) * | 2010-02-04 | 2012-05-16 | カシオ計算機株式会社 | Image processing apparatus and image processing program |
CN102354402B (en) * | 2011-09-21 | 2013-07-10 | 西安交通大学 | Drawing rendering method based on style learning |
CN102663782B (en) * | 2012-03-02 | 2014-11-05 | 西安交通大学 | Painting rendering method based on stroke texture analysis |
CN102810160A (en) * | 2012-06-06 | 2012-12-05 | 北京京东世纪贸易有限公司 | Method and device for searching images |
CN102938077A (en) * | 2012-10-25 | 2013-02-20 | 渭南师范学院 | Online AOI (Automatic Optical Inspection) image retrieval method based on double-threshold binaryzation |
JP5984880B2 (en) * | 2014-06-27 | 2016-09-06 | 京セラドキュメントソリューションズ株式会社 | Image processing device |
CN104574389A (en) * | 2014-12-26 | 2015-04-29 | 康奋威科技(杭州)有限公司 | Battery piece chromatism selection control method based on color machine vision |
CN105426825B (en) * | 2015-11-09 | 2018-10-16 | 国网山东省电力公司烟台供电公司 | A kind of power grid geographical wiring diagram method for drafting based on Aerial Images identification |
CN107092430B (en) * | 2016-02-18 | 2020-03-24 | 纬创资通(中山)有限公司 | Space drawing scoring method, device and system for scoring space drawing |
CN106530317B (en) * | 2016-09-23 | 2019-05-24 | 南京凡豆信息科技有限公司 | A kind of scoring of simple picture computer and auxiliary painting methods |
-
2018
- 2018-04-12 CN CN201810323324.7A patent/CN108615253B/en active Active
Patent Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102473318A (en) * | 2009-07-30 | 2012-05-23 | 伊斯曼柯达公司 | Processing digital templates for image display |
CN102231093A (en) * | 2011-06-14 | 2011-11-02 | 伍斌 | Screen locating control method and device |
CN103150557A (en) * | 2013-02-26 | 2013-06-12 | 北京航空航天大学 | Machine vision-based display terminal operation response matching detection device |
CN103902988A (en) * | 2014-04-21 | 2014-07-02 | 梁爽 | Method for rough draft shape matching based on Modular product graph and maximum clique |
CN105956579A (en) * | 2016-05-27 | 2016-09-21 | 国创科视科技股份有限公司 | Rapid finger vein identification method integrating fuzzy template and point characteristics |
CN106952257A (en) * | 2017-03-21 | 2017-07-14 | 南京大学 | A kind of curved surface label open defect detection method based on template matches and Similarity Measure |
Non-Patent Citations (1)
Title |
---|
基于序贯相似度的AGV图像配准方法;闫小超 等;《科学技术工程》;20100131;第10卷(第3期);第696-699页 * |
Also Published As
Publication number | Publication date |
---|---|
CN108615253A (en) | 2018-10-02 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN108615253B (en) | Image generation method, device and computer readable storage medium | |
CN108898643B (en) | Image generation method, device and computer readable storage medium | |
CN108876871B (en) | Image processing method and device based on circle fitting and computer readable storage medium | |
CN109741281B (en) | Image processing method, image processing device, storage medium and terminal | |
CN110853047A (en) | Intelligent image segmentation and classification method and device and computer readable storage medium | |
CN110969046B (en) | Face recognition method, face recognition device and computer-readable storage medium | |
US20240005468A1 (en) | Image distortion evaluation method and apparatus, and computer device | |
CN110097616B (en) | Combined drawing method and device, terminal equipment and readable storage medium | |
CN110648284B (en) | Image processing method and device with uneven illumination | |
CN108961260B (en) | Image binarization method and device and computer storage medium | |
CN110675334A (en) | Image enhancement method and device | |
CN108986181B (en) | Dot-based image processing method, device and computer readable storage medium | |
CN111626967A (en) | Image enhancement method, image enhancement device, computer device and readable storage medium | |
CN112837251A (en) | Image processing method and device | |
CN111080665A (en) | Image frame identification method, device and equipment and computer storage medium | |
CN108682021B (en) | Rapid hand tracking method, device, terminal and storage medium | |
CN109191539B (en) | Oil painting generation method and device based on image and computer readable storage medium | |
CN108629219B (en) | Method and device for identifying one-dimensional code | |
CN110969678B (en) | Drawing method, device, terminal equipment and storage medium for tiled circles | |
CN108492347A (en) | Image generating method, device and computer readable storage medium | |
CN109993816B (en) | Combined painting method, device, terminal setting and computer readable storage medium | |
CN113963004A (en) | Sampling method and device and electronic equipment | |
CN109325573B (en) | Two-dimensional code generation method, two-dimensional code reading method and two-dimensional code reading device | |
CN112200004A (en) | Training method and device of image detection model and terminal equipment | |
CN111125999A (en) | Character color adjusting method, system, equipment and machine readable medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |