As an efficient and natural way to communicate ideas, the potential advantages of freehand sketch have been widely recognized and exploited in many fields. One phenomenon is that the pen is becoming a standard interaction tool in most computing devices such as tablet PCs, electronic whiteboards, and personal digital assistants (PDAs). Despite great efforts made since Sutherland's Sketchpad in 1963, the correct interpretation of sketches can still be a difficult problem. The difficulty arises from the fact that freehand sketches are informal, ambiguous, and implicit compared to the traditional WIMP (Window, Icon, Menu, and Pointer) user interfaces. Even the sketches representing the same semantics will vary greatly when drawn by the same user at different times.
Although the characteristic features of this invention will be particularly pointed out in the claims, the invention itself, and the manner in which it may be made and used, may be better understood by referring to the following description taken in connection with the accompanying figures forming a part thereof.
For the purposes of promoting an understanding of the principles of the disclosure, reference will now be made to the embodiments illustrated in the drawings and specific language will be used to describe the same. It will nevertheless be understood that no limitation of the scope of the claims is thereby intended, and alterations and modifications in the illustrated devices, and further applications of the principles of the disclosure as illustrated therein are herein contemplated as would normally occur to one skilled in the art to which the disclosure relates.
The techniques and methods disclosed herein are, generally speaking, aimed at providing ways to effectively and efficiently beautify hand sketches for a variety of purposes including, but not limited to, searching databases for similar drawings. In these methods, particular emphasis is placed on segmenting sketches, identifying geometric primitives in the segmented sketches, identifying implicit geometric constraints between geometric primitives, beautifying the drawings by replacing the segmented sketch with geometric primitives, and using the beautified drawings as input drawings for searching databases.
Sketch beautification can be thought of in some aspects as resolving two issues: sketch segmentation and primitive (or composite) recognition. Sketch segmentation parses the continuous stream of pen strokes into a series of constituent primitives. A robust and efficient segmentation algorithm can be used for a computer to correctly understand a user's interaction intent as the basis of higher-level symbolic and structural analysis. Primitive or composite recognition determines the kind of geometric entity a primitive or composite represents. In some applications, line, circle, and arc are the most popular primitives that constitute user's sketches, while composites can be some predefined entities, including symbols, which are composed of multiple primitives. It may be difficult in some applications for users to sketch high-order curves; but high-order curves may seldom occur in practice.
Once the primitives are recognized, freehand sketches can be beautified by assigning replacement primitives with proper parameters. Besides sketch beautification and composite (or primitive) recognition, the geometric constraints implied in sketches can also considered. Use of implied geometric constraints, as well as express geometric constraints, may also facilitate the sketch beautification process. Sketch beautification based on geometric constraints is useful in many fields. For example, in the conceptual design stage, a designer may check whether his/her initial design satisfies certain conditions. Also, the design results of the conceptual stage can be reused seamlessly in the later detailed design stage. The process described above can be illustrated by
Methods are presented below to parse and recognize sketches. In some embodiments, methods presented herein may contain three components: freehand sketch segmentation, primitive (or composite) recognition, and implicit constraint detection. The segmentation procedure may be independent of the sketching speed and curvature. Also, the shape-based sketch recognition may be independent of stroke-order, -number, and -direction, as well as invariant to rotation, scaling, and translation of strokes. With the help of implicit constraint detection, the beautification may be driven by a constraint solver.
Methods disclosed below can be used to parameterize freehand sketches, allowing designers to sketch freehand drawings and regularize them in real time according to the imposed geometric constraints. In some embodiments, methods can be composed of three parts: sketch recognition, implicit constraint recognition, and regularization under geometric constraint satisfaction. Since freehand sketches can sometimes be imprecise and vary greatly even when done by the same person at different times, it may be necessary to recognize what kind of meaningful geometric primitive a sketch represents. Furthermore, during the sketching process, it may be tedious for designers to express every constraint explicitly and in many cases certain constraints may be ignored naturally as default, such as the perpendicular or parallel constraints. What is needed is a method to find constraints to ensure there is a solution for the constraint satisfaction problem. Finally, the geometric constraint system can be solved and the sketches rendered.
The techniques presented herein enable users to beautify sketches to create drawings useful in a range of applications, some of which include further using the beautified sketches in database searching.
Segmentation Identification
Freehand sketches are usually composed of a series of basic geometric entities such as lines, circles, and arcs. When a user transmits his/her ideas using a pen, it may not be reasonable to require that each stroke only represents a single geometric primitive. On the contrary, a stroke may consist of multiple line segments and arcs. To recognize the sketches, a segmentation process can be used to parse and recognize primitive shapes from a user's stroke streams. Alternatively, an assumption can be made that a freehand stroke represents a primitive shape. Generally, sketches can be drawn offline or online. In the offline case, the sketches consist of bitmap-like pixels. In contrast with the offline sketches, during the online sketching process, the track of a stroke S can usually be composed of a sequence of small line segments rather than image bitmaps:
S={((xi,yi),(xi+1,yi+1),ti)|0≦i≦n} (1)
where n is the total number of line segments included in a single stroke S, (xi,yi) and (xi+1,yi+1) are the two ending points of a small line segment at time ti. Correspondingly, a sketching activity A is usually formed by a sequence of strokes:
A={Si|0≦i<m} (2)
where m is the number of strokes. In some embodiments, the sketch segmentation (ink parsing) can be described as finding all segment points that parse the stroke stream into a sequence of geometric primitives such as lines, circles, and arcs. One purpose of the geometric track is to provide the neighborhood information among consecutive intersected points between a circle and sketches. The methods disclosed herein can be extended to handle the off-line sketches if the consecutive points of the off-line sketches are tracked.
To parse a stroke into independent primitives a circle-scanning strategy can be used in which multiple circles are used to scan the sketch by changing their radii progressively. When two consecutive intersected points between a scanning circle and the sketch are close enough, the shared point between the two intersected line segments can be regarded as a segment point.
Given a stream of sketches (as Figure C(a) shows), an axes-aligned bounding box (AABB) B is determined according to Equation (3).
B={left=min{xi},top=min{yi},right=max{xi},bottom=max{yi}} (3)
where {xi,yi} represents the ending points of the line segments contained in this stroke. This bounding box can be used as a rough reference to determine the scanning circles and their parameters as described later. On the basis of this bounding box, a bounding square Q can be determined. This bounding square has the same center as the bounding box B, and its side length is equal to the longer length of the bounding box B.
To assure that a number of segment points can be detected, nine circles can be located at certain positions to scan the sketches. As Figure C(b) shows, Circle 1 is located at the center of the bounding box B, Circle 2-Circle 5 are located at the corners of the bounding box B obtained in Step 1, and Circle 6-Circle 9 are located at the corners of the bounding square Q. As for the radius of each circle, the radius of Circle 1 is equal to the half diagonal length of the bounding box B; the radius of Circle 2-Circle 9 is equal to the diagonal length of the bounding box B.
In
If more sets of scanning circles at different positions are used, the possibility of missing segment points will be lower. However, a heavier computational load may be the result since a lot of intersection operations are involved in the scanning process. Also, more false-positive segment points may be detected when the scanning step is too small. By analyzing possible sketching tracks, nine positions can be selected. The nine positions are largely distributed around eight major directions, as
When a circle scans a sketch, the radius of the circle can be changed progressively from a predefined value to zero (or from zero to a predefined value). This process can result in a series of intersection points between the circle and the sketch. As Equation (1) shows, the sketch consists of a sequence of small segments; thus, the scanning process computes the intersection between line segments and circles with the same center but different radii.
For the example shown in
Generally, the complexity of the sketches is proportional to the number of line segments contained in the sketches. More complex sketches usually have more segment points. To find all segment points, it can be necessary to use a series of circles with a small step in increasing radii to scan the sketch. However, a too small step implies additional unnecessary segments points that have to be filtered out. Experiments can be used to achieve a balance between the segmentation accuracy and the computational load. Computation time can be roughly linear to the step number of a scanning operation.
Due to the symmetry property of their positions, the nine predefined scanning circles can be classified into three categories: (1) circles located at the center of the bounding box, such as Circle 1 in
As seen in
In experiments testing the methods disclosed herein, based on 63 sketched drawings, the final results are summarized in Table 1, while the detailed statistics are listed in the Appendix. It can be seen that the overall accuracy of the segmentation is 92.5%. Accuracy may be further improved when combined with other methods.
Geometric Primitive Recognition
Lines, circles, and arcs can be the most popular primitives when users sketch their ideas using a pen. Although there may be only three kinds of geometric primitives, it is still not easy to robustly recognize them because there may be no clear boundary between them in many cases. As the examples in
A shape histogram method, similar to that disclosed in U.S. patent application Ser. No. 11/288,911 entitled METHODS FOR RETRIEVING SHAPES AND DRAWINGS, can be used to recognize independent strokes representing geometric primitives. Experiments show this derivation is good at recognizing geometric primitives and is independent of stroke-order, -number, and -direction, as well as invariant to rotation, scaling, and translation of strokes.
This step uses a series of points to approximate a 2D shape. To ensure that the sampling process can be conducted efficiently and uniformly, a look-up-table-based approach can be used.
For example, one step may be to compute the summed length of all line segments included in the freehand sketch. When each line segment is added, the summed length is saved into table T with size n, where n−1 is the total number of the line segments. Table T can be represented by a linear array as Equation (4) shows.
where L is the Euclidean distance between two points.
Another step may be to generate a random real number r between 0 and the total length tn−l, and then use the well-known binary-search algorithm to find out the position m where r is located in the table. The found position corresponds to the line segment ((xm,ym),(xm+1,ym+1)).
A further step may be to generate a random real number l between 0 and 1. According to Equation (5), a sample point (xk,yk) can be determined and saved into an array A.
Repeating those two generating steps for 2×n times, n point pairs can be obtained that are sampled in an unbiased manner.
In the sampling procedure, sampling density can be considered. From the perspective of statistics, more samples imply a more precise approximation of the original shape. A basic criterion that can be used is ensuring that sampling points are uniformly distributed on all critical shape components of the sketch. Experiments regarding the tradeoff between efficiency and precision have showed that 105 sampling point pairs can achieve a better balance between precision and computational efficiency for any given 2D legacy drawing.
Once enough random point pairs are sampled, the next step is to build the corresponding distance histogram which is described by a shape function. The Euclidean distance between two points can be selected as the shape function. Given n point pairs, their distances are calculated. Then by traversing each point pair (xi,yi),(xi+1,yi+1) in an array A and counting the number of sample pairs that fall into a certain distance range, a shape histogram H can be built. If the whole distance range is divided uniformly by N parts, then a shape histogram H is represented as
where Euclidean is the straight line distance between two points.
Since strokes drawn at different times can have different geometric sizes, a normalization process is needed to account for this difference. A standard value L can be determined and used for normalization. Generally, there can be two simple ways for normalization as shown in Equation (7). The first one uses the maximum distance among all sampled point pairs as the standard value. The second one uses the average distance of all sample point pairs as the standard value.
The problem of recognizing a primitive shape can now be transformed to computing the similarity between two histograms. Minkowski distance Ln is used in one embodiment. The similarity σ of two histograms, H1 and H2, can be computed using Equation (8).
where N is the dividing number of a histogram. For the two histograms, the smaller W means more similarity. To determine the primitive shape that a sketch represents, corresponding templates can be predefined. Because the shape histogram of a sketch is a perturbed version of the corresponding regular shape, the histogram of a regular shape as a template can be selected.
An experiment was conducted to check whether a 2D shape histogram can robustly recognize geometric primitives. Eight users were chosen to freely sketch lines, circles, and arcs. Each primitive was sketched ten times with different sizes and different shapes. All the sketches were indexed as templates. Then each user was asked to input sketches freely and evaluate the recognition performance. Three kinds of distances are considered: (a) the maximum distance, (b) the minimum distance, and (c) the average distance. The similarity distance between the later input sketches and the templates is shown in
To improve the recognition performance, the similarity between the input sketches can be compared using a set of critical templates. The critical shape acts as a “boundary shape.” Since an arc is generally confused with a line and circle, the extremes correspond to line and circle. Therefore, some critical arc shapes, a line, and a circle can be defined.
On the basis of the beautification of the 63 sketched drawings, the primitive recognition described above has been evaluated and summarized in Table 3. Additional information can be found in the Appendix. Totally, there are 1074 primitives, among which the correct recognitions are 1062 and the false recognitions are 12. Once the freehand sketches are segmented, most of the primitives can be recognized successfully.
As mentioned above, the 2D shape histogram method can also be used to recognize composite sketches. To asses the performance of composite sketch recognition, a set of symbols as shown in
A larger database was used to test the retrieval performance of the method disclosed above. It contained 2000 legacy drawings from industrial fields. Nine related methods were compared and the results were presented in the form of Precise-Recall Curves. The experiment shows that the 2D shape histogram has the second best performance compared to the other 8 methods. The best one is the 2.5D spherical harmonics transform method. The reason that the 2.5D spherical harmonics method was not used to compute the similarity between freehand sketches is due to the fact that the method requires a bounding box of the sketches. For similar sketches such as lines, arcs and circles, the respective bounding box may vary greatly, thus leading to a poor performance. From the experiment it was determined that the estimated accuracy rate of the 2D shape retrieval of our prototype system is within 75˜80%.
Sketch Beautification
Once the primitives in the sketches have been recognized, the primitives can be beautified by assigning proper parameters. For a line, a starting point and an ending point are needed. A simple way is using the starting and ending points of the sketch segment as the initial starting and ending points of a line. For an arc or circle, three points on the sketches are selected to compute the radius and the center of the arc or circle because the three points determine an arc or circle uniquely. The three points are composed by the two ending points and the middle point of the parsed segments.
It can be sometimes difficult for users to draw any graph precisely during the sketching process. Under- and over-sketching sometimes occur during the sketching process. In
There is, however, no need to immediately repair any over-sketching or under-sketching that may be present in a sketch. The reparation can be done by incorporating the over-sketching or under-sketching into a constraint system described below. Once the geometric constraint system is solved, the reparation will be finished automatically.
Turning now to the beautification of arcs, since variations of sketched arcs can be large, sometimes the proposed segment method might parse a sketched arc into several parts.
Implied Geometric Constraint Detection
The beautification described above transforms the freehand sketches into the corresponding regular geometric shapes but does not necessarily consider some intentions implied in a user's sketch. For example, the beautification described above does not explicitly consider certain geometric constraints such as perpendicular and parallel properties between shapes. These constraints represent the relationships between primitives. The geometric constraints can be classified into two categories: explicit constraints and implicit constraints. Explicit constraints refer to the constraint that users specify explicitly, while implicit constraints mean some implied constraints that users do not specify directly. With implicit constraints, users will express their ideas more naturally and efficiency will be improved at the same time. It can be natural for some users to express such intentions implicitly when they are sketching. For example, when a user sketches the shape as shown in
To detect implicit constraints, a method dubbed Relative Shape Histogram (RSH) can be used to check the relationship between two geometric primitives. RSH is similar to the shape histogram method described in U.S. patent application Ser. No. 11/288,911 entitled METHODS FOR RETRIEVING SHAPES AND DRAWINGS. RSH has similar sketch representation, sampling strategy, and shape function as the shape histogram method. One difference is that RSH only considers the Euclidean distances between point pairs that are sampled from different primitives; i.e., (xi,yi) and (xi+1,yi+1) in Equation (6) are located on different primitives. According to the basic steps of the
Furthermore, two interesting phenomena from the RSHs can be noticed. The first one is that certain parameters can be estimated from the respective RSH. For example, some examples of parallel constraint are shown in the first row of
A dynamic time warping (DTW) approach can be used to compute the similarity between sketches and existing templates and thus determine the constraint type of the RSH. DTW was originally developed to align two spectral sequences of speech and is now being widely used in speech processing, bio-informatics, and hand-writing recognition.
Suppose there are two time series S and T with length m and n respectively:
S={s1,s1, . . . ,sm}, T={t1,t1, . . . ,tn} (9)
To align S and T, we need to construct an m×n matrix M whose element at position (i,j) is the distance D between the two points si and tj. In this way, matrix element (i,j) corresponds to the alignment between the points si and tj. Now the alignment problem can be converted to finding a warping path that represents the correspondence between the two sequences S and T. In particular, DTW is defined as the warping path that minimizes the warping cost, which can be calculated by a dynamic programming approach as:
According to the DTW theory, the following steps are summarized to determine the constraint type of an RSH:
In most research work about GCSS (Geometric Constraint Satisfaction System) [37-39], implicit constraints are widely mentioned. However, no literature is found to handle the implicit constraints implied in freehand sketches. Despite the fact that GCSS also uses the same word “sketch”, the referred “sketch” is not a freehand sketch but a regular sketch. The most popular way to determine the type of implicit constraint is computing the distance between the parameters of the primitives. For example, the parallelism between two lines can be determined by checking the angle difference between the two lines is small enough. However, it is difficult to use this intuitive method to check the constraint type between sketched primitives. In
Among the 63 sketched drawings, 20 drawings were used to assess the performance of implicit constraint detection. Given two segmented primitives, four kinds of constraints are checked, including parallelism, concentricity, perpendicularity and tangency. The results are presented in Table 5.
In one embodiment, once the sketches are beautified, a geometric constraint system can be formed with the help of implicit and explicit constraints. In another embodiment, a constraint solver can be used to further beautify the sketches by satisfying the geometric constraints. Some examples about beautification driven by constraints are presented in
Detection of Falsely Identified Segment Points
In some embodiments, after a beautification process has been completed based on the identified segment points, the following process can revise some points that may have been falsely identified. The following disclosure describes the process of how to discover the region of interest (ROI) and correct some segmentation point inaccuracies.
First, denote the result obtained from the preliminary beautification as
P={P1, . . . PN},Pi={ps,pe,s1, . . . sm} (11)
where i=1, . . . N. N is the number of primitives after beautification, ps,pe are two end points of Pi, s1, . . . sm are segments in Pi after beautification, and m is the number of segments in Pi.
By locating the start and end points of Pi in the original sketch, the original segments between the two end points can be identified. Denote the segments between the end points as Si={ps,pe,seg1, . . . segK} where, K is the number of segments in this portion of the original sketch In addition, denote the connecting segment from ps to pe as H=(ps,pe).
The maximum deviation dmax can be defined as the maximum perpendicular distance from the end of each segment to H as it is shown in
By comparing the difference between dmax(Pi) and dmax(Si), a determination of whether there are any bogus primitives can be made. For example, if |dmax(Pi)−dmax(Si)|≦ξ, such as in
If a false primitive has been identified, the following method can be used in some applications to correct the false identification. The fact that noise and regular strokes coexist in a sketch makes the critical point detection different from the existing corner detection methods that are used for continuous curves. The values of slopes and curvatures may become oscillated along the discrete strokes in a single entity when noise strokes are encountered. Thus they are not optimal for this case.
In this algorithm, a divide and conquer strategy is employed. Points with dmax(Si)>ξ are required to be located first. In reality, there are two cases where the points with the maximum deviation in Si may exist.
When there are only an odd number of points with the maximum distance, the medium one of them is selected.
After the point where dmax(Si)>ξ is located, the original set of segments Si={ps,pe,segl, . . . segk} is split by this point and become two set of segments Si1={ps,pnew1,segl, . . . segk} and Si2={pnew,Pe,segk+1, . . . segK}. This algorithm then finds the points where dmax(Si1)>ξ and dmax(Si2)>ξ are located and splits the segments by the points. The algorithm handles recursively within each segment until the value of dmax for each one is less than the threshold.
Each set of segments after this decomposition process can be denoted as D={D1, . . . DN′},Di={p′s,p′e,s′1, . . . s′m}. One procedure to decide the geometric property of Di is to again check the value of dmax (Di) even though dmax(Di)≦ξ for stopping condition. If dmax(Di)≦ a much smaller threshold, then Di is determined as a straight line, else Di is a curve.
Referring now to
Referring now to
Some Examples of Freehand Sketch Parameterization
To demonstrate the validity of the methods disclosed herein, some examples are presented in
Thus, as described above a user can enter and beautify a sketch using the methods disclosed. A user sketch can be segmented into individual geometric primitives. The individual primitives can then be beautified. In addition to geometric primitives, implied geometric constraints, such as parallel lines, can be detected and beautified. After beautification of geometric primitives, or of implicit geometric constraints, or both, the beautified sketch can be processed to determine if any segments points were falsely identified. If so, the sketch can be beautified once again in the same manner disclosed above discarding the falsely identified segment points.
After beautification, the sketch can be used in a variety of forms. The beautified sketch can be used to search in a database of known objects similar to the beautified sketch using methods disclosed in U.S. patent application Ser. No. 11/288,911, filed Nov. 29, 2005 entitled: METHODS FOR RETRIEVING SHAPES AND DRAWINGS. Alternatively, a sketch may be beautified, a search conducted for a similar shape in a library of known symbols, and the sketch can be replaced with a symbol that approximates the sketch. Such would be beneficial in applications such as circuit analysis software wherein a user can supply a sketch of a desired element such as a resistor, the sketch can be beautified and compared against a library of symbols and then replaced with an analysis object of the corresponding shape.
Referring back generally to
The embodiment shown in
In other embodiments, the beautified sketch could also be further processed using explicit geometric constraints. In this situation a user may provide a sketch and additionally impose explicit geometric constraints such as, for example, assigning lengths to certain features of the sketch. The system could then satisfy these constraints and return the results to the user. A beautified drawing which satisfies explicit constraints could then be used, as described above, in other applications such as input useful in searching a database of drawings.
Thus, methods have been disclosed to beautify freehand sketches, such as sketch segmentation, geometric shape recognition, implicit constraint detection, and beautification. These are achieved using scanning circles at key locations, shape histogram matching, relative shape histograms, and finally, constraint satisfaction. In some embodiments, the beautification not only transforms the parsed segments into the regular primitives but also satisfies the implicit constraints implied in the sketch and the explicit constraints imposed by the user. The proposed methods have some valuable advantages, such as transformation-invariance, stroke-speed, and curvature independence. The beautification methods disclosed herein may be useful in computer-aided design, which is expected to provide users with great flexibility, high efficiency, and naturalness in product design. In some applications users may express constraints directly with freehand sketches. In addition, the proposed method may be extended to 3D for modeling purposes.
Herein, an approach supporting freehand sketch parameterization is introduced, including freehand sketch recognition, implicit constraint detection, and a geometric constraint solver. This proposed method allows users to sketch freehand drawings and regularize them automatically according to the imposed geometric constraints. The whole parameterization process is independent of stroke-order, -number, and -direction, as well as invariant to rotation, scaling, and translation of strokes. In particular, with the help of an interface-open and -reconstruction strategy, the described graph reasoning method can provide an analytical solution for most geometric constraint satisfaction problems. Experiments show that this interaction paradigm supported by freehand sketch parameterization can provide users with a great flexibility, high efficiency and naturalness.
The above description is illustrative, and not restrictive. Many other embodiments will be apparent to those of skill in the art upon reviewing the above description. The scope of embodiments should therefore be determined with reference to the appended claims, along with the full scope of equivalents to which such claims are entitled.
In the foregoing description of the embodiments, various features are grouped together in a single embodiment for the purpose of streamlining the disclosure. This method of disclosure is not to be interpreted as reflecting that the claimed embodiments have more features than are expressly recited in each claim. Rather, as the following claims reflect, inventive subject matter lies in less than all features of a single disclosed embodiment. Thus the following claims are hereby incorporated into the Description of the Embodiments, with each claim standing on its own as a separate exemplary embodiment.
The present application claims the benefit of U.S. Provisional Patent Application Ser. No. 60/664,005, filed Mar. 21, 2005, with said priority application being incorporated herein by reference in its entirety. This application is also related to U.S. patent application Ser. No. 11/288,911, filed Nov. 29, 2005, entitled: METHODS FOR RETRIEVING SHAPES AND DRAWINGS (Inventors: Karthik Ramani and Jiantao Pu), which is hereby incorporated by reference in its entirety. This application is also related to “Toward Freehand Sketch Beautification Driven by Geometric Constraint” by Pu Jiantao and Karthik Ramani which is hereby incorporated by reference in its entirety.
Number | Date | Country | |
---|---|---|---|
60664005 | Mar 2005 | US |