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

Image and Video Analytics Assignment

It's the assignment of iva.

Uploaded by

srisanthoshini25
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views

Image and Video Analytics Assignment

It's the assignment of iva.

Uploaded by

srisanthoshini25
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Image and video analytics assignment-1

Techniques of image pre-processing:

1.Noise Reduction:
Noise in an image can be caused by various factors such as low light,
sensor noise, and compression artifacts. Noise reduction techniques aim to
remove noise from the image while preserving its essential features. Some
common noise reduction techniques include Gaussian smoothing, median
filtering, and wavelet denoising .

Techniques:
1. Gaussian Filtering:
o How it works: Applies a Gaussian function to smooth the image.
o Use case: Effective for reducing Gaussian noise.
o Example: Blurring an image to reduce high-frequency noise.

Sample code:

gaussian_blur1 = cv2.GaussianBlur(img,(5,5),2,cv2.BORDER_DEFAULT)

gaussian_blur2 = cv2.GaussianBlur(img,(5,5),7,cv2.BORDER_DEFAULT)

plt.figure(figsize=(20, 20))

plt.subplot(1,3,1),plt.imshow(img,cmap = 'gray')

plt.title('Noisy Image')

plt.subplot(1,3,2),

plt.imshow(gaussian_blur1,cmap = 'gray')

plt.title('smoothing with Gaussian sigma=2')

plt.subplot(1,3,3),

plt.imshow(gaussian_blur2,cmap = 'gray')

plt.title('smoothing with Gaussian sigma=7')


2. Median Filtering:
o How it works: Replaces each pixel’s value with the median value of the
neighboring pixels.
o Use case: Excellent for removing salt-and-pepper noise.
o Example: Cleaning up an image with scattered white and black pixels.:

Sample code: #Median filter

img = cv2.cvtColor(pic1, cv2.COLOR_BGR2GRAY)

median = cv2.medianBlur(img,5)

plt.figure(figsize=(16, 16))

plt.subplot(121),plt.imshow(img,cmap = 'gray')

plt.title('Noisy Image')

plt.subplot(122),

plt.imshow(median,cmap = 'gray')

plt.title('Median filter')

plt.show()

3. Wavelet Transform:
o How it works: Decomposes the image into different frequency
components and processes them separately.
o Use case: Effective for multi-scale noise reduction.
o Example: Denoising an image by thresholding wavelet coefficients.
2.Contrast Enhancement:
Contrast enhancement techniques aim to increase the contrast of
an image, making it easier to distinguish between different image features.
These techniques can be helpful in applications such as medical imaging and
surveillance. Some standard contrast enhancement techniques include
histogram equalization, adaptive histogram equalization, and contrast stretching .

Techniques:
1. Histogram Equalization:

o How it works: Distributes the intensity values of an image more


evenly across the histogram.
o Use case: Enhances the contrast of images with poor dynamic
range.
o Example: Making details in a low-contrast image more visible.

2. Adaptive Histogram Equalization (AHE):

o How it works: Applies histogram equalization to small regions


(tiles) of the image.
o Use case: Improves local contrast and enhances edges.
o Example: Enhancing medical images to highlight fine details.
3. Linear Contrast Stretching:

o How it works: Stretches the range of intensity values linearly.


o Use case: Simple and effective for images with a narrow range of
intensity values.
o Example: Improving the contrast of satellite images.
4. Non-Linear Contrast Stretching:

o How it works: Uses non-linear functions (e.g., logarithmic,


exponential) to stretch the intensity values.
o Use case: Enhances specific ranges of intensity values more than
others.
o Example: Enhancing images with specific intensity ranges of
interest.
3.Image Resizing:
Image resizing techniques are used to adjust the size of an image.
Resizing can be done to make an image smaller or larger or to change its aspect
ratio. Some typical image resizing techniques include nearest neighbor
interpolation, bilinear interpolation, and bicubic interpolation.

Techniques:

1. Nearest Neighbor Interpolation:

o How it works: Simplest method that assigns the value of the


nearest pixel to the new pixel.
o Use case: Fast but can result in a blocky appearance, suitable for
simple graphics.
o Example: Resizing pixel art without introducing new colors.

2. Bilinear Interpolation:

o How it works: Considers the closest 2x2 neighborhood of known


pixel values surrounding the unknown pixel.
o Use case: Smoother than nearest neighbor, suitable for
photographs.
o Example: Enlarging a photo while maintaining a reasonable quality.

3. Bicubic Interpolation:

o How it works: Uses the closest 4x4 neighborhood of known pixels,


providing smoother results than bilinear.
o Use case: High-quality resizing for photographs.
o Example: Upscaling an image for printing.

4. Lanczos Resampling:

o How it works: Uses a sinc function to interpolate pixel values,


providing high-quality results.
o Use case: Best for high-quality image resizing, especially when
reducing size.
o Example: Downscaling a high-resolution image for web use.
4. color correction: Color correction techniques are used to adjust the
color balance of an image. Color correction is important in applications such
as photography, where the color accuracy of an image is critical. Some
common color correction techniques include gray world assumption, white
balance, and color transfer.

Techniques:
1. White Balance Adjustment:
o How it works: Corrects the color temperature to make whites appear
neutral.
o Use case: Removes color casts caused by different lighting
conditions.
o Example: Adjusting a photo taken under tungsten light to remove the
yellowish tint
2. Gray World Assumption:

o How it works: Assumes that the average color of an image should be


gray and adjusts accordingly.
o Use case: Useful for general color correction in various lighting
conditions.
o Example: Balancing colors in an outdoor photo to make it look more
natural

Sample code:

#Converting the sample image to grayscale

img = cv2.cvtColor(pic1, cv2.COLOR_BGR2GRAY)

plt.imshow(img,cmap='gray')
3. Color Transfer:

o How it works: Transfers the color characteristics from one image to


another.
o Use case: Matches the color style of one image to another.
o Example: Applying the color palette of a sunset photo to another
image

5. Segmentation:
Segmentation techniques are used to divide an image into regions based
on its content. Segmentation can be helpful in applications such as medical
imaging, where specific structures or organs must be isolated from the image.
Some standard segmentation techniques include thresholding, edge detection,
and region growing.

Techniques:
1. Threshold-Based Segmentation

• How it works: Divides the image into segments based on a threshold value.
Pixels with intensity values above the threshold are assigned to one segment,
and those below are assigned to another.
• Use case: Simple and effective for images with distinct intensity differences.
• Example: Separating the foreground from the background in a binary image.

Sample code:

#Thresholding: try playing with the threshold value (144 here) to see the changes

ret, thresh1 = cv2.threshold(img, 140, 255, cv2.THRESH_BINARY)

plt.imshow(thresh1,cmap='gray')
2. Edge-Based Segmentation

• How it works: Detects edges within an image and uses these edges to define
boundaries between segments.
• Use case: Effective for images with clear, well-defined edges.
• Example: Identifying the boundaries of objects in a photograph.

3. Region-Based Segmentation

• How it works: Groups pixels into regions based on predefined criteria, such as
intensity or texture.
• Use case: Useful for images where regions have similar characteristics.
• Example: Segmenting different tissues in a medical image.

6. Feature Extraction:
Feature extraction techniques are used to identify and extract relevant
features from an image. These features can be used in object recognition and
image classification applications. Some standard feature extraction techniques
include edge detection, corner detection, and texture analysis.

Techniques:
1. Edge Detection

• How it works: Identifies points in an image where the intensity changes


sharply.
• Techniques: Canny, Sobel, and Prewitt edge detectors.
• Use case: Useful for detecting object boundaries.
• Example: Identifying the edges of buildings in an aerial image.
2. Corner Detection

• How it works: Detects points where the intensity changes in multiple


directions.
• Techniques: Harris corner detector, Shi-Tomasi corner detector.
• Use case: Identifying key points in an image for tracking or matching.
• Example: Detecting corners of objects in a scene for 3D reconstruction.

3. Texture Analysis

• How it works: Analyzes the texture patterns in an image.


• Techniques: Gray-Level Co-occurrence Matrix (GLCM), Local Binary Patterns
(LBP).
• Use case: Classifying different textures in an image.
• Example: Differentiating between different types of fabrics.

You might also like