02lab Image Operation
02lab Image Operation
ACTIVITY 2
(DIGITAL IMAGE
PROCESSING)
IMPORTING THE REQUIRED
LIBRARIES
cv2 - Used for Image Processing
Matplotlib - Used for Plotting and Visualization
Numpy - Used for Scientific Computing
TO ANALYZE IMAGE
IMAGE DETAILS
There are multiple ways to do interpolation. If we are enlarging an image, it's preferable to
use linear or cubic interpolation. If we are shrinking an image, it's preferable to use the
area-based interpolation. Cubic interpolation is computationally more complex, and hence
slower than linear interpolation. But the quality of the resulting image will be higher.
OpenCV comes with a function resize() for this purpose. The size of the image can be
specified manually, or you can specify the scaling factor. Different interpolation methods
are used. Preferable interpolation methods are INTER_AREA for shrinking and INTER_CUBIC
(slow) & INTER_LINEAR for zooming. By default, the interpolation method INTER_LINEAR is
used for all resizing purposes.
AFFINE TRANSFORMATION
Affine transformation is a functional mapping
between two geometric (affine) spaces which
preserve points, straight and parallel lines as well
as ratios between points. Loosely speaking linear
transformation that results in, at least in the
context of image processing, one or more
manipulations like rotating, flipping, scaling or
shearing by applying a transformation matrix.
For the example we just need three points to get
the affine transformation matrix. We want the
three points in source points to be mapped to
the corresponding points in destination points.
To get the transformation matrix, we’ll use the OpenCV function getAffineTransform(). Once we
have the affine transformation matrix, we use the warpAffine() function to apply this matrix to
the original image.
AFFINE TRANSFORMATION
MIRROR IMAGE
IMAGE ROTATION
Rotation of an image for an angle theta is achieved by the transformation matrix
of the form: