Image Processing Reference
In-Depth Information
We will use the second formula to calculate the dot product. To determine if a pixel C with
coordinates ( Cx , Cy ) is above the user-specified line, which is defined by points A and B with
coordinates ( Ax , Ay ) and ( Bx , By ) respectively, we need to do the following, as illustrated in Fig-
ure 2 .
FIGURE 2 Using dot product to determining if a point is over or below a user-specified line.
First we need to find the vector that is perpendicular to the line that is defined by points A
and B ; we will call it vector D . We then need to find the vector E that is equal to the diference
of vectors C and A . If the dot product of D and E is greater than 0, point C is above the line
defined by points A and B . If it is equal to 0, point C is right on the line, otherwise point C is
below the line. The parallel algorithm in pseudo-code is shown in Pseudo-code 5.
4.3 Line Crossing Detector
Line Crossing Detector is a similar algorithm to Over a Line Detector.
Pseudo-code 5
//one thread for each pixel
foreach pixel p do
color_diff = prev_color(p) - curr_color(p)
// square of different
color_diff *= color_diff
// update previous color
prev_color(p) = curr_color(p)
// empirically chosen value.
// can be adjusted to make detector more
// or less sensitive to changes.
threshold = 5000
Cx = p.getXcoordinates()
Search WWH ::

Custom Search