0% found this document useful (0 votes)
8 views

T-pyramid of an Image-2

Uploaded by

Jelin Ranjitha.k
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

T-pyramid of an Image-2

Uploaded by

Jelin Ranjitha.k
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 21

IMAGE AND

VIDEO
ANALYTICS
laborator
y
1.T-PYRAMID OF AN
IMAGE
Definition:
 mage Pyramids are one of the most beautiful
concept of image processing.Normally, we work
with images with default resolution but many
times we need to change the resolution (lower it)
or resize the original image in that case image
pyramids comes handy. The pyrUp() function
increases the size to double of its original size
and pyrDown() function decreases the size to
half. If we keep the original image as a base
image and go on applying pyrDown function on
it and keep the images in a vertical stack, it will
look like a pyramid. The same is true for
upscaling the original image by pyrUp function.
Types:

 Gaussian Pyramid: This type of pyramid is


created by repeatedly applying a Gaussian
blur and downsampling the image. Each
level of the pyramid represents a lower
resolution version of the original image.
 Laplacian Pyramid: This pyramid is
derived from the Gaussian pyramid. It's
formed by taking the difference between
each level of the Gaussian pyramid and its
expanded version. This helps in
reconstructing the original image from the
pyramid.
Advantages of Image
pyramids:
 Lowering of resolution
 Getting various sizes of image
 Image Blending
 Edge detection
PROGRAM
 import cv2
 import matplotlib.pyplot as plt

 img = cv2.imread("images/input.jpg")

 layer = img.copy()

 for i in range(4):
 plt.subplot(2, 2, i + 1)

 # using pyrDown() function


 layer = cv2.pyrDown(layer)

 plt.imshow(layer)
 cv2.imshow("str(i)", layer)
 cv2.waitKey(0)

 cv2.destroyAllWindows()
OUTPUT:
2.QUADTREE
REPRESENTATION
DERFINITION:

 A region quadtree may also be used


as a variable resolution
representation of a data field. For
example, the temperatures in an
area may be stored as a quadtree,
with each leaf node storing the
average temperature over the
subregion it represents.
Process:

 Divide the current two dimensional


space into four boxes.
 If a box contains one or more points
in it, create a child object, storing in
it the two dimensional space of the
box
 If a box does not contain any points,
do not create a child for it
 Recurse for each of the children.
Functions:
 Insert Function:  Search Function:
 The insert functions is used  The search function is
to insert a node into an used to locate a node in
existing Quad Tree. This the given quad. It can also
function first checks whether
be modified to return the
the given node is within the
boundaries of the current
closest node to the given
quad. If it is not, then we point. This function is
immediately cease the implemented by taking
insertion. If it is within the the given point,
boundaries, we select the comparing with the
appropriate child to contain boundaries of the child
this node based on its quads and recursing. This
location. This function is function is O(Log N) where
O(Log N) where N is the size N is size of distance.
of distance.
Program:
 import matplotlib.pyplot as plt
 import cv2
 import numpy as np
 from operator import add
 from functools import reduce
 img = cv2.imread("IMG_8366.JPG")
 def split4(image):
 half_split = np.array_split(image, 2)
 res = map(lambda x: np.array_split(x, 2, axis=1), half_split)
 return reduce(add, res)
 split_img = split4(img)
 fig, axs = plt.subplots(2, 2)
 axs[0, 0].imshow(split_img[0])
 axs[0, 1].imshow(split_img[1])
 axs[1, 0].imshow(split_img[2])
 axs[1, 1].imshow(split_img[3])
 def concatenate4(north_west, north_east, south_west, south_east):
 top = np.concatenate((north_west, north_east), axis=1)
 bottom = np.concatenate((south_west, south_east), axis=1)
 return np.concatenate((top, bottom), axis
 full_img = concatenate4(split_img[0], split_img[1], split_img[2], split_img[3]
 plt.imshow(full_img)
 plt.show()
Output:
3.GEOMENTRIC TRANSFORMS
Definition:

 Geometric transformation is one of


the conventional methods to
augment data, which aims to make
the model invariant to the changes in
position and orientation. Some
typical operations include rotation
with a certain angle, horizontal or
vertical flipping, random patch
cropping, scaling, shifting, and so on
Purpose:
 Image Registration: Aligning different images or frames to a
common coordinate system. This is useful for tasks like image
stitching, where multiple images are combined to create a
panoramic view.
 Object Detection and Recognition: Transforming images
to standardize size, orientation, or perspective for better
detection and recognition of objects within the image.
 Image Enhancement: Applying transformations to improve
the quality of an image by adjusting contrast, brightness, or
sharpness.
 Video Stabilization: Correcting for camera motion or jitter in
video sequences to produce smoother and more stable
footage.
 Augmented Reality: Overlaying digital information or virtual
objects onto real-world scenes by aligning them with the
camera's perspective.
Types:
 Translation
 Rotation
 Reflection
 Dilation.
Geometric Transforms
Include
 Translation: Shifting the position of pixels within the image
along the x and y axes.
 Rotation: Rotating the image around a specified point or axis.
 Scaling: Resizing the image while maintaining its aspect ratio.
 Shearing: Distorting the image by stretching or skewing it
along one axis.
 Perspective Transformation: Transforming the image to
simulate changes in perspective, such as tilting or viewing
from different angles.
 Affine Transformation: Combining translation, rotation,
scaling, and shearing into a single transformation matrix.
 Homography: A transformation that maps points from one
image to corresponding points in another image, often used for
image registration and panorama stitching.

You might also like