CN105654531A - Method and device for drawing image contour - Google Patents

Method and device for drawing image contour Download PDF

Info

Publication number
CN105654531A
CN105654531A CN201511021247.2A CN201511021247A CN105654531A CN 105654531 A CN105654531 A CN 105654531A CN 201511021247 A CN201511021247 A CN 201511021247A CN 105654531 A CN105654531 A CN 105654531A
Authority
CN
China
Prior art keywords
pixel
image
profile
outline
starting point
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.)
Granted
Application number
CN201511021247.2A
Other languages
Chinese (zh)
Other versions
CN105654531B (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.)
Beijing Jupiter Technology Co ltd
Original Assignee
Beijing Kingsoft Internet Security Software 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 Beijing Kingsoft Internet Security Software Co Ltd filed Critical Beijing Kingsoft Internet Security Software Co Ltd
Priority to CN201511021247.2A priority Critical patent/CN105654531B/en
Publication of CN105654531A publication Critical patent/CN105654531A/en
Application granted granted Critical
Publication of CN105654531B publication Critical patent/CN105654531B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T11/002D [Two Dimensional] image generation
    • G06T11/20Drawing from basic elements, e.g. lines or circles
    • G06T11/203Drawing of straight lines or curves

Landscapes

  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Image Analysis (AREA)

Abstract

The embodiment of the invention provides a method and a device for drawing an image contour. The specific implementation mode of the method comprises the following steps: when an image contour drawing instruction is detected, determining coordinates of pixel points in the image contour by adopting an edge detection algorithm; determining a starting point of contour drawing and a drawing direction corresponding to the starting point according to coordinates of pixel points in the image contour, a position input by a current user and a direction of drawing operation of the current user, and determining a set number of pixel points in the drawing direction; and when the last pixel point in the set number of pixel points is the termination point of the image contour, determining the target image contour according to the pixel points in the stored target image contour and the pixel points between the starting point and the termination point, otherwise, taking the set number of pixel points as the pixel points in the target image contour, storing the pixel points, and taking the last pixel point as the starting point to execute the determination process of the drawing direction. By applying the embodiment, the outline of the image can be drawn more accurately.

Description

A kind of method for drafting of image outline and device
Technical field
The present invention relates to technical field of image processing, particularly a kind of method for drafting of image outline and dressPut.
Background technology
Image cropping is a basic function of graph and image processing application program (App), in the marketA lot of products can both be accomplished this point. For example, user wants certain the auto heterodyne head portrait on photo current to cutSanction is got off, just need first by target image this auto heterodyne head portrait determine, and then application cutting implement entersRow is cut out. In prior art, general using shape masking-out is determined target image, and then cuts out shapeMasking-out comprises circle, ellipse, the various shape such as star-like. The figure that utilizes this mode of shape masking-out to cut out outPicture is the shape of shape masking-out. But in actual applications, the profile great majority of target image are irregular,When target image may be the connected multiple irregular images of personage's head portrait, intersection etc., for example several personages'Group photo image, one has the tree of a large amount of leaves etc. so when irregular image, adopts the shape masking-out cannotDetermine exactly target image, poor user experience.
In prior art, can also utilize the free Freehandhand-drawing draw target image of graph and image processing AppProfile, utilize the profile of mouse render target image, or utilize finger at mobile phone or panel computer screenOn draw, recycling cutting implement cut out. In this mode, although user can draw arbitrarilyImage outline, but the target image profile that free Freehandhand-drawing is drawn is accurate not, can only be roughly currentThe shape that image cropping becomes user to want, user experiences poor.
Summary of the invention
The object of the embodiment of the present invention has been to provide a kind of method for drafting and device of image outline, Neng GougengDrawing image profile exactly.
In order to achieve the above object, the invention discloses a kind of method for drafting of image outline, be applied to and haveThe electronic equipment of display screen, described method comprises:
A. in the time detecting that image outline is drawn instruction, in the picture for the treatment of draw outline, adopt edge inspectionMethod of determining and calculating is determined the coordinate of pixel in image outline;
B. according to the position of the coordinate of pixel in described image outline and active user's input, take turns at imageIn exterior feature, determine the starting point that profile is drawn;
C. draw the direction of operation according to active user, determine in image outline corresponding to this starting point and carry outThe drafting direction of drawing, and in image outline, determine and set a quantity pixel according to described drafting direction;
D. whether judge last pixel corresponding to this drafting direction in a described setting quantity pixelFor the terminating point of described image outline, if so, according to the pixel in the target image profile of preserving,And the pixel in the image outline between starting point and ending point in described image outline, determine target imageProfile, otherwise the pixel using a described setting quantity pixel in target image profile is also preserved,Described last pixel is performed step to C as starting point.
Preferably, described according to the position of the coordinate of pixel in described image outline and active user's input,In image outline, determine that the starting point that profile is drawn comprises:
According to the position of active user's input, obtain the coordinate of described position;
According to the coordinate of pixel in the coordinate of described position and described image outline, determine described position and instituteState the distance between each pixel in image outline;
By the pixel in image outline corresponding minimum range, be defined as the starting point that profile is drawn.
Preferably, described by the pixel in image outline corresponding minimum range, be defined as profile drawStarting point comprises:
Judge whether described minimum range is less than default the first distance threshold, if so, by minimum range correspondenceImage outline in pixel, be defined as profile draw starting point.
Preferably, described method also comprises:
In the time that described minimum range is not less than default the first distance threshold, output information.
Preferably, described direction of drawing operation according to active user, determines the image wheel that this starting point is correspondingThe drafting direction of drawing in exterior feature, comprising:
Draw the direction of operation according to active user, determine that active user draws the angle corresponding to direction of operationDegree;
According to each angular range corresponding to each drafting direction of preserving for this starting point, determine this angleThe angular range at place is image wheel corresponding to this starting point by drafting orientation determination corresponding this angular rangeThe drafting direction of drawing in exterior feature.
Preferably, last picture corresponding to this drafting direction in the described setting quantity pixel of described judgementWhether vegetarian refreshments is the terminating point of described image outline, comprising:
Determine the coordinate of last pixel corresponding to this drafting direction in a described setting quantity pixel;
Between the coordinate of the starting point that the coordinate of described last pixel of judgement and described profile are drawnWhether distance is less than default second distance threshold value;
If so, determine that described last pixel is terminating point, otherwise, determine described last pictureVegetarian refreshments nonterminal point.
Preferably, described according to the position of the coordinate of pixel in described image outline and active user's input,Determine the starting point of profile drafting in image outline before, described method also comprises:
According to the coordinate of pixel in definite image outline, generate with the picture for the treatment of draw outline contour wideThe black and white picture of binaryzation, described in comprising in the black and white picture of described binaryzation, treat the picture of draw outlineImage outline.
Preferably, described using a described setting quantity pixel pixel in target image profile and protectDeposit, comprising:
Judge in target image profile whether preserve a described setting quantity pixel, if not, by instituteState and set a quantity pixel as the pixel in target image profile and preserve.
Preferably, described method also comprises:
If preserved a described setting quantity pixel in target image profile, delete preserve described inSet a quantity pixel.
Preferably, described edge detection algorithm comprises triumphant Buddhist nun Canny edge detection algorithm.
In order to achieve the above object, the invention also discloses a kind of drawing apparatus of image outline, be applied to toolHave the electronic equipment of display screen, described device comprises:
Image outline detection module, for when detecting that image outline draws when instruction, is treating draw outlineIn picture, adopt edge detection algorithm to determine the coordinate of pixel in image outline;
Starting point determination module, for inputting according to the coordinate of described image outline pixel and active userPosition, in image outline determine profile draw starting point;
Draw orientation determination module, for draw the direction of operation according to active user, determine this starting point pairThe drafting direction of drawing in the image outline of answering, and determine in image outline according to described drafting directionSet a quantity pixel;
Terminating point judge module is corresponding for judging described this drafting direction of a setting quantity pixelWhether a rear pixel is the terminating point of described image outline;
Target image profile determination module, if for described this drafting direction pair of a setting quantity pixelLast pixel of answering is the terminating point of described image outline, according in the target image profile of preservingPixel, and the pixel in the image outline between starting point and ending point in described image outline, reallyImage outline sets the goal;
Pixel is preserved module, if corresponding for described this drafting direction of a setting quantity pixelA rear terminating point that pixel is not described image outline, using a described setting quantity pixel as orderPixel in mark image outline is also preserved, and using described last pixel as starting point, triggering is paintedOrientation determination module processed.
Preferably, described starting point determination module comprises:
Coordinate obtains submodule, for according to the position of active user's input, obtains the coordinate of described position;
Distance is determined submodule, for according to the seat of the coordinate of described position and described image outline pixelMark, determines the distance between each pixel in described position and described image outline;
Starting point is determined submodule, for by the pixel of image outline corresponding minimum range, is defined asThe starting point that profile is drawn.
Preferably, described starting point determine submodule specifically for:
Judge whether described minimum range is less than default the first distance threshold, if so, by minimum range correspondenceImage outline in pixel, be defined as profile draw starting point.
Preferably, described device also comprises:
Information output module, while presetting the first distance threshold for being not less than when described minimum range, defeatedGo out information.
Preferably, described drafting orientation determination module comprises:
Angle is determined submodule, for draw the direction of operation according to active user, determines that active user drawsThe angle corresponding to direction of operation;
Draw orientation determination submodule, for corresponding according to each drafting direction of preserving for this starting pointEach angular range, determines the angular range at this angle place, by true drafting direction corresponding this angular rangeBe decided to be the drafting direction of drawing in image outline corresponding to this starting point.
Preferably, described terminating point judge module comprises:
Pixel coordinate is determined submodule, for determining described this drafting direction pair of a setting quantity pixelThe coordinate of last pixel of answering;
Coordinate distance judges submodule, paints for the coordinate and the described profile that judge described last pixelWhether the distance between the coordinate of the starting point of system is less than default second distance threshold value;
Terminating point is determined submodule, if for coordinate and the described image outline of described last pixelDistance between the starting point coordinate that middle profile is drawn is less than default second distance threshold value, determines described lastA pixel is terminating point, otherwise, determine described last pixel nonterminal point.
Preferably, before described starting point determination module, described device also comprises:
Binaryzation picture determination module, for according to the coordinate of definite image outline pixel, generate withThe black and white picture for the treatment of the contour wide binaryzation of picture of draw outline, wraps in the black and white picture of described binaryzationDescribed in containing, treat the image outline of the picture of draw outline.
Preferably, described pixel preserve module specifically for:
Judge in target image profile whether preserve a described setting quantity pixel, if not, by instituteState and set a quantity pixel as the pixel in target image profile and preserve.
Preferably, described device also comprises:
Pixel removing module, if preserved a described setting quantity pixel for target image profilePoint, deletes a described setting quantity pixel of preserving.
As seen from the above technical solution, the embodiment of the present invention first adopts edge detection algorithm to determine image outlineThe coordinate of middle pixel, then according to the direction of the position of user's input and drafting operation, true from image outlineMake the pixel coordinate of target image profile, therefore drawing image profile more accurately, improves userExperience.
Brief description of the drawings
In order to be illustrated more clearly in the embodiment of the present invention or technical scheme of the prior art, below will be to implementingIn example or description of the Prior Art, the accompanying drawing of required use is briefly described. Apparently, the following describesIn accompanying drawing be only some embodiments of the present invention, for those of ordinary skill in the art, do not payingGo out under the prerequisite of creative work, can also obtain according to these accompanying drawings other accompanying drawing.
The schematic flow sheet of the method for drafting of a kind of image outline that Fig. 1 provides for the embodiment of the present invention;
The reference picture that Fig. 2 provides for the embodiment of the present invention;
The image outline picture of the reference picture that Fig. 3 provides for the embodiment of the present invention;
The schematic flow sheet of the method for drafting of the another kind of image outline that Fig. 4 provides for the embodiment of the present invention;
The structural representation of the drawing apparatus of a kind of image outline that Fig. 5 provides for the embodiment of the present invention.
Detailed description of the invention
Below in conjunction with the accompanying drawing in the embodiment of the present invention, the technical scheme in the embodiment of the present invention is carried out clearlyChu, complete description. Obviously, described embodiment is only a part of embodiment of the present invention, and notWhole embodiment. Based on the embodiment in the present invention, those of ordinary skill in the art are not making woundThe every other embodiment obtaining under the prerequisite of the property made work, belongs to the scope of protection of the invention.
The embodiment of the present invention provides a kind of method for drafting and device of image outline, can draw more accuratelyImage outline, improves user and experiences. The method that the present embodiment provides and application of installation are in the electricity with display screenIn subset, comprise the electronic equipments such as desktop computer, notebook computer, panel computer pad, mobile phone,The mode of user's operation of catching can be the sliding action of mouse action and/or finger.
Below by specific embodiment, the present invention is described in detail.
The schematic flow sheet of the method for drafting of a kind of image outline that Fig. 1 provides for the embodiment of the present invention, its bagDraw together following steps:
Step S101: in the time detecting that image outline is drawn instruction, in the picture for the treatment of draw outline, adoptDetermine the coordinate of pixel in image outline with edge detection algorithm.
Be understandable that, the edge of image refers to the part that image local area brightness is changed significantly, imageThe shape that forms of edge be the profile of image. In one pictures, the profile of image may be crisscross multipleIntersect, may be also separate several profiles assortedly.
In actual applications, can adopt edge detection algorithm to determine the coordinate of pixel in image outline. AdoptThe coordinate of determining image outline pixel with edge detection algorithm belongs to prior art, in embodiments of the present inventionThis process is not repeated.
In order effectively to determine the coordinate of pixel in image outline, can adopt in embodiments of the present invention triumphantBuddhist nun Canny edge detection algorithm. Canny rim detection is actually a kind of first order differential operator detection algorithm,It has also increased non-maximum and has suppressed and two improvement of dual threshold on the basis of first order differential operator. UtilizeNon-maximum suppresses not only effectively to suppress multiple response edge, but also can improve the positioning accurate at edgeDegree; Utilize dual threshold, i.e. high threshold and low threshold value, can effectively reduce the loss at edge. By regulatingCorresponding parameter, Canny edge detection algorithm can identify the image outline of different fine degree. Due toDo not adopt Canny edge detection algorithm to determine that the pixel in image outline belongs to prior art, therefore not hereinRepeat again.
Step S102: according to the position of the coordinate of pixel in this image outline and active user's input,In image outline, determine the starting point that profile is drawn.
In order to obtain the positional information of active user's input, can provide corresponding information, prompting userPosition input initial drawing in screen time, as " please clicking in screen, to input initial position ",Or provide input frame, and prompting user inputs the coordinate (x, y) of initial position, and the coordinate system using is passableTaking the current upper left corner for the treatment of draw outline picture as the origin of coordinates, level is to the right x axle positive direction, vertically toBe down y axle positive direction, in reference axis, provide corresponding unit length, certainly adopt other coordinate system to be alsoPassable.
After having determined the position of active user's input, can adopt various ways to obtain from step S101To image outline in determine the starting point that profile is drawn, for example, according to the horizontal stroke of the position of active user inputCoordinate, by identical with this abscissa in image outline, apart from the nearest pixel in position of active user's inputPoint is defined as the starting point that profile is drawn, or according to the ordinate of the position of active user's input, by imageIdentical with this ordinate in profile, be defined as profile apart from the nearest pixel in position of active user's inputThe starting point of drawing.
Step S103: draw the direction of operation according to active user, determine the image wheel that this starting point is correspondingThe drafting direction of drawing in exterior feature, and in image outline, determine and set quantity according to described drafting directionPixel.
After having determined the starting point that profile is drawn, in order to determine target image profile from image outline,In the embodiment of the present invention, need in the process of drawing, obtain active user and draw the direction of operation. In order to obtainActive user draws the direction of operation, can point out user to input the direction of drawing operation. Particularly, userThe mode of direction of operating is drawn in input, can be to pin right mouse button in the enterprising line slip of screen, can be alsoSlide on screen with pointing, therefore corresponding information can be for " please pin left mouse button on screenSlide " or " please on screen, sliding ", also can provide input frame, user is according to showing on screen in promptingAt least two coordinate points of coordinate input, utilize these coordinate points to obtain the direction of drawing operation.
User's drafting operation may be along any one direction, and the direction that user draws operation has determined thisThe drafting direction of drawing in image outline. In this image outline, the multiple sides corresponding with this starting pointUpwards may there is the pixel of image outline. Draw the direction of operation according to active user, determine that this is initialPut the drafting direction of drawing in corresponding image outline, can have different modes, for example, can be trueDetermine active user and draw the each direction comprising in the direction of operation and the image outline corresponding with this starting pointBetween angle, by the orientation determination in image outline corresponding minimum angle for draw direction.
This setting quantity pixel can be 4~10 pixels, and other quantity pixel is also certainlyPassable. The value difference of this setting quantity, the speed that corresponding profile is drawn and effect also can be different.
Step S104: judge last picture corresponding to this drafting direction in a described setting quantity pixelWhether vegetarian refreshments is the terminating point of described image outline.
In the present embodiment, this step can comprise different embodiments. For example, can judge that this is lastWhether a pixel is less than a threshold with the distance of starting point in abscissa direction or in ordinate directionValue, when the distance between this last pixel and starting point in one of them direction of horizontal stroke, ordinate directionWhen being less than setting threshold, just can determine that this last pixel is terminating point. For fear of maloperation,This setting threshold is generally less than the distance of setting between a quantity pixel.
Step S105: if last picture corresponding to this drafting direction in a described setting quantity pixelVegetarian refreshments is the terminating point of described image outline, according to the pixel in the target image profile of preserving, and instituteState the pixel in the image outline between starting point and ending point in image outline, determine target image wheelWide.
Step S106: if last picture corresponding to this drafting direction in a described setting quantity pixelVegetarian refreshments is not the terminating point of described image outline, a described setting quantity pixel is taken turns as target imagePixel in exterior feature is also preserved, using described last pixel as starting point, and execution step S103.
Draw the direction of operation according to active user, in image outline, determine paints corresponding with starting pointDirection processed, and in image outline, determine and set a quantity pixel according to this drafting direction. If this settingIn a quantity pixel, last pixel corresponding to this drafting direction is not the termination of described image outlinePoint, using this last pixel as starting point, then carries out the drafting of target image profile. Therefore everyOnce such operation just can be regarded a drafting cycle as, if in this drafting cycle with this drafting direction pairLast pixel of answering is not the terminating point of image outline, so these pixels preserved, andUsing this last pixel as starting point, start the next drafting cycle. Often determine a drafting cycle,Whether be all the termination of image outline to last pixel corresponding with drawing direction in this drafting cyclePoint judges.
As shown in the above, the embodiment of the present invention first adopts edge detection algorithm to determine in image outline to look likeThe coordinate of vegetarian refreshments, then according to the direction of the position of user's input and drafting operation, from image outline, determineThe pixel coordinate of target image profile, the therefore profile of drawing image more accurately, improves user's bodyTest.
In another embodiment of the present invention, the step S102 in the embodiment of the method shown in Fig. 1, according toIn this image outline, the position of the coordinate of pixel and active user's input, determines that in image outline, profile is drawnStarting point before, described method can also comprise:
According to the coordinate of pixel in definite image outline, generate with the picture for the treatment of draw outline contour wideThe black and white picture of binaryzation, described in comprising in the black and white picture of described binaryzation, treat the picture of draw outlineImage outline.
Suppose to treat the picture of draw outline as shown in Figure 2, target image is the region in the upper left corner in Fig. 2. AdoptEdge detection algorithm is determined the coordinate of pixel in the image outline in Fig. 2, and according to looking like in this image outlineThe coordinate of vegetarian refreshments generate one with the black and white picture of the contour wide binaryzation of Fig. 2, i.e. Fig. 3, comprises in Fig. 3Image outline in Fig. 2.
Obtaining after the black and white picture of the binaryzation that includes image outline information, inputting according to active userWhen the starting point that profile draws is determined in position in image outline, can be directly from the image of this binaryzation pictureIn profile, determine the starting point that profile is drawn, thereby the process that simplified image profile is drawn improves drawing processEfficiency.
In another embodiment of the present invention, the step S102 in the embodiment of the method shown in Fig. 1, according toThe position of the coordinate of pixel and active user's input in this image outline, in image outline, definite profile is paintedThe starting point of system, can comprise the steps:
Step 1: according to the position of active user's input, obtain the coordinate of described position;
Step 2: according to the coordinate of pixel in the coordinate of described position and described image outline, described in determiningDistance in position and described image outline between each pixel;
Step 3: by the pixel in image outline corresponding minimum range, be defined as the initial of profile draftingPoint.
In the present embodiment, by determining the coordinate of user's input position, by with the institute of this coordinate distance minimumState the coordinate of pixel in image outline and be defined as the starting point that profile is drawn, can make the drafting of image outlineProcess is more accurate.
Further, by the pixel in image outline corresponding minimum range, be defined as taking turns in image outlineWide starting point of drawing, can comprise: judge whether described minimum range is less than default the first distance threshold,If so,, by the pixel in image outline corresponding minimum range, be defined as profile in image outline and paintThe starting point of system, in the time that described minimum range is not less than default the first distance threshold, output information, carriesShow that the pixel in the current described image outline of input position distance of user is too far away, should adjust input positionPut, make input position near the pixel in described image outline, can make like this drawing process more accurate.
In another embodiment of the present invention, the step S103 in the embodiment of the method shown in Fig. 1, according toActive user draws the direction of operation, determines the drafting side of drawing in image outline corresponding to this starting pointTo, can comprise the steps:
Step 1: draw the direction of operation according to active user, determine that active user draws the direction pair of operationThe angle of answering;
Step 2: according to each angular range corresponding to each drafting direction of preserving for this starting point, reallyThe angular range at fixed this angle place is this starting point correspondence by drafting orientation determination corresponding this angular rangeImage outline in the drafting direction of drawing.
Suppose, current starting point is the A point in Fig. 3, sets up coordinate system in Fig. 3. In step S101While determining the coordinate of pixel in image outline, preserve two and drawn directions, be respectively A1 and A2 direction,The angular range that this both direction is corresponding is respectively 0~180 degree ,-180~0 degree. Suppose that active user draws behaviourThe direction of doing is U1, and determines that angle corresponding to this U1 direction is-130 degree, therefore determines that this angle is inIn-180~0 degree angular range, be to draw in the image outline corresponding with starting point A by A2 orientation determinationDrafting direction.
In the present embodiment, determine that user draws the angular range at the angle place of the direction of operation, shouldThe drafting orientation determination that angular range is corresponding is the drafting of drawing in image outline corresponding to this starting pointDirection, can simplify the deterministic process of drawing direction, reduces amount of calculation.
In another embodiment of the present invention, the step S104 in the embodiment of the method shown in Fig. 1, judgementIn a described setting quantity pixel, whether last pixel corresponding to this drafting direction is described imageThe terminating point of profile, can comprise the steps:
Step 1: determine last pixel corresponding to this drafting direction in a described setting quantity pixelCoordinate;
Step 2: the coordinate of the starting point that the coordinate of described last pixel of judgement and described profile are drawnBetween distance whether be less than default second distance threshold value;
Step 3: if, determine that described last pixel is terminating point, otherwise, described in determiningA rear pixel nonterminal point.
In the present embodiment, the distance between the coordinate of last pixel and starting point coordinate is less than in advanceIf second distance threshold value, as the standard of determining terminating point, can be determined termination when profile is drawn more accuratelyPoint.
After using a described setting quantity pixel, the pixel in target image profile is preserved, if inspectionMeasure user's deletion action, the pixel of preservation can also be deleted, specifically can comprise step:
Judge in target image profile whether preserve a described setting quantity pixel, if not, by instituteState and set a quantity pixel as the pixel in target image profile and preserve; If target image profileIn preserved a described setting quantity pixel, delete preserve a described setting quantity pixel.
In the present embodiment, if preserved a described setting quantity pixel in target image profile, canTo illustrate that this drafting operation belongs to a kind of deletion action. Particularly, user may want to change the wheel of drawingExterior feature, or due to user's maloperation, drawn wrong profile. If belonging to, this drafting operation deletes behaviourDo, delete a described setting quantity pixel of having preserved. This deleting visible, this embodiment providesExcept can improving user, operation experiences.
The schematic flow sheet of the method for drafting of the another kind of image outline that Fig. 4 provides for the embodiment of the present invention, itsComprise the steps:
Step S401: in the time detecting that image outline is drawn instruction, in the picture for the treatment of draw outline, adoptEdge detection algorithm is determined the coordinate of pixel in image outline.
Step S402: according to the coordinate of pixel in definite image outline, generate and the figure that treats draw outlineThe black and white picture of the contour wide binaryzation of sheet, waits to draw wheel in the black and white picture of described binaryzation described in comprisingThe image outline of wide picture.
Step S403: according to the position of active user's input, obtain the coordinate of described position; According to institute's rhemeThe coordinate of pixel in the coordinate of putting and described image outline, determines in described position and described image outline everyDistance between individual pixel, and determine the minimum range in this distance.
Step S404: judge that whether described minimum range is less than default the first distance threshold, if so, holdsRow step S405, otherwise, S406 carried out.
Step S405: in the time that described minimum range is not less than default the first distance threshold, output information.
Step S406: in the time that described minimum range is less than default the first distance threshold, minimum range is correspondingPixel in image outline, is defined as the starting point that profile is drawn.
Step S407: draw the direction of operation according to active user, determine the image outline that this starting point is correspondingIn the drafting direction of drawing, and in image outline, determine that according to described drafting direction setting quantity looks likeVegetarian refreshments.
Step S408: determine last pixel corresponding to this drafting direction in a described setting quantity pixelThe coordinate of point.
Step S409: the seat of the starting point that the coordinate of described last pixel of judgement and described profile are drawnWhether the distance between mark is less than default second distance threshold value, if so, performs step S410, otherwise,Execution step S412.
Step S410: when the coordinate of the coordinate of described last pixel and the starting point of described profile draftingBetween distance while being less than default second distance threshold value, determine that described last pixel is terminating point.
Step S411: according to the pixel in the target image profile of preserving, and initial in described image outlinePixel in image outline between point and terminating point, determines target image profile.
Step S412: when the coordinate of the coordinate of described last pixel and the starting point of described profile draftingBetween distance while being not less than default second distance threshold value, determine described last pixel nonterminal point.
Step S413: judge in target image profile, whether to preserve a described setting quantity pixel, ifBe, perform step S414, otherwise, execution step S415.
Step S414: in the time having preserved described setting quantity pixel in target image profile, deleteA described setting quantity pixel of preserving, and by first pixel corresponding with this drafting direction of preservingAs starting point, execution step S407.
Step S415: in the time not preserving described setting quantity pixel in target image profile, will described inSet a quantity pixel as the pixel in target image profile and preserve, and by described last pictureVegetarian refreshments, as starting point, performs step S407.
As shown in the above, the embodiment of the present invention first adopts edge detection algorithm to determine in image outline to look likeThe coordinate of vegetarian refreshments, then according to the direction of the position of user's input and drafting operation, from image outline, determineThe pixel coordinate of target image profile. In the time that user's input position range image profile is far away, all rightProvide information, prompting user adjusts input position, therefore drawing image profile more accurately. WithTime, user can also delete the pixel in drawn profile in drawing process, improves user and experiences.
The structural representation of the drawing apparatus of a kind of image outline that Fig. 5 provides for the embodiment of the present invention, with Fig. 1Shown in embodiment of the method corresponding, described device comprises:
Image outline detection module 501, in the time detecting that image outline is drawn instruction, is waiting to draw wheelIn wide picture, adopt edge detection algorithm to determine the coordinate of pixel in image outline;
Starting point determination module 502, for according to the coordinate of described image outline pixel and active userThe starting point that profile is drawn is determined in the position of input in image outline;
Draw orientation determination module 503, for draw the direction of operation according to active user, determine that this is initialPut the drafting direction of drawing in corresponding image outline, and the described drafting direction of foundation is in image outlineDetermine and set a quantity pixel;
Terminating point judge module 504, for judging this drafting direction correspondence of a described setting quantity pixelLast pixel whether be the terminating point of described image outline;
Target image profile determination module 505, if for described setting quantity this drafting side of pixelThe terminating point of described image outline to last pixel of correspondence, according to the target image wheel of preservingPixel in exterior feature, and the pixel in the image outline between starting point and ending point in described image outlinePoint, determines target image profile;
Pixel is preserved module 506, if for this drafting direction correspondence of a described setting quantity pixelLast pixel be not the terminating point of described image outline, described setting quantity pixel is doneFor the pixel in target image profile preservation, and using described last pixel as starting point, touchSend out and draw orientation determination module 503.
Concrete, the edge detection algorithm that image outline detection module 501 adopts can comprise triumphant Buddhist nun CannyEdge detection algorithm.
In another embodiment of the present invention, the starting point determination module in the device embodiment shown in Fig. 5502 specifically can comprise:
Coordinate obtains submodule (not shown), for according to the position of active user's input, obtains instituteThe coordinate that rheme is put;
Distance is determined submodule (not shown), for taking turns according to the coordinate of described position and described imageThe coordinate of pixel in exterior feature, determines the distance between each pixel in described position and described image outline;
Starting point is determined submodule (not shown), for by image outline corresponding minimum rangePixel, is defined as the starting point that profile is drawn.
Further, this starting point determines that submodule specifically can be for judging whether described minimum range is less thanDefault the first distance threshold, if so, by the pixel in image outline corresponding minimum range, is defined asThe starting point that profile is drawn.
In another embodiment of the present invention, the device shown in Fig. 5 can also comprise:
Information output module (not shown), for being not less than default first when described minimum rangeWhen distance threshold, output information.
In another embodiment of the present invention, the drafting orientation determination mould in the device embodiment shown in Fig. 5Piece 503 specifically can comprise:
Angle is determined submodule (not shown), for draw the direction of operation according to active user, reallyDetermine active user and draw the angle corresponding to direction of operation;
Draw orientation determination submodule (not shown), for each according to what preserve for this starting pointDraw each angular range corresponding to direction, determine the angular range at this angle place, by this angular range pairThe drafting orientation determination of answering is the drafting direction of drawing in image outline corresponding to this starting point.
In another embodiment of the present invention, the terminating point judge module in the device embodiment shown in Fig. 5504 specifically can comprise:
Pixel coordinate is determined submodule (not shown), for determining a described setting quantity pixelIn the coordinate of last pixel corresponding to this drafting direction;
Coordinate distance judges submodule (not shown), for judging the seat of described last pixelWhether the distance between the coordinate of the starting point that mark and described profile are drawn is less than default second distance threshold value;
Terminating point is determined submodule (not shown), if for the coordinate of described last pixelAnd the distance between the starting point coordinate that in described image outline, profile is drawn is less than default second distance threshold value,Determine that described last pixel is terminating point, otherwise, determine described last pixel nonterminalPoint.
In another embodiment of the present invention, the starting point in the device embodiment shown in Fig. 5 is determined mouldBefore piece 502, described device can also comprise:
Binaryzation picture determination module (not shown), for according to definite image outline pixelCoordinate, generate and the black and white picture of the contour wide binaryzation of the picture for the treatment of draw outline described binaryzationBlack and white picture in treat the image outline of the picture of draw outline described in comprising.
In another embodiment of the present invention, the pixel in the device embodiment shown in Fig. 5 is preserved module506 specifically can be for:
Judge in target image profile whether preserve a described setting quantity pixel, if not, by instituteState and set a quantity pixel as the pixel in target image profile and preserve.
In another embodiment of the present invention, the device shown in Fig. 5 can also comprise:
Pixel removing module (not shown), if described in having preserved for target image profileSet a quantity pixel, delete a described setting quantity pixel of preserving.
Because said apparatus embodiment is that method for drafting embodiment based on image outline obtains, with the methodHave identical technique effect, the technique effect that therefore installs embodiment does not repeat them here.
For device embodiment, because it is substantially similar in appearance to embodiment of the method, so describe to obtain ratioSimpler, relevant part is referring to the part explanation of embodiment of the method.
It should be noted that, in this article, the relational terms such as the first and second grades be only used for byEntity or operation and another entity or operating space separate, and not necessarily require or imply theseBetween entity or operation, there is relation or the order of any this reality. And term " comprises ", " bagContaining " or any other variant be intended to contain comprising of nonexcludability, thereby make to comprise a series of key elementsProcess, method, article or equipment not only comprise those key elements, but also comprise its that clearly do not listHis key element, or be also included as the intrinsic key element of this process, method, article or equipment. Do not havingHave in the situation of more restrictions, the key element being limited by statement " comprising ... ", and be not precluded within and compriseIn process, method, article or the equipment of described key element, also there is other identical element.
One of ordinary skill in the art will appreciate that, all or part of step in above-mentioned embodiment is canComplete by the relevant hardware of programmed instruction, described program can be stored in embodied on computer readable storageIn medium. Here alleged storage medium, refers to ROM/RAM, magnetic disc, CD etc.
The foregoing is only preferred embodiment of the present invention, be not intended to limit protection model of the present inventionEnclose. All any amendments of making within the spirit and principles in the present invention, be equal to replacement, improvement etc., all bagBe contained in protection scope of the present invention.

Claims (10)

1. a method for drafting for image outline, is characterized in that, is applied to the electronic equipment with display screen,Described method comprises:
A. in the time detecting that image outline is drawn instruction, in the picture for the treatment of draw outline, adopt edge inspectionMethod of determining and calculating is determined the coordinate of pixel in image outline;
B. according to the position of the coordinate of pixel in described image outline and active user's input, take turns at imageIn exterior feature, determine the starting point that profile is drawn;
C. draw the direction of operation according to active user, determine in image outline corresponding to this starting point and carry outThe drafting direction of drawing, and in image outline, determine and set a quantity pixel according to described drafting direction;
D. whether judge last pixel corresponding to this drafting direction in a described setting quantity pixelFor the terminating point of described image outline, if so, according to the pixel in the target image profile of preserving,And the pixel in the image outline between starting point and ending point in described image outline, determine target imageProfile, otherwise the pixel using a described setting quantity pixel in target image profile is also preserved,Described last pixel is performed step to C as starting point.
2. method according to claim 1, is characterized in that, described according to looking like in described image outlineThe starting point bag that profile is drawn is determined in the position of the coordinate of vegetarian refreshments and active user's input in image outlineDraw together:
According to the position of active user's input, obtain the coordinate of described position;
According to the coordinate of pixel in the coordinate of described position and described image outline, determine described position and instituteState the distance between each pixel in image outline;
By the pixel in image outline corresponding minimum range, be defined as the starting point that profile is drawn.
3. method according to claim 2, is characterized in that, described by image corresponding minimum rangePixel in profile, the starting point that is defined as profile drafting comprises:
Judge whether described minimum range is less than default the first distance threshold, if so, by minimum range correspondenceImage outline in pixel, be defined as profile draw starting point.
4. method according to claim 3, is characterized in that, described method also comprises:
In the time that described minimum range is not less than default the first distance threshold, output information.
5. method according to claim 1, is characterized in that, describedly draws operation according to active userDirection, determine the drafting direction of drawing in image outline corresponding to this starting point, comprising:
Draw the direction of operation according to active user, determine that active user draws the angle corresponding to direction of operationDegree;
According to each angular range corresponding to each drafting direction of preserving for this starting point, determine this angleThe angular range at place is image wheel corresponding to this starting point by drafting orientation determination corresponding this angular rangeThe drafting direction of drawing in exterior feature.
6. method according to claim 1, is characterized in that, the described setting quantity of a described judgement pictureIn vegetarian refreshments, whether last pixel corresponding to this drafting direction is the terminating point of described image outline, bagDraw together:
Determine the coordinate of last pixel corresponding to this drafting direction in a described setting quantity pixel;
Between the coordinate of the starting point that the coordinate of described last pixel of judgement and described profile are drawnWhether distance is less than default second distance threshold value;
If so, determine that described last pixel is terminating point, otherwise, determine described last pictureVegetarian refreshments nonterminal point.
7. method according to claim 1, is characterized in that, described according to looking like in described image outlineThe position of the coordinate of vegetarian refreshments and active user input, in image outline, determine starting point that profile draws itBefore, described method also comprises:
According to the coordinate of pixel in definite image outline, generate with the picture for the treatment of draw outline contour wideThe black and white picture of binaryzation, described in comprising in the black and white picture of described binaryzation, treat the picture of draw outlineImage outline.
8. method according to claim 1, is characterized in that, described by a described setting quantity pixelPoint, as the pixel in target image profile preservation, comprising:
Judge in target image profile whether preserve a described setting quantity pixel, if not, by instituteState and set a quantity pixel as the pixel in target image profile and preserve.
9. method according to claim 8, is characterized in that, described method also comprises:
If preserved a described setting quantity pixel in target image profile, delete preserve described inSet a quantity pixel.
10. method according to claim 1, is characterized in that, described edge detection algorithm comprises Kai NiCanny edge detection algorithm.
CN201511021247.2A 2015-12-30 2015-12-30 Method and device for drawing image contour Active CN105654531B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201511021247.2A CN105654531B (en) 2015-12-30 2015-12-30 Method and device for drawing image contour

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201511021247.2A CN105654531B (en) 2015-12-30 2015-12-30 Method and device for drawing image contour

Publications (2)

Publication Number Publication Date
CN105654531A true CN105654531A (en) 2016-06-08
CN105654531B CN105654531B (en) 2019-01-08

Family

ID=56490006

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201511021247.2A Active CN105654531B (en) 2015-12-30 2015-12-30 Method and device for drawing image contour

Country Status (1)

Country Link
CN (1) CN105654531B (en)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107885538A (en) * 2016-09-28 2018-04-06 北京京东尚科信息技术有限公司 The method and apparatus that hot-zone link is added on picture
CN109785400A (en) * 2018-11-20 2019-05-21 广东智媒云图科技股份有限公司 A kind of sketch figure picture production method, device, electronic equipment and storage medium
CN110197519A (en) * 2018-02-26 2019-09-03 苏州宝时得电动工具有限公司 Method for compensating signal, device and storage medium in map generating process
CN111210485A (en) * 2020-01-06 2020-05-29 北京字节跳动网络技术有限公司 Image processing method and device, readable medium and electronic equipment
CN111611151A (en) * 2019-02-25 2020-09-01 阿里巴巴集团控股有限公司 Method and device for detecting excessive drawing of user interface

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5940081A (en) * 1995-01-27 1999-08-17 Sony Corporation Method and apparatus for forming a font and the font produced method and apparatus for drawing a blurred figure
CN103092524A (en) * 2013-01-31 2013-05-08 广东欧珀移动通信有限公司 Method for realizing screenshot through touch screen and mobile terminal
CN104574403A (en) * 2015-01-12 2015-04-29 飞天诚信科技股份有限公司 Intelligent cutting method
CN104932827A (en) * 2015-06-29 2015-09-23 北京金山安全软件有限公司 Picture clipping method and device and terminal
CN105046730A (en) * 2015-07-09 2015-11-11 北京盛世宣合信息科技有限公司 Writing trace demonstration method and apparatus applied to writing brush
CN105094599A (en) * 2015-06-29 2015-11-25 北京金山安全软件有限公司 Picture clipping method and device and terminal

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5940081A (en) * 1995-01-27 1999-08-17 Sony Corporation Method and apparatus for forming a font and the font produced method and apparatus for drawing a blurred figure
CN103092524A (en) * 2013-01-31 2013-05-08 广东欧珀移动通信有限公司 Method for realizing screenshot through touch screen and mobile terminal
CN104574403A (en) * 2015-01-12 2015-04-29 飞天诚信科技股份有限公司 Intelligent cutting method
CN104932827A (en) * 2015-06-29 2015-09-23 北京金山安全软件有限公司 Picture clipping method and device and terminal
CN105094599A (en) * 2015-06-29 2015-11-25 北京金山安全软件有限公司 Picture clipping method and device and terminal
CN105046730A (en) * 2015-07-09 2015-11-11 北京盛世宣合信息科技有限公司 Writing trace demonstration method and apparatus applied to writing brush

Cited By (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107885538A (en) * 2016-09-28 2018-04-06 北京京东尚科信息技术有限公司 The method and apparatus that hot-zone link is added on picture
CN107885538B (en) * 2016-09-28 2020-12-22 北京京东尚科信息技术有限公司 Method and device for adding hot area links on picture
CN110197519A (en) * 2018-02-26 2019-09-03 苏州宝时得电动工具有限公司 Method for compensating signal, device and storage medium in map generating process
CN109785400A (en) * 2018-11-20 2019-05-21 广东智媒云图科技股份有限公司 A kind of sketch figure picture production method, device, electronic equipment and storage medium
CN109785400B (en) * 2018-11-20 2023-08-04 广东智媒云图科技股份有限公司 Silhouette image manufacturing method and device, electronic equipment and storage medium
CN111611151A (en) * 2019-02-25 2020-09-01 阿里巴巴集团控股有限公司 Method and device for detecting excessive drawing of user interface
CN111611151B (en) * 2019-02-25 2023-05-16 阿里巴巴集团控股有限公司 Method and device for detecting overdrawing of user interface
CN111210485A (en) * 2020-01-06 2020-05-29 北京字节跳动网络技术有限公司 Image processing method and device, readable medium and electronic equipment
CN111210485B (en) * 2020-01-06 2023-03-28 北京字节跳动网络技术有限公司 Image processing method and device, readable medium and electronic equipment

Also Published As

Publication number Publication date
CN105654531B (en) 2019-01-08

Similar Documents

Publication Publication Date Title
CN105654531A (en) Method and device for drawing image contour
US9489068B2 (en) Methods and apparatus for preventing accidental touch operation
CN109961406A (en) A kind of method, apparatus and terminal device of image procossing
CN106296760B (en) Picture clipping method and device
CN103076954B (en) The method of adjustment display effect and device
CN109934785B (en) Image sharpening method and device
US20160275649A1 (en) Method and Apparatus for Switching Display Mode of Screen of Terminal Device, and Terminal Device
CN105046661A (en) Method, apparatus and intelligent terminal for improving video beautification efficiency
CN109544453A (en) Image adjusting method and device, electronic equipment, storage medium
US20190164347A1 (en) Method of displaying at least one virtual object in mixed reality, and an associated terminal and system
CN104754221A (en) Photographing method and mobile terminal
CN106371712B (en) Irregular screenshot method and device
CN113301320A (en) Image information processing method and device and electronic equipment
CN105898561A (en) Video image processing method and video image processing device
CN109246292B (en) Method and device for moving terminal desktop icons
CN109144363B (en) Information processing method and electronic equipment
CN105511753A (en) Method and terminal for display adjustment
US20170140557A1 (en) Image processing method and device, and computer storage medium
CN109766530B (en) Method and device for generating chart frame, storage medium and electronic equipment
CN107529095A (en) A kind of video-splicing method and device
US11287949B2 (en) Method and device for displaying icon
CN110874814A (en) Image processing method, image processing device and terminal equipment
CN113763233A (en) Image processing method, server and photographing device
CN112286430B (en) Image processing method, apparatus, device and medium
CN104679428A (en) Method for judging photograph rotation direction according to single finger gestures

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
TR01 Transfer of patent right
TR01 Transfer of patent right

Effective date of registration: 20201125

Address after: Room 115, area C, 1 / F, building 8, yard 1, yaojiayuan South Road, Chaoyang District, Beijing 100123

Patentee after: Beijing LEMI Technology Co.,Ltd.

Address before: 100085 Beijing City, Haidian District Road 33, two floor East Xiaoying

Patentee before: BEIJING KINGSOFT INTERNET SECURITY SOFTWARE Co.,Ltd.

TR01 Transfer of patent right
TR01 Transfer of patent right

Effective date of registration: 20240122

Address after: 3870A, 3rd Floor, Building 4, Courtyard 49, Badachu Road, Shijingshan District, Beijing, 100144

Patentee after: Beijing Jupiter Technology Co.,Ltd.

Country or region after: China

Address before: 100123 room 115, area C, 1st floor, building 8, yard 1, yaojiayuan South Road, Chaoyang District, Beijing

Patentee before: Beijing LEMI Technology Co.,Ltd.

Country or region before: China