vimwiki/tech/gradient_vectors.wiki

42 lines
1.1 KiB
Plaintext

= Gradient Vectors =
A gradiant vector is an array with one cell corresponding to each pixel in an
image, with each cell containing a [[vector]] of the image's gradiant at that
point.
A Vector in this case has both direction and maginiute.
A gradient in this case is the change in values along both the x and y around
some pixel.
An interesting and very important property of gradient vectors is their
relationship to edges in an image. An edge is any sudden change in an image,
including lines, boundaries between two objects, etc. A gradient vector will
always be a normal to the edge in an image.
== Example Algorithm ==
{{{
[X] [7] [X]
[2] [C] [8]
[X] [3] [X]
}}}
Given the above pixel C, we only care about the values with numbers. We can
find the gradient in the X and Y respectively using
{{{
Delta_x = 8 - 2 = 6
Delta_y = 7 - 3 = 4
}}}
Therefore our vector is the matrix consisting of 6 over 4. To find the
direction of this vector we can take
{{{
arctan(6 / 4) = 56.309 degrees
}}}
This of course was on a single pixel value but the same concept applies for [[RGB]]
or [[CMYK]] colorspaces.