cs0607050/analysis.tex
1:   \section{Analysis}
2:   \label{s:analysis}
3: 
4:   We structure a stroke pattern according to perceptual organization
5:   principles: a pattern is a \emph{collection} of groups (hatching or
6:   stippling); a group is a \emph{distribution} of elements (points or
7:   lines); and an element is a \emph{cluster} of strokes.  For instance,
8:   the user can draw a pattern like the one in \fig{f:anal_ex}, which is
9:   composed of sketched line segments, sometimes with a single stroke,
10:   sometimes with multiple overlapping strokes; our system then clusters
11:   the strokes in line elements that hold specific properties; and finally
12:   structures the elements into a hatching group that holds its own
13:   properties.  We restrict our analysis to homogeneous groups with an
14:   approximate uniform distribution of their elements: hatching groups are
15:   made only of lines, stippling groups made only of points. This approach
16:   could be extended to more complex elements, using the clustering technique 
17:   of Barla \etal~\cite{BTS05a}.
18: 
19:   \input{fig-anal-ex.tex}
20: 
21:   As a general rule of thumb, we consider that involving the user in the
22:   analysis gives him or her more control over the final result, at the
23:   same time removing complex ambiguities.  Thus, in our system, the user
24:   first specifies the high-level properties of the stroke pattern he is
25:   going to describe. He chooses a type of pattern (hatching or stippling);
26:   this determines the type of elements to be analyzed (lines for hatching,
27:   points for stippling). He then chooses a 1D or 2D reference frame within 
28:   which the elements will be placed. He finally sets the scale $\epsilon$ of 
29:   the elements, measured in pixels: intuitively, $\epsilon$ represents the
30:   maximum diameter of analysed points, and the maximum thickness of
31:   analyzed lines. 
32: 
33:   Once these parameters are set, the user draws strokes as polyline
34:   gestures. Depending on the group type, points or lines at the scale
35:   $\epsilon$ are extracted and structured: Then statistics about perceptual
36:   properties of the strokes are computed. This whole processus has an instant 
37:   feedback, so that the user can vary $\epsilon$ and observe changes made to the
38:   analysis in real-time. We first describe how elements are extracted given a chosen
39:   $\epsilon$ and their analyzed properties; then we describe how those
40:   elements are structured into a group, and how perceptual measures that
41:   characterize this group are extracted.
42: 
43: 
44:   \subsection{Element analysis}
45:   \label{s:element}
46: 
47:   The purpose of element analysis is to cluster a set of strokes drawn by
48:   the user into points or lines, depending on the chosen element type.  To
49:   this end, we use a greedy algorithm that processes strokes in the
50:   drawing order, and tries to cluster them until no more clustering can be
51:   done. We first fit each input stroke to an element (point or line) at
52:   the scale $\epsilon$.  Strokes that cannot be fit to an element are
53:   flaged \emph{invalid} and will be ignored in the remaining steps of the
54:   analysis. Then, valid pairs of elements that can be perceived as a
55:   single element are clustered iteratively. The fitting and clustering of
56:   points and lines is illustrated in \fig{f:element_analysis}.
57: 
58:   For points, the fitting is performed by
59:   computing the center of gravity $c$ of a stroke $S$ and measuring its
60:   spread $s_p=2\max_{p \in S} |p - c|$. If $s_p>\epsilon$, then the stroke
61:   is flaged \emph{invalid} because the circle of center $c$ and diameter
62:   $s_p$ do not encloses $S$. The clustering of two points
63:   is made by computing the center of gravity $c^*$
64:   of the points and measuring its spread $s_p^*$. Similarly, if
65:   $s_p^*>\epsilon$, then the points cannot be clustered. This allows the
66:   system to recognize any cluster of short strokes relative to the scale
67:   $\epsilon$, like point clusters, small circled shapes, crosses,
68:   etc. (See \sect{s:results}.)
69: 
70: %  \input{fig-point-anal.tex}
71: 
72:   For lines, the fitting is performed by computing the virtual line $l_v$
73:   of a stroke $S$ and measuring its spread $s_l=2\max(d_H(S,l_v),
74:   d_H(l_v,S))$ where $d_H(X,Y)=\max_{x \in X} (\min_{y \in Y} |x - y|)$ is
75:   the Hausdorff distance between two sets of points.  The virtual line can be computed by least-square
76:   fitting, but in practice we found that using the endpoint line is enough
77:   and faster. Then, if $s_l>\epsilon$, the stroke is flaged
78:   \emph{invalid} because the line segment of axis $l_v$ and thickness
79:   $s_l$ do not enclose $S$. The clustering of two lines
80:   is made by computing the virtual line $l_v^*$ of
81:   the lines and measuring its spread $s_l^*$. The virtual line can be
82:   computed by least-square fitting on the whole set of points; but we
83:   preferred to apply least-square fitting only on the two endpoints of each clustered
84:   line for efficiency reasons.  Then, if $s_l^*>\epsilon$, the lines
85:   cannot be clustered.  This allows the system to recognize any set of
86:   strokes that resembles a line segment at the scale $\epsilon$. Examples
87:   including sketched lines, overlapping lines, and dashed lines are shown
88:   in \sect{s:results}.
89: 
90: %  \input{fig-line-anal.tex}
91: 
92:   Once points or lines have been extracted, we can compute their
93:   properties: extent, position and orientation. The extent property represents 
94:   the dimensions of the element: point size or line length and width.  
95:   For point size, we use the spread of the element. For lines, we use the length of the
96:   virtual line and its spread (for width).  Orientation represents the
97:   angle between a line and the reference frame main direction (the main
98:   axis for 1D frames, the X-axis for the cartesian frame). It is always
99:   ignored for points.  We add a special position property for 1D reference
100:   frames: since they are synthesized in 2D (in the picture plane), 1D
101:   patterns have a remaining degree of freedom that is represented by the
102:   position of elements perpendicular to the main axis.  For all these
103:   properties, we compute statistics (a mean and a standard deviation) and
104:   boundary values (a min and a max); We also store the gesture input by the 
105:   user and will refer to it as the \emph{shape} of the element in the rest of the paper.
106: 
107:   \input{fig-el-anal.tex}
108: 
109: %  These are summarized in the first row
110: %  of \tbl{t:props}.
111: 
112: %  \input{tbl-props.tex}
113: 
114:   \subsection{Group analysis}
115:   \label{s:group}
116: 
117:   A group is considered to be an approximately uniform distribution of
118:   elements within a reference frame. This means that while analyzing a
119:   reference group, we are not interested in the exact distribution of its
120:   elements: we consider a reference group as a small sample of a bigger,
121:   approximately uniform distribution of the same elements. Consequently,
122:   we first need to extract a local structure that describes the
123:   neighborhood of each element; this local structure will then be
124:   reproduced more or less uniformly throughout the pattern during
125:   synthesis.
126: 
127:   To this end, we begin with the computation of a graph that
128:   structures the elements locally: in 1D, we build a chain that
129:   orders strokes along the main axis; whereas in 2D, we compute a
130:   Delaunay triangulation. We only keep the edges that: (a)
131:   connect two \emph{valid} elements and (b) connect an element to
132:   its \emph{nearest neighbor}. \ignorethis{(see
133:   \fig{f:synth-graph})} We chose this because the synthesis
134:   algorithm (described in \sect{s:synthesis}) converges only when 
135:   considering nearest neighbor edges. However, this decision is also
136:   justified from a perceptual point of view: basing our analysis
137:   on nearest neighbors emphasizes the proximity property of
138:   element pairs, which is known to be a fundamental perceptual
139:   organization criterion. 
140: 
141: % \input{fig-synth-graph.tex}
142: 
143:   For each edge of the resulting graph, we extract the following
144:   perceptual properties, taking inspiration from Etemadi
145:   \etal~\cite{bb3357}: proximity for points and lines; parallelism,
146:   overlapping and separation for lines only. 
147:   
148:   \begin{window}[0,r,{\includegraphics[width=0.16\linewidth]{proximity.eps}},{}] 
149:   Proximity is simply taken to be the euclidean distance between the centers of the
150:   two elements in pixels. We not only compute this measure for points, but also for lines 
151:   in order to initialize our synthesis algorithm (see \sect{s:synthesis}.)
152:   \end{window}
153:   Let's note $\Delta$ the vector from one point to the other,
154:   then we have 
155:   \begin{equation}
156:     prox=||\Lambda|| 
157:   \end{equation}
158:   with $prox \in [0,+\infty)$.
159: 
160:   \begin{window}[0,r,{\includegraphics[width=0.28\linewidth]{parallelism.eps}},{}] 
161:   To compute parallelism, we first find the accute angle made between the two lines.
162:   Since there is no apriori order on the line pair, we take the absolute value of 
163:   this accute angle and normalize it between $0$ and $1$. 
164:   \end{window}
165:   Let's note $\Theta$ the accute angle, then we compute parallelism using
166:   \begin{equation}
167:     par=|\frac{2\Theta}{\pi}|
168:   \end{equation}
169:   with $par \in [0,1]$.
170: 
171: 
172:   \begin{window}[0,r,{\includegraphics[width=0.294\linewidth]{overlapping.eps}},{}] 
173:   Like Etemaldi \etal~\cite{bb3357}, we define overlapping relative
174:   to the bissector of the considered line pair. But we modify slightly their
175:   measure to meet our needs: We project the center of each line on the bissector
176:   and use them to define an overlapping vector $\Delta$. 
177:   \end{window}
178:   Overlapping is computed using the following formula:
179:   \begin{equation}
180:     ov=\frac{2||\Delta||}{L_1^*+L_2^*}
181:   \end{equation}
182:   where $L_1^*$ and $L_2^*$   are the lengths of the lines projected on the bissector.
183:   Note that with this definition, $ov=0$ means a perfect overlapping.
184: 
185:   \begin{window}[0,r,{\includegraphics[width=0.29\linewidth]{separation.eps}},{}] 
186:   Finally, separation represents the distance between two lines, this time in the direction 
187:   perpendicular to their bissector. We project the center of each line on a line perpendicular to the 
188:   bissector and use them to define a separation vector $\Gamma$.
189:   \end{window}
190:   Separation is then computed with the following formula:
191:   \begin{equation}
192:     sep=||\Gamma||
193:   \end{equation}
194:   with $sep \in [0,+\infty)$.
195: 
196: %  \tbl{t:props} summarizes the element pair properties, and 
197:   We compute statistics (a mean and a  standard deviation) and bounds (a min and a max) for each of these properties. 
198: 
199: 
200: