CN108898643B - Image generation method, device and computer readable storage medium - Google Patents

Image generation method, device and computer readable storage medium Download PDF

Info

Publication number
CN108898643B
CN108898643B CN201810619935.6A CN201810619935A CN108898643B CN 108898643 B CN108898643 B CN 108898643B CN 201810619935 A CN201810619935 A CN 201810619935A CN 108898643 B CN108898643 B CN 108898643B
Authority
CN
China
Prior art keywords
image
splitting
module
drawing image
splitting module
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
Application number
CN201810619935.6A
Other languages
Chinese (zh)
Other versions
CN108898643A (en
Inventor
邓立邦
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Guangdong Matview Intelligent Science & Technology Co ltd
Original Assignee
Guangdong Matview Intelligent Science & Technology Co ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Guangdong Matview Intelligent Science & Technology Co ltd filed Critical Guangdong Matview Intelligent Science & Technology Co ltd
Priority to CN201810619935.6A priority Critical patent/CN108898643B/en
Publication of CN108898643A publication Critical patent/CN108898643A/en
Application granted granted Critical
Publication of CN108898643B publication Critical patent/CN108898643B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T11/002D [Two Dimensional] image generation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/30Determination of transform parameters for the alignment of images, i.e. image registration
    • G06T7/32Determination of transform parameters for the alignment of images, i.e. image registration using correlation-based methods
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/10Image acquisition modality
    • G06T2207/10004Still image; Photographic image

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Image Processing (AREA)
  • Image Analysis (AREA)

Abstract

The invention provides an image generation method, an image generation device and a computer readable storage medium, wherein the method comprises the following steps: carrying out module splitting on a history drawing image collected in advance to obtain a plurality of splitting modules; acquiring a current drawing image; performing gray level calculation on the current drawn image by adopting a weighted average algorithm to obtain a gray level image; carrying out binarization processing on the gray level image, and extracting the corresponding contour features of the current drawn image; respectively calculating the similarity of the contour features and a plurality of splitting modules stored in a module image library; when the maximum similarity between the contour features and the splitting modules is larger than a first threshold value, extracting the splitting module corresponding to the maximum similarity as a target splitting module; and combining the current drawing image into the historical drawing image corresponding to the target splitting module to generate a combined image. The image generation method can organically combine and display the drawing image and the historical drawing image, enrich the display effect of the drawing image, and simultaneously effectively reduce the difficulty of electronic drawing.

Description

Image generation method, device and computer readable storage medium
Technical Field
The invention relates to the technical field of image processing, in particular to an image generation method and device 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: a user needs to create a blank drawing board on a touch screen, and can draw only after the drawing type is selected and the painting brush parameters (color, thickness, brush shape and transparency) are set, so that the drawing difficulty is increased; secondly, the drawing device only displays the original drawing drawn by the user correspondingly, different images cannot be displayed according to the stroke of the painter, and new images cannot be organically combined on the basis of the original drawing drawn by the user, the pattern of the original drawing is fixed, and the drawing display is single.
Disclosure of Invention
The invention aims to provide an image generation method, an image generation device and a computer readable storage medium, which can organically combine and display a drawing image and a historical drawing image, enrich the display effect of the drawing image and effectively reduce the difficulty of electronic drawing.
The embodiment of the invention provides an image generation method, which comprises the following steps:
carrying out module splitting on a history drawing image collected in advance to obtain a plurality of splitting modules;
acquiring a current drawing image;
performing gray level calculation on the current drawn image by adopting a weighted average algorithm to obtain a gray level image;
carrying out binarization processing on the gray level image, and extracting the contour features corresponding to the current drawn image;
respectively calculating the similarity of the contour features and the plurality of splitting modules;
when the maximum similarity between the contour features and the splitting modules is larger than a first threshold value, extracting the splitting module corresponding to the maximum similarity as a target splitting module;
and combining the current drawing image into the historical drawing image corresponding to the target splitting module to generate a combined image.
Preferably, the module splitting is performed on the pre-collected historical drawing image to obtain a plurality of split modules, and specifically includes:
inputting a pre-collected historical drawing image into a grid matrix with a set size, and adjusting pixels of the historical drawing image;
carrying out graying processing and binarization processing on the historical drawing image to obtain a binary template image corresponding to the historical drawing image;
and carrying out module splitting on the binary template image according to the position relation and the line length of the contour line in the binary template image to obtain a plurality of splitting modules.
Preferably, the module splitting is performed on the binary template image according to the position relationship and the line length of the contour line in the binary template image to obtain a plurality of split modules, and specifically includes:
searching continuously connected contour lines in the binary template image to obtain a plurality of mutually independent disconnected module line segments;
and when the line length ratio of the module line segment relative to the total contour line of the binary template image is greater than a second threshold value, extracting the module line segment as a splitting module.
Preferably, the calculating the similarity between the contour feature and the plurality of splitting modules respectively specifically includes:
and calculating a cosine value between the pixel point set of the contour characteristic and the pixel point set of any one splitting module by adopting a cosine similarity algorithm, and taking the cosine value as the similarity of the contour characteristic and any one splitting module.
Preferably, the image generation method includes:
using a formula
Figure BDA0001697768170000021
Calculating cosine values between the pixel point sets of the contour features and the pixel point set of any one splitting module;
wherein n represents an n-dimensional space; a. theiA set of pixels of the contour feature is (A ═ A)1,A2,...,An) The ith subset of (1); b isiThe pixel point set B of the splitting module is equal to (B)1,B2,...,Bn) The ith subset of (a).
Preferably, when the maximum similarity between the contour feature and the splitting module is greater than a first threshold, extracting the splitting module corresponding to the maximum similarity as a target splitting module specifically includes:
sorting the splitting modules according to the sequence of similarity from big to small, and judging whether the maximum similarity corresponding to the first sorted splitting module is greater than a first threshold value;
and when the maximum similarity corresponding to the first sorted splitting module is greater than a first threshold value, extracting the first sorted splitting module as a target splitting module.
Preferably, the combining the current drawing image into the historical drawing image corresponding to the target splitting module to generate a combined image specifically includes:
extracting the maximum X coordinate value and the minimum X coordinate value of each pixel point in the target splitting module on an X axis, and the maximum Y coordinate value and the minimum Y coordinate value on a Y axis to construct a size baseline of the target splitting module; the dimension base line takes a minimum X coordinate value and a minimum Y coordinate value as a starting coordinate, and takes a maximum X coordinate value and a maximum Y coordinate value as an end coordinate;
when the size baseline is positioned outside the current drawing image, enlarging the current drawing image to enable the starting point and the end point of the size baseline to be positioned on the enlarged current drawing image;
when the size base line is positioned in the current drawing image, reducing the current drawing image, so that the starting point and the end point of the size base line are positioned on the reduced current drawing image;
and extracting the historical drawing image corresponding to the target splitting module, replacing the target splitting module in the historical drawing image corresponding to the target splitting module with the zoomed current drawing image, and generating a combined image.
An embodiment of the present invention further provides an image generating apparatus, including:
the image splitting module is used for carrying out module splitting on a pre-collected historical drawing image to obtain a plurality of splitting modules;
the image acquisition module is used for acquiring a current drawing image;
the gray processing module is used for carrying out gray calculation on the current drawn image by adopting a weighted average algorithm to obtain a gray image;
the binarization processing module is used for carrying out binarization processing on the gray level image and extracting the contour characteristics corresponding to the current drawn image;
the similarity calculation module is used for calculating the similarity of the contour features and the plurality of splitting modules respectively;
the splitting module determining module is used for extracting the splitting module corresponding to the maximum similarity as a target splitting module when the maximum similarity between the contour features and the splitting module is greater than a first threshold;
and the image combination module is used for combining the current drawing image into the historical drawing image corresponding to the target splitting module to generate a combined 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.
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: an image generation method, comprising: carrying out module splitting on a history drawing image collected in advance to obtain a plurality of splitting modules and storing the splitting modules in a module image library; collecting a drawing image drawn on a screen of a terminal device; performing gray level calculation on the current drawn image by adopting a weighted average algorithm to obtain a gray level image; carrying out binarization processing on the gray level image, and extracting the contour features corresponding to the current drawn image; respectively calculating the similarity of the contour features and a plurality of split modules stored in the module image library; when the maximum similarity between the contour features and the splitting modules is larger than a first threshold value, extracting the splitting module corresponding to the maximum similarity as a target splitting module; and combining the current drawing image into the historical drawing image corresponding to the target splitting module to generate a combined image. The image generation method can organically combine and display the drawing image and the historical drawing image, enrich the display effect of the drawing image, and simultaneously effectively reduce the difficulty of electronic drawing.
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: carrying out module splitting on a history drawing image collected in advance to obtain a plurality of splitting modules;
s200: acquiring a current drawing image;
s300: performing gray level calculation on the current drawn image by adopting a weighted average algorithm to obtain a gray level image;
s400: carrying out binarization processing on the gray level image, and extracting the contour features corresponding to the current drawn image;
s500: respectively calculating the similarity of the contour features and the plurality of splitting modules;
s600: when the maximum similarity between the contour features and the splitting modules is larger than a first threshold value, extracting the splitting module corresponding to the maximum similarity as a target splitting module;
s700: and combining the current drawing image into the historical drawing image corresponding to the target splitting module to generate a combined image.
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 by a user on a screen and sends the drawing image to the processor of the terminal equipment for graying processing, binarization processing and similarity matching processing with a plurality of splitting modules, and finally, a historical drawing image corresponding to the splitting module with the highest similarity is combined with the current drawing image to generate a combined image and push the combined image to the screen of the terminal equipment. 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 current drawn 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 current 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, S400: performing binarization processing on the gray level image, and extracting the contour features corresponding to the current drawn 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 or not, 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 corresponding profile characteristic of the current drawn 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 gray-white profile characteristics, so that the drawn image can be simplified, the data volume of the drawn image is reduced, the profile of the drawn image is highlighted, and the accuracy of similarity matching with the historical drawn image is improved.
In other embodiments, the first set gray value of the pixel point of the profile feature is updated to 0, the second set gray value of the pixel point of the profile feature is updated to 1, and the updated profile feature 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 contour feature into 0 or 1 and representing the contour feature by adopting 1 as a code.
In an alternative embodiment, S100: the method includes the following steps that module splitting is conducted on a history drawing image collected in advance, a plurality of splitting modules are obtained, and the method specifically comprises the following steps:
inputting a pre-collected historical drawing image into a grid matrix with a set size, and adjusting pixels of the historical drawing image;
carrying out graying processing and binarization processing on the historical drawing image to obtain a binary template image corresponding to the historical drawing image;
and carrying out module splitting on the binary template image according to the position relation and the line length of the contour line in the binary template image to obtain a plurality of splitting modules.
In the present embodiment, a history drawing image acquired in advance is input to a checkered matrix of a set size or can, thereby scaling the history drawing image to the same size, such as: 500 x 500 pixels, representing that the historical rendered image is comprised of 250000 pixels. Then, the same graying processing and binarization processing as the currently drawn image are adopted, and the description is not repeated again.
In an optional embodiment, the module splitting is performed on the binary template image according to the position relationship and the line length of the contour line in the binary template image, so as to obtain a plurality of split modules, specifically including:
searching continuously connected contour lines in the binary template image to obtain a plurality of mutually independent disconnected module line segments;
and when the line length ratio of the module line segment relative to the total contour line of the binary template image is greater than a second threshold value, extracting the module line segment as a splitting module.
Specifically, the second threshold is 10%.
The following describes the module splitting process of the history drawing image in detail: in a grid matrix corresponding to the historical drawing image, pixel points marked as 1 are displayed in white and represent objects; the pixel point identified as 0, displayed in black, represents the background. According to the matrix, the pixel points marked with 1 are distributed with two conditions: one is that a plurality of adjacent pixel points are gathered in one or more continuous areas at the same time; the other is independent scattered display of one point, namely the pixel points are not adjacent.
The rule of module splitting is to satisfy the following 2 conditions simultaneously: 1. the splitting module is a part of a continuous line that is independently broken. 2. The line length of the splitting module is required to be 10% or more of the total line length, wherein the total line length refers to the total number of pixels marked as 1 in the history drawing image; the line length of the splitting module refers to the total number of pixels identified by the splitting module as 1.
And according to the rule, carrying out module splitting on the historical drawing image, and storing a splitting module on a server of the terminal equipment.
For example: a history drawing image is composed of 4 separate broken parts of left eye, right eye, mouth, and body, assuming that the left eye line length is 13% of the total length, the right eye line length is 17% of the total length, the mouth line length is 15% of the total length, and the body line length is 55% of the total length. Then, according to the above rule, the module splitting is performed on the history drawing image, and the history drawing image is split into: left eye, right eye, mouth, body.
In an alternative embodiment, S500: respectively calculating the similarity of the profile features and the plurality of splitting modules, specifically comprising:
and calculating a cosine value between the pixel point set of the contour characteristic and the pixel point set of any one splitting module by adopting a cosine similarity algorithm, and taking the cosine value as the similarity of the contour characteristic and any one splitting module.
In an alternative embodiment, the image generation method includes:
using a formula
Figure BDA0001697768170000081
Calculating cosine values between the pixel point sets of the contour features and the pixel point set of any one splitting module;
wherein n represents an n-dimensional space; a. theiA set of pixels of the contour feature is (A ═ A)1,A2,...,An) The ith subset of (1); b isiThe pixel point set B of the splitting module is equal to (B)1,B2,...,Bn) The ith subset of (a).
In an optional embodiment, when the maximum similarity between the contour feature and the splitting module is greater than a first threshold, extracting the splitting module corresponding to the maximum similarity as a target splitting module specifically includes:
sorting the splitting modules according to the sequence of similarity from big to small, and judging whether the maximum similarity corresponding to the first sorted splitting module is greater than a first threshold value;
and when the maximum similarity corresponding to the first sorted splitting module is greater than a first threshold value, extracting the first sorted splitting module as a target splitting module.
Specifically, the first threshold value is 0.9.
Through the formula, the sizes of the cosine values of the drawn image and the plurality of splitting modules are calculated and are arranged according to the sequence of values from large to small, the value is closer to 1, the more front the value is, and the similarity is higher. Finally, judging whether the cosine value of the first sorted splitting module is more than or equal to 0.9, if so, taking the splitting module as a target splitting module; if not, the similarity comparison fails, a splitting module similar to the drawn image is not searched, and the terminal equipment displays the current drawn image.
In an alternative embodiment, S700: combining the current drawing image into the historical drawing image corresponding to the target splitting module to generate a combined image, specifically comprising:
extracting the maximum X coordinate value and the minimum X coordinate value of each pixel point in the target splitting module on an X axis, and the maximum Y coordinate value and the minimum Y coordinate value on a Y axis to construct a size baseline of the target splitting module; the dimension base line takes a minimum X coordinate value and a minimum Y coordinate value as a starting coordinate, and takes a maximum X coordinate value and a maximum Y coordinate value as an end coordinate;
when the size baseline is positioned outside the current drawing image, enlarging the current drawing image to enable the starting point and the end point of the size baseline to be positioned on the enlarged current drawing image;
when the size base line is positioned in the current drawing image, reducing the current drawing image, so that the starting point and the end point of the size base line are positioned on the reduced current drawing image;
and extracting the historical drawing image corresponding to the target splitting module, replacing the target splitting module in the historical drawing image corresponding to the target splitting module with the zoomed current drawing image, and generating a combined 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 splitting module 1 is used for carrying out module splitting on a history drawing image collected in advance to obtain a plurality of splitting modules;
the image acquisition module 2 is used for acquiring a current drawing image;
the gray processing module 3 is used for carrying out gray calculation on the current drawn image by adopting a weighted average algorithm to obtain a gray image;
a binarization processing module 4, configured to perform binarization processing on the grayscale image, and extract a contour feature corresponding to the currently drawn image;
a similarity calculation module 5, configured to calculate similarities between the contour features and the plurality of splitting modules, respectively;
the splitting module determining module 6 is configured to, when the maximum similarity between the contour feature and the splitting module is greater than a first threshold, extract the splitting module corresponding to the maximum similarity as a target splitting module;
and the image combination module 7 is configured to combine the current drawing image into the historical drawing image corresponding to the target splitting module, so as to generate a combined image.
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 by a user on a screen and sends the drawing image to the processor of the terminal equipment for graying processing, binarization processing and similarity matching processing with a plurality of splitting modules, and finally, a historical drawing image corresponding to the splitting module with the highest similarity is combined with the current drawing image to generate a combined image and push the combined image to the screen of the terminal equipment. 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 current drawn 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 current 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, the binarization processing module 4 is specifically configured to determine whether a gray value of any one pixel of the gray image is greater than a first threshold, if so, update the gray value of the any one pixel to a first set gray value, and if not, update the gray value of the any one pixel to a second set gray value, so as to obtain a contour feature corresponding to the currently drawn 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 gray-white profile characteristics, so that the drawn image can be simplified, the data volume of the drawn image is reduced, the profile of the drawn image is highlighted, and the accuracy of similarity matching with the historical drawn image is improved.
In other embodiments, the first set gray value of the pixel point of the profile feature is updated to 0, the second set gray value of the pixel point of the profile feature is updated to 1, and the updated profile feature 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 contour feature into 0 or 1 and representing the contour feature by adopting 1 as a code.
In an alternative embodiment, the image splitting module 1 comprises:
the pixel adjusting unit is used for inputting a pre-collected historical drawing image into a grid matrix with a set size and adjusting pixels of the historical drawing image;
the image processing unit is used for carrying out graying processing and binarization processing on the historical drawing image to obtain a binary template image corresponding to the historical drawing image;
and the splitting unit is used for carrying out module splitting on the binary template image according to the position relation and the line length of the contour line in the binary template image to obtain a plurality of splitting modules.
In the present embodiment, a history drawing image acquired in advance is input to a checkered matrix of a set size or can, thereby scaling the history drawing image to the same size, such as: 500 x 500 pixels, representing that the historical rendered image is comprised of 250000 pixels. Then, the same graying processing and binarization processing as the currently drawn image are adopted, and the description is not repeated again.
In an alternative embodiment, the splitting unit comprises:
the line searching unit is used for searching the continuously connected contour lines in the binary template image to obtain a plurality of mutually independent disconnected module line segments;
and the line segment extraction unit is used for extracting the module line segment as a splitting module when the line length ratio of the module line segment to the total contour line of the binary template image is greater than a second threshold.
Specifically, the second threshold is 10%.
The following describes the module splitting process of the history drawing image in detail: in a grid matrix corresponding to the historical drawing image, pixel points marked as 1 are displayed in white and represent objects; the pixel point identified as 0, displayed in black, represents the background. According to the matrix, the pixel points marked with 1 are distributed with two conditions: one is that a plurality of adjacent pixel points are gathered in one or more continuous areas at the same time; the other is independent scattered display of one point, namely the pixel points are not adjacent.
The rule of module splitting is to satisfy the following 2 conditions simultaneously: 1. the splitting module is a part of a continuous line that is independently broken. 2. The line length of the splitting module is required to be 10% or more of the total line length, wherein the total line length refers to the total number of pixels marked as 1 in the history drawing image; the line length of the splitting module refers to the total number of pixels identified by the splitting module as 1.
And according to the rule, carrying out module splitting on the historical drawing image, and storing a splitting module on a server of the terminal equipment.
For example: a history drawing image is composed of 4 separate broken parts of left eye, right eye, mouth, and body, assuming that the left eye line length is 13% of the total length, the right eye line length is 17% of the total length, the mouth line length is 15% of the total length, and the body line length is 55% of the total length. Then, according to the above rule, the module splitting is performed on the history drawing image, and the history drawing image is split into: left eye, right eye, mouth, body.
In an optional embodiment, the similarity calculation module 5 is specifically configured to calculate, by using a cosine similarity algorithm, a cosine value between a pixel point set of the contour feature and a pixel point set of any one of the splitting modules, as the similarity between the contour feature and any one of the splitting modules.
In an alternative embodiment, the similarity calculation module 5 is specifically adapted to use a formula
Figure BDA0001697768170000121
Calculating cosine values between the pixel point sets of the contour features and the pixel point set of any one splitting module;
wherein n represents an n-dimensional space; a. theiA set of pixels of the contour feature is (A ═ A)1,A2,...,An) The ith subset of (1); b isiThe pixel point set B of the splitting module is equal to (B)1,B2,...,Bn) The ith subset of (a).
In an optional embodiment, when the maximum similarity between the contour feature and the splitting module is greater than a first threshold, extracting the splitting module corresponding to the maximum similarity as a target splitting module specifically includes:
sorting the splitting modules according to the sequence of similarity from big to small, and judging whether the maximum similarity corresponding to the first sorted splitting module is greater than a first threshold value;
and when the maximum similarity corresponding to the first sorted splitting module is greater than a first threshold value, extracting the first sorted splitting module as a target splitting module.
Specifically, the first threshold value is 0.9.
Through the formula, the sizes of the cosine values of the drawn image and the plurality of splitting modules are calculated and are arranged according to the sequence of values from large to small, the value is closer to 1, the more front the value is, and the similarity is higher. Finally, judging whether the cosine value of the first sorted splitting module is more than or equal to 0.9, if so, taking the splitting module as a target splitting module; if not, the similarity comparison fails, a splitting module similar to the drawn image is not searched, and the terminal equipment displays the current drawn image.
In an alternative embodiment, the image combining module 7 comprises:
a coordinate extraction unit, configured to extract a maximum X coordinate value and a minimum X coordinate value of each pixel point in the target splitting module on an X axis, and a maximum Y coordinate value and a minimum Y coordinate value on a Y axis, and construct a size baseline of the target splitting module; the dimension base line takes a minimum X coordinate value and a minimum Y coordinate value as a starting coordinate, and takes a maximum X coordinate value and a maximum Y coordinate value as an end coordinate;
an image scaling unit, configured to, when the size baseline is located outside the currently drawn image, enlarge the currently drawn image such that a start point and an end point of the size baseline are both located on the enlarged currently drawn image;
the image scaling unit is used for reducing the current drawing image when the size base line is positioned in the current drawing image, so that a starting point and an end point of the size base line are positioned on the reduced current drawing image;
and the image replacing unit is used for extracting the historical drawing image corresponding to the target splitting module, replacing the target splitting module in the historical drawing image corresponding to the target splitting module with the zoomed current drawing image, and generating a combined 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 functional modules of the image generation apparatus as shown in fig. 2.
The image generating device may be a desktop computer, a notebook, a palm computer, a cloud server, or other computing devices. The image generation device may include, but is not limited to, a processor, a memory. It will be understood 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 of 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-output device, a network access device, a bus, and the like.
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, usb disk, removable hard disk, magnetic disk, optical disk, computer Memory, Read-Only Memory (ROM), Random Access Memory (RAM), electrical carrier wave signals, telecommunications signals, software distribution medium, and the like. It should be noted that the computer readable medium may contain content that is subject to appropriate increase or decrease as required by legislation and patent practice in jurisdictions, for example, in some jurisdictions, computer readable media does not include electrical carrier signals and telecommunications signals as is required by 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 between them, 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: an image generation method, comprising: carrying out module splitting on a history drawing image collected in advance to obtain a plurality of splitting modules; acquiring a current drawing image; performing gray level calculation on the current drawn image by adopting a weighted average algorithm to obtain a gray level image; carrying out binarization processing on the gray level image, and extracting the contour features corresponding to the current drawn image; respectively calculating the similarity of the contour features and a plurality of split modules stored in the module image library; when the maximum similarity between the contour features and the splitting modules is larger than a first threshold value, extracting the splitting module corresponding to the maximum similarity as a target splitting module; and combining the current drawing image into the historical drawing image corresponding to the target splitting module to generate a combined image. The image generation method can organically combine and display the drawing image and the historical drawing image, enrich the display effect of the drawing image, and simultaneously effectively reduce the difficulty of electronic drawing.
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 (9)

1. An image generation method, comprising:
carrying out module splitting on a history drawing image collected in advance to obtain a plurality of splitting modules;
acquiring a current drawing image;
performing gray level calculation on the current drawn image by adopting a weighted average algorithm to obtain a gray level image;
carrying out binarization processing on the gray level image, and extracting the contour features corresponding to the current drawn image;
respectively calculating the similarity of the contour features and the plurality of splitting modules;
when the maximum similarity between the contour features and the splitting modules is larger than a first threshold value, extracting the splitting module corresponding to the maximum similarity as a target splitting module;
combining the current drawing image into a historical drawing image corresponding to the target splitting module to generate a combined image;
the module splitting is performed on the pre-collected historical drawing image to obtain a plurality of split modules, and the method specifically comprises the following steps:
inputting a pre-collected historical drawing image into a grid matrix with a set size, and adjusting pixels of the historical drawing image;
carrying out graying processing and binarization processing on the historical drawing image to obtain a binary template image corresponding to the historical drawing image;
and carrying out module splitting on the binary template image according to the position relation and the line length of the contour line in the binary template image to obtain a plurality of splitting modules.
2. The image generation method according to claim 1, wherein the module splitting is performed on the binary template image according to a position relationship and a line length of a contour line in the binary template image, so as to obtain a plurality of split modules, specifically including:
searching continuously connected contour lines in the binary template image to obtain a plurality of mutually independent disconnected module line segments;
and when the line length ratio of the module line segment relative to the total contour line of the binary template image is greater than a second threshold value, extracting the module line segment as a splitting module.
3. The image generation method according to claim 1, wherein the calculating the similarity between the contour feature and the plurality of splitting modules respectively specifically includes:
and calculating a cosine value between the pixel point set of the contour characteristic and the pixel point set of any one splitting module by adopting a cosine similarity algorithm, and taking the cosine value as the similarity of the contour characteristic and any one splitting module.
4. The image generation method according to claim 3, characterized by comprising:
using a formula
Figure FDA0003484526890000021
Calculating cosine values between the pixel point sets of the contour features and the pixel point set of any one splitting module;
wherein n represents an n-dimensional space; a. theiA set of pixels of the contour feature is (A ═ A)1,A2,...,An) The ith subset of (1); b isiIs the splitting moduleSet of pixel points B ═ B1,B2,...,Bn) The ith subset of (a).
5. The image generation method according to claim 1, wherein when the maximum similarity between the contour feature and the splitting module is greater than a first threshold, extracting the splitting module corresponding to the maximum similarity as a target splitting module specifically includes:
sorting the splitting modules according to the sequence of similarity from big to small, and judging whether the maximum similarity corresponding to the first sorted splitting module is greater than a first threshold value;
and when the maximum similarity corresponding to the first sorted splitting module is greater than a first threshold value, extracting the first sorted splitting module as a target splitting module.
6. The image generation method according to claim 1, wherein the combining the current drawing image into the historical drawing image corresponding to the target splitting module to generate a combined image specifically includes:
extracting the maximum X coordinate value and the minimum X coordinate value of each pixel point in the target splitting module on an X axis, and the maximum Y coordinate value and the minimum Y coordinate value on a Y axis to construct a size baseline of the target splitting module; the dimension base line takes a minimum X coordinate value and a minimum Y coordinate value as a starting coordinate, and takes a maximum X coordinate value and a maximum Y coordinate value as an end coordinate;
when the size baseline is positioned outside the current drawing image, enlarging the current drawing image to enable the starting point and the end point of the size baseline to be positioned on the enlarged current drawing image;
when the size base line is positioned in the current drawing image, reducing the current drawing image, so that the starting point and the end point of the size base line are positioned on the reduced current drawing image;
and extracting the historical drawing image corresponding to the target splitting module, replacing the target splitting module in the historical drawing image corresponding to the target splitting module with the zoomed current drawing image, and generating a combined image.
7. An image generation apparatus, comprising:
the image splitting module is used for carrying out module splitting on a pre-collected historical drawing image to obtain a plurality of splitting modules;
the image acquisition module is used for acquiring a current drawing image;
the gray processing module is used for carrying out gray calculation on the current drawn image by adopting a weighted average algorithm to obtain a gray image;
the binarization processing module is used for carrying out binarization processing on the gray level image and extracting the contour characteristics corresponding to the current drawn image;
the similarity calculation module is used for calculating the similarity of the contour features and the plurality of splitting modules respectively;
the splitting module determining module is used for extracting the splitting module corresponding to the maximum similarity as a target splitting module when the maximum similarity between the contour features and the splitting module is greater than a first threshold;
the image combination module is used for combining the current drawing image into the historical drawing image corresponding to the target splitting module to generate a combined image;
the image splitting module comprises:
the pixel adjusting unit is used for inputting a pre-collected historical drawing image into a grid matrix with a set size and adjusting pixels of the historical drawing image;
the image processing unit is used for carrying out graying processing and binarization processing on the historical drawing image to obtain a binary template image corresponding to the historical drawing image;
and the splitting unit is used for carrying out module splitting on the binary template image according to the position relation and the line length of the contour line in the binary template image to obtain a plurality of splitting modules.
8. 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 6 when executing the computer program.
9. 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 6.
CN201810619935.6A 2018-06-15 2018-06-15 Image generation method, device and computer readable storage medium Active CN108898643B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810619935.6A CN108898643B (en) 2018-06-15 2018-06-15 Image generation method, device and computer readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810619935.6A CN108898643B (en) 2018-06-15 2018-06-15 Image generation method, device and computer readable storage medium

Publications (2)

Publication Number Publication Date
CN108898643A CN108898643A (en) 2018-11-27
CN108898643B true CN108898643B (en) 2022-03-11

Family

ID=64344859

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810619935.6A Active CN108898643B (en) 2018-06-15 2018-06-15 Image generation method, device and computer readable storage medium

Country Status (1)

Country Link
CN (1) CN108898643B (en)

Families Citing this family (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109886781B (en) * 2019-01-31 2023-05-09 广东智媒云图科技股份有限公司 Product recommendation method, device, equipment and storage medium based on painting behaviors
CN109725792B (en) * 2019-02-25 2020-10-16 广东智媒云图科技股份有限公司 Question-answer interaction-based drawing method
CN109993811B (en) * 2019-03-19 2023-01-13 广东智媒云图科技股份有限公司 Work creation method and device based on texture material
CN109993814B (en) * 2019-03-19 2023-06-27 广东智媒云图科技股份有限公司 Interactive drawing method and device based on silhouette, terminal equipment and storage medium
CN109993816B (en) * 2019-03-21 2023-08-04 广东智媒云图科技股份有限公司 Combined painting method, device, terminal setting and computer readable storage medium
CN110175257B (en) * 2019-04-15 2023-06-16 广东智媒云图科技股份有限公司 Method for matching line manuscript images, electronic equipment and storage medium
CN110569907B (en) * 2019-09-10 2022-03-04 网易(杭州)网络有限公司 Method and device for identifying splicing pattern, computer storage medium and electronic equipment
CN111162897A (en) * 2019-12-25 2020-05-15 杭州安司源科技有限公司 Mobile terminal true random number rapid generation method based on camera
CN111522988B (en) * 2020-05-29 2022-07-15 深圳市商汤科技有限公司 Image positioning model obtaining method and related device
CN113034523A (en) * 2021-04-23 2021-06-25 腾讯科技(深圳)有限公司 Image processing method, image processing device, storage medium and computer equipment
CN113723417B (en) * 2021-08-31 2024-04-12 深圳平安智慧医健科技有限公司 Single view-based image matching method, device, equipment and storage medium
CN115471507B (en) * 2022-10-26 2023-09-15 华东师范大学 Deep learning-based bright field multicolor immunohistochemical image dyeing and splitting method

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101571717A (en) * 2008-05-02 2009-11-04 通用电气公司 Method and system for machining process control
CN102810160A (en) * 2012-06-06 2012-12-05 北京京东世纪贸易有限公司 Method and device for searching images
CN104407384A (en) * 2014-12-08 2015-03-11 中国石油天然气集团公司 Seismic section display method
CN106095366A (en) * 2016-06-07 2016-11-09 北京小鸟看看科技有限公司 A kind of shorten the method for picture delay, device and virtual reality device
CN106201275A (en) * 2016-07-29 2016-12-07 北京小米移动软件有限公司 Snapshot is as processing method and processing device
CN106294458A (en) * 2015-05-29 2017-01-04 北京四维图新科技股份有限公司 A kind of map point of interest update method and device
JP2017174030A (en) * 2016-03-23 2017-09-28 富士ゼロックス株式会社 Image processing apparatus and image processing program
CN107393000A (en) * 2017-08-24 2017-11-24 广东欧珀移动通信有限公司 Image processing method, device, server and computer-readable recording medium

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101571717A (en) * 2008-05-02 2009-11-04 通用电气公司 Method and system for machining process control
CN102810160A (en) * 2012-06-06 2012-12-05 北京京东世纪贸易有限公司 Method and device for searching images
CN104407384A (en) * 2014-12-08 2015-03-11 中国石油天然气集团公司 Seismic section display method
CN106294458A (en) * 2015-05-29 2017-01-04 北京四维图新科技股份有限公司 A kind of map point of interest update method and device
JP2017174030A (en) * 2016-03-23 2017-09-28 富士ゼロックス株式会社 Image processing apparatus and image processing program
CN106095366A (en) * 2016-06-07 2016-11-09 北京小鸟看看科技有限公司 A kind of shorten the method for picture delay, device and virtual reality device
CN106201275A (en) * 2016-07-29 2016-12-07 北京小米移动软件有限公司 Snapshot is as processing method and processing device
CN107393000A (en) * 2017-08-24 2017-11-24 广东欧珀移动通信有限公司 Image processing method, device, server and computer-readable recording medium

Also Published As

Publication number Publication date
CN108898643A (en) 2018-11-27

Similar Documents

Publication Publication Date Title
CN108898643B (en) Image generation method, device and computer readable storage medium
CN108615253B (en) Image generation method, device and computer readable storage medium
CN109376596B (en) Face matching method, device, equipment and storage medium
CN108876871B (en) Image processing method and device based on circle fitting and computer readable storage medium
CN111340109B (en) Image matching method, device, equipment and storage medium
CN110119733B (en) Page identification method and device, terminal equipment and computer readable storage medium
CN110097616B (en) Combined drawing method and device, terminal equipment and readable storage medium
CN110969046B (en) Face recognition method, face recognition device and computer-readable storage medium
CN111383232A (en) Matting method, matting device, terminal equipment and computer-readable storage medium
US20210248729A1 (en) Superpixel merging
CN112328345A (en) Method and device for determining theme color, electronic equipment and readable storage medium
CN112651953A (en) Image similarity calculation method and device, computer equipment and storage medium
CN108986181B (en) Dot-based image processing method, device and computer readable storage medium
CN114548218A (en) Image matching method, device, storage medium and electronic device
CN113077469B (en) Sketch image semantic segmentation method and device, terminal device and storage medium
CN112288045B (en) Seal authenticity distinguishing method
CN112200004B (en) Training method and device for image detection model and terminal equipment
CN109191539B (en) Oil painting generation method and device based on image and computer readable storage medium
CN108492347B (en) Image generation method, device and computer readable storage medium
CN111931794B (en) Sketch-based image matching method
CN115601752A (en) Character recognition method, character recognition device, electronic equipment and medium
CN109993816B (en) Combined painting method, device, terminal setting and computer readable storage medium
CN108509487B (en) Image retrieval method, device and storage medium based on pulse-issued cortex model
CN112348069A (en) Data enhancement method and device, computer readable storage medium and terminal equipment
CN110647796A (en) Iris identification method and device

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