0% found this document useful (0 votes)
3 views3 pages

Digital Image Processing Practical File

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

Digital Image Processing Practical File

Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Digital Image Processing – Practical File

Practicals Included:
1. Box Filter Kernel
2. Downsampling of Image
3. Gamma Correction
4. Image Negative
5. Image Subtraction
6. Negative Inverse Image
7. Order Statistics (Non-Linear Filtering)
8. Subtraction of Two Images

Practical 1: Box Filter Kernel


Aim: To apply a box filter kernel on an image for smoothing and noise reduction.

Theory: A box filter is a simple linear smoothing filter that replaces each pixel with the average of its
neighboring pixels inside a fixed-size kernel such as 3x3 or 5x5. It helps reduce noise and small
intensity variations. This filter is commonly used before advanced image processing operations
because it improves image quality by reducing unwanted details. However, too much filtering can
blur important edges.

Code:
import cv2
blur = [Link](img, (5,5))

Output: Original and smoothed images are displayed.


Conclusion: Box filtering reduces noise and smooths the image effectively.

Practical 2: Downsampling of Image


Aim: To reduce the image size using downsampling.

Theory: Downsampling reduces the number of pixels in an image and lowers its resolution. It is
useful for reducing storage space and computational cost. It is widely used in compression,
streaming, and computer vision applications where faster processing is required.

Code:
small = [Link](img, ([Link][1]//2, [Link][0]//2))

Output: Original and reduced-size images are displayed.


Conclusion: Downsampling improves efficiency and reduces memory usage.

Practical 3: Gamma Correction


Aim: To improve brightness using gamma correction.

Theory: Gamma correction is a power-law transformation used to adjust brightness levels. It


improves the visibility of dark or bright areas according to human visual perception. It is useful in
photography, medical imaging, and display systems.

Code:
corrected = [Link](img, table)

Output: Gamma corrected image is displayed.


Conclusion: Gamma correction improves image brightness and contrast.

Practical 4: Image Negative


Aim: To generate the negative of an image.

Theory: Negative transformation subtracts each pixel value from 255 in an 8-bit image. This
reverses brightness levels and helps reveal hidden details in bright regions. It is useful in X-ray and
medical image analysis.

Code:
negative = 255 - img

Output: Original and negative images are displayed.


Conclusion: Negative transformation improves visibility of fine details.

Practical 5: Image Subtraction


Aim: To subtract two images for change detection.

Theory: Image subtraction compares two images by subtracting corresponding pixel values. It helps
detect movement, object changes, and differences between frames. It is useful in surveillance and
monitoring systems.

Code:
sub = [Link](img1, img2)

Output: Difference image is displayed.


Conclusion: Image subtraction helps in identifying changed regions.

Practical 6: Negative Inverse Image


Aim: To restore the original image from a negative image.

Theory: Applying the negative formula again on a negative image restores the original image. This
demonstrates that negative transformation is reversible and useful for restoration tasks.

Code:
inverse = 255 - img

Output: Restored image is displayed.


Conclusion: Original image is successfully recovered.

Practical 7: Order Statistics (Non-Linear Filtering)


Aim: To remove noise using median filtering.

Theory: Order statistics filters are non-linear filters that arrange neighboring pixel values and
choose a specific value such as minimum, maximum, or median. Median filtering is highly effective
for removing salt-and-pepper noise while preserving edges.

Code:
median = [Link](img, 5)

Output: Noise-reduced image is displayed.


Conclusion: Median filtering removes impulse noise without strong blurring.

Practical 8: Subtraction of Two Images


Aim: To compare two grayscale images using subtraction.

Theory: Absolute difference is used to compare intensity values between grayscale images. It
highlights changed regions clearly and is commonly used in motion detection and background
subtraction.

Code:
result = [Link](img1, img2)

Output: Difference image is displayed.


Conclusion: Grayscale subtraction clearly identifies intensity changes.
Final Conclusion:
These practicals helped in understanding major Digital Image Processing techniques such as
filtering, enhancement, transformation, restoration, and comparison. These methods are widely
used in medical imaging, surveillance, computer vision, and industrial applications.

You might also like