SlideShare a Scribd company logo
AIR UNIVERSITY
Department of Electrical and Computer Engineering
Digital Image Processing Lab
Lab #4: Sampling and Quantization Variation
Student Name: Umar Mustafa
Roll No: 200365
Instructor: Engr. M. Farooq Khan
Problem 2: Sampling variation </h2>
Let us now observe the variation in image perception, when we change the sampling of the image. In this regard, you are required to do the desired tasks,
1. Load the image ‘droplets.jpg’, and convert it from RGB to gray.
2. Now subsample the image by 2. (Take every alternate pixels in rows as well as column)
3. Do you observe any change in the image outlook or your visual perception? Please discuss
4. Repeat step 5 on iteratively twice and for each subsampling result, discuss the variation in the image perception. Can you explain what is happening?
Do you observe any change in the image outlook or your visual perception? Please discuss
the variation in the image perception. Can you explain what is happening?
Yes, there is a change in the image outlook after subsampling the image by 2. The subsampled image has half the dimensions of the original image, and contains only every other pixel in
both the rows and columns of the original image. This results in a loss of detail and sharpness in the subsampled image compared to the original image. The subsampled image may appear
slightly blurry or pixelated, as some of the fine details in the original image have been lost due to downsampling. However, the overall structure and composition of the image should still be
recognizable, and important features such as edges and shapes should still be preserved to some extent.
Problem 3: Quantization variation
Let us now observe the variation in image perception, when we change the quantization of the image. In this regard, you are required to do the desired tasks,
1. Load the image ‘droplets.jpg’ and convert it from RGB to gray.
2. Now reduce the quantization of the image to 6bit. (the pixel mapping goes from 0-63 instead of 0-255)
3. Do you observe any change in the image outlook or your visual perception? Please discuss
4. Repeat step 5 on for 4-bit, 2-bit and 1-bit quantization, and discuss the variation in the image perception. Can you explain what is happening?
Do you observe any change in the image outlook or your visual perception? and discuss
the variation in the image perception. Can you explain what is happening?
When I performed 6-bit quantization on the image, I reduced the number of possible pixel values from 256 (8-bit) to 64 (6-bit). The result is a loss of detail and a more 'blocky' appearance, as
the image is now represented by a smaller set of discrete values. When I repeated the quantization process with lower bit depths (4-bit, 2-bit, and 1-bit), I further reduced the number of
possible pixel values and introduce more quantization artifacts. So I observed low visual quality as I decreased the number of bits used to represent this image.
Conclusion
Subsampling an image by 2 means reducing the dimensions of the image to half in both the rows and columns, resulting in a smaller image with fewer pixels. It can be done using
formulae or libraries in Python.
Subsampling an image can result in a loss of detail and sharpness, and the degree of loss depends on the degree of subsampling.
Libraries such as NumPy and OpenCV make subsampling simpler and more convenient. Overall, subsampling preserves the overall structure and composition of the image, while
sacrificing some fine details in the process.
Quantization is the process of reducing the number of bits used to represent an image's pixel values. This process reduces the image's file size and computational complexity. However, it
also results in a loss of information and visual quality. Higher quantization levels result in greater loss of detail and more significant visual distortions.
In [28]: import matplotlib.pyplot as plt
import numpy as np
import cv2
from IPython import display
from PIL import Image
# Load an image using cv2.imread
img = cv2.imread('F:/imagelab/droplets.jpg')
plt.subplot(331)
plt.imshow(img,cmap = 'gray')
plt.title('Original Image')
# Gray (Gray_Scale color space):
gray_image = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
# Save the image to a file using cv2.imwrite
cv2.imwrite('F:/imagelab/gray.jpg', gray_image)
plt.subplot(332)
plt.imshow(gray_image,cmap = 'gray')
plt.title('Gray Image')
gray_image = np.array(gray_image)
#With Formula
# Subsample the image by a factor of 2
plt.subplot(333)
subsampled2 = gray_image[::2, ::2]
subsampled2 = Image.fromarray(subsampled2)
plt.imshow(subsampled2,cmap = 'gray')
plt.title('Sub Sampled')
# Subsample the image by a factor of 4
plt.subplot(334)
subsampled4 = gray_image[::4, ::4]
subsampled4 = Image.fromarray(subsampled4)
plt.imshow(subsampled4,cmap = 'gray')
plt.title('Sub Sampled4')
# Subsample the image by a factor of 6
plt.subplot(335)
subsampled6 = gray_image[::6, ::6]
subsampled6 = Image.fromarray(subsampled6)
plt.imshow(subsampled6,cmap = 'gray')
plt.title('Sub Sampled6')
#Now without using direct formula
plt.subplot(336)
subsample2 = cv2.resize(gray_image, (gray_image.shape[1]//2, gray_image.shape[0]//2))
plt.imshow(subsample2,cmap = 'gray')
plt.title('Sub Sampled2')
plt.subplot(337)
subsample4 = cv2.resize(gray_image, (gray_image.shape[1]//4, gray_image.shape[0]//4))
plt.imshow(subsample4,cmap = 'gray')
plt.title('Sub Sampled4')
plt.subplot(338)
subsample6 = cv2.resize(gray_image, (gray_image.shape[1]//6, gray_image.shape[0]//6))
plt.imshow(subsample6,cmap = 'gray')
plt.title('Sub Sampled6')
plt.show()
In [29]: # Load an image using cv2.imread
img = cv2.imread('F:/imagelab/droplets.jpg')
plt.subplot(331)
plt.imshow(img,cmap = 'gray')
plt.title('Original Image')
# Gray (Gray_Scale color space):
gray_image = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
# Save the image to a file using cv2.imwrite
cv2.imwrite('F:/imagelab/gray.jpg', gray_image)
plt.subplot(332)
plt.imshow(gray_image,cmap = 'gray')
plt.title('Gray Image')
# 6bit Quantization
r_6bit = (np.asarray(gray_image) >> 2) << 2
r_6bit = Image.fromarray(r_6bit)
plt.subplot(333)
plt.imshow(r_6bit,cmap = 'gray')
plt.title('quantized 6 bit')
# 4bit Quantization
r_4bit = (np.asarray(gray_image) >> 4) << 4
r_4bit = Image.fromarray(r_4bit)
plt.subplot(334)
plt.imshow(r_4bit,cmap = 'gray')
plt.title('quantized 4bit')
# 2bit Quantization
r_2bit = (np.asarray(gray_image) >> 6) << 6
r_2bit = Image.fromarray(r_2bit)
plt.subplot(335)
plt.imshow(r_2bit,cmap = 'gray')
plt.title('quantized 2bit')
# 1bit Quantization
r_1bit = (np.asarray(gray_image) >> 7) << 7
r_1bit = Image.fromarray(r_1bit)
plt.subplot(336)
plt.imshow(r_1bit,cmap = 'gray')
plt.title('quantized 1bit')
plt.show()

More Related Content

Similar to CE344L-200365-Lab4.pdf

Introduction To Digital image Processing
Introduction To Digital image ProcessingIntroduction To Digital image Processing
Introduction To Digital image Processing
MohamedFathy132015
 
Lossless Huffman coding image compression implementation in spatial domain by...
Lossless Huffman coding image compression implementation in spatial domain by...Lossless Huffman coding image compression implementation in spatial domain by...
Lossless Huffman coding image compression implementation in spatial domain by...
IRJET Journal
 
Portfolio for CS 6475 Computational Photography
Portfolio for CS 6475 Computational PhotographyPortfolio for CS 6475 Computational Photography
Portfolio for CS 6475 Computational Photography
Senthilkumar Gopal
 
Can you please separate the code into imagespy sharpenpy.pdf
Can you please separate the code into imagespy sharpenpy.pdfCan you please separate the code into imagespy sharpenpy.pdf
Can you please separate the code into imagespy sharpenpy.pdf
agmbro1
 
An Approach for Image Deblurring: Based on Sparse Representation and Regulari...
An Approach for Image Deblurring: Based on Sparse Representation and Regulari...An Approach for Image Deblurring: Based on Sparse Representation and Regulari...
An Approach for Image Deblurring: Based on Sparse Representation and Regulari...
IRJET Journal
 
An Approach for Image Deblurring: Based on Sparse Representation and Regulari...
An Approach for Image Deblurring: Based on Sparse Representation and Regulari...An Approach for Image Deblurring: Based on Sparse Representation and Regulari...
An Approach for Image Deblurring: Based on Sparse Representation and Regulari...
IRJET Journal
 
IRJET- Coloring Greyscale Images using Deep Learning
IRJET- Coloring Greyscale Images using Deep LearningIRJET- Coloring Greyscale Images using Deep Learning
IRJET- Coloring Greyscale Images using Deep Learning
IRJET Journal
 
Image proccessing and its applications.
Image proccessing and its applications.Image proccessing and its applications.
Image proccessing and its applications.
Ashwini Awatare
 
Image processing sw & hw
Image processing sw & hwImage processing sw & hw
Image processing sw & hw
amalalhait
 
An introduction to super resolution using deep learning
An introduction to super resolution using deep learningAn introduction to super resolution using deep learning
An introduction to super resolution using deep learning
Anil Chandra Naidu Matcha
 
Comparative between global threshold and adaptative threshold concepts in ima...
Comparative between global threshold and adaptative threshold concepts in ima...Comparative between global threshold and adaptative threshold concepts in ima...
Comparative between global threshold and adaptative threshold concepts in ima...
AssiaHAMZA
 
Image enhancement lecture
Image enhancement lectureImage enhancement lecture
Image enhancement lecture
ISRAR HUSSAIN
 
Paper id 25201490
Paper id 25201490Paper id 25201490
Paper id 25201490
IJRAT
 
Information search using text and image query
Information search using text and image queryInformation search using text and image query
Information search using text and image query
eSAT Publishing House
 
IRJET- Low Light Image Enhancement using Convolutional Neural Network
IRJET-  	  Low Light Image Enhancement using Convolutional Neural NetworkIRJET-  	  Low Light Image Enhancement using Convolutional Neural Network
IRJET- Low Light Image Enhancement using Convolutional Neural Network
IRJET Journal
 
Information search using text and image query
Information search using text and image queryInformation search using text and image query
Information search using text and image query
eSAT Journals
 
A modified symmetric local binary pattern for image features extraction
A modified symmetric local binary pattern for image features extractionA modified symmetric local binary pattern for image features extraction
A modified symmetric local binary pattern for image features extraction
TELKOMNIKA JOURNAL
 
[IJET-V1I6P16] Authors : Indraja Mali , Saumya Saxena ,Padmaja Desai , Ajay G...
[IJET-V1I6P16] Authors : Indraja Mali , Saumya Saxena ,Padmaja Desai , Ajay G...[IJET-V1I6P16] Authors : Indraja Mali , Saumya Saxena ,Padmaja Desai , Ajay G...
[IJET-V1I6P16] Authors : Indraja Mali , Saumya Saxena ,Padmaja Desai , Ajay G...
IJET - International Journal of Engineering and Techniques
 
A Closed-form Solution to Photorealistic Image Stylization
A Closed-form Solution to Photorealistic Image StylizationA Closed-form Solution to Photorealistic Image Stylization
A Closed-form Solution to Photorealistic Image Stylization
SherozbekJumaboev
 
ee8220_project_W2013_v5
ee8220_project_W2013_v5ee8220_project_W2013_v5
ee8220_project_W2013_v5
Farhad Gholami
 

Similar to CE344L-200365-Lab4.pdf (20)

Introduction To Digital image Processing
Introduction To Digital image ProcessingIntroduction To Digital image Processing
Introduction To Digital image Processing
 
Lossless Huffman coding image compression implementation in spatial domain by...
Lossless Huffman coding image compression implementation in spatial domain by...Lossless Huffman coding image compression implementation in spatial domain by...
Lossless Huffman coding image compression implementation in spatial domain by...
 
Portfolio for CS 6475 Computational Photography
Portfolio for CS 6475 Computational PhotographyPortfolio for CS 6475 Computational Photography
Portfolio for CS 6475 Computational Photography
 
Can you please separate the code into imagespy sharpenpy.pdf
Can you please separate the code into imagespy sharpenpy.pdfCan you please separate the code into imagespy sharpenpy.pdf
Can you please separate the code into imagespy sharpenpy.pdf
 
An Approach for Image Deblurring: Based on Sparse Representation and Regulari...
An Approach for Image Deblurring: Based on Sparse Representation and Regulari...An Approach for Image Deblurring: Based on Sparse Representation and Regulari...
An Approach for Image Deblurring: Based on Sparse Representation and Regulari...
 
An Approach for Image Deblurring: Based on Sparse Representation and Regulari...
An Approach for Image Deblurring: Based on Sparse Representation and Regulari...An Approach for Image Deblurring: Based on Sparse Representation and Regulari...
An Approach for Image Deblurring: Based on Sparse Representation and Regulari...
 
IRJET- Coloring Greyscale Images using Deep Learning
IRJET- Coloring Greyscale Images using Deep LearningIRJET- Coloring Greyscale Images using Deep Learning
IRJET- Coloring Greyscale Images using Deep Learning
 
Image proccessing and its applications.
Image proccessing and its applications.Image proccessing and its applications.
Image proccessing and its applications.
 
Image processing sw & hw
Image processing sw & hwImage processing sw & hw
Image processing sw & hw
 
An introduction to super resolution using deep learning
An introduction to super resolution using deep learningAn introduction to super resolution using deep learning
An introduction to super resolution using deep learning
 
Comparative between global threshold and adaptative threshold concepts in ima...
Comparative between global threshold and adaptative threshold concepts in ima...Comparative between global threshold and adaptative threshold concepts in ima...
Comparative between global threshold and adaptative threshold concepts in ima...
 
Image enhancement lecture
Image enhancement lectureImage enhancement lecture
Image enhancement lecture
 
Paper id 25201490
Paper id 25201490Paper id 25201490
Paper id 25201490
 
Information search using text and image query
Information search using text and image queryInformation search using text and image query
Information search using text and image query
 
IRJET- Low Light Image Enhancement using Convolutional Neural Network
IRJET-  	  Low Light Image Enhancement using Convolutional Neural NetworkIRJET-  	  Low Light Image Enhancement using Convolutional Neural Network
IRJET- Low Light Image Enhancement using Convolutional Neural Network
 
Information search using text and image query
Information search using text and image queryInformation search using text and image query
Information search using text and image query
 
A modified symmetric local binary pattern for image features extraction
A modified symmetric local binary pattern for image features extractionA modified symmetric local binary pattern for image features extraction
A modified symmetric local binary pattern for image features extraction
 
[IJET-V1I6P16] Authors : Indraja Mali , Saumya Saxena ,Padmaja Desai , Ajay G...
[IJET-V1I6P16] Authors : Indraja Mali , Saumya Saxena ,Padmaja Desai , Ajay G...[IJET-V1I6P16] Authors : Indraja Mali , Saumya Saxena ,Padmaja Desai , Ajay G...
[IJET-V1I6P16] Authors : Indraja Mali , Saumya Saxena ,Padmaja Desai , Ajay G...
 
A Closed-form Solution to Photorealistic Image Stylization
A Closed-form Solution to Photorealistic Image StylizationA Closed-form Solution to Photorealistic Image Stylization
A Closed-form Solution to Photorealistic Image Stylization
 
ee8220_project_W2013_v5
ee8220_project_W2013_v5ee8220_project_W2013_v5
ee8220_project_W2013_v5
 

More from UmarMustafa13

CEA Technical English.pptx
CEA Technical English.pptxCEA Technical English.pptx
CEA Technical English.pptx
UmarMustafa13
 
CEA-3-Activity.pptx
CEA-3-Activity.pptxCEA-3-Activity.pptx
CEA-3-Activity.pptx
UmarMustafa13
 
CE344L-200365-Lab2.pdf
CE344L-200365-Lab2.pdfCE344L-200365-Lab2.pdf
CE344L-200365-Lab2.pdf
UmarMustafa13
 
CE344L-200365-Lab7.pdf
CE344L-200365-Lab7.pdfCE344L-200365-Lab7.pdf
CE344L-200365-Lab7.pdf
UmarMustafa13
 
CE344L-200365-Lab5.pdf
CE344L-200365-Lab5.pdfCE344L-200365-Lab5.pdf
CE344L-200365-Lab5.pdf
UmarMustafa13
 
CE344L-200365-Lab6.pdf
CE344L-200365-Lab6.pdfCE344L-200365-Lab6.pdf
CE344L-200365-Lab6.pdf
UmarMustafa13
 
CE344L-200365-Lab3.pdf
CE344L-200365-Lab3.pdfCE344L-200365-Lab3.pdf
CE344L-200365-Lab3.pdf
UmarMustafa13
 
CE344L-200365-Lab8.pdf
CE344L-200365-Lab8.pdfCE344L-200365-Lab8.pdf
CE344L-200365-Lab8.pdf
UmarMustafa13
 

More from UmarMustafa13 (8)

CEA Technical English.pptx
CEA Technical English.pptxCEA Technical English.pptx
CEA Technical English.pptx
 
CEA-3-Activity.pptx
CEA-3-Activity.pptxCEA-3-Activity.pptx
CEA-3-Activity.pptx
 
CE344L-200365-Lab2.pdf
CE344L-200365-Lab2.pdfCE344L-200365-Lab2.pdf
CE344L-200365-Lab2.pdf
 
CE344L-200365-Lab7.pdf
CE344L-200365-Lab7.pdfCE344L-200365-Lab7.pdf
CE344L-200365-Lab7.pdf
 
CE344L-200365-Lab5.pdf
CE344L-200365-Lab5.pdfCE344L-200365-Lab5.pdf
CE344L-200365-Lab5.pdf
 
CE344L-200365-Lab6.pdf
CE344L-200365-Lab6.pdfCE344L-200365-Lab6.pdf
CE344L-200365-Lab6.pdf
 
CE344L-200365-Lab3.pdf
CE344L-200365-Lab3.pdfCE344L-200365-Lab3.pdf
CE344L-200365-Lab3.pdf
 
CE344L-200365-Lab8.pdf
CE344L-200365-Lab8.pdfCE344L-200365-Lab8.pdf
CE344L-200365-Lab8.pdf
 

Recently uploaded

ML Based Model for NIDS MSc Updated Presentation.v2.pptx
ML Based Model for NIDS MSc Updated Presentation.v2.pptxML Based Model for NIDS MSc Updated Presentation.v2.pptx
ML Based Model for NIDS MSc Updated Presentation.v2.pptx
JamalHussainArman
 
spirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptxspirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptx
Madan Karki
 
Textile Chemical Processing and Dyeing.pdf
Textile Chemical Processing and Dyeing.pdfTextile Chemical Processing and Dyeing.pdf
Textile Chemical Processing and Dyeing.pdf
NazakatAliKhoso2
 
CSM Cloud Service Management Presentarion
CSM Cloud Service Management PresentarionCSM Cloud Service Management Presentarion
CSM Cloud Service Management Presentarion
rpskprasana
 
Eric Nizeyimana's document 2006 from gicumbi to ttc nyamata handball play
Eric Nizeyimana's document 2006 from gicumbi to ttc nyamata handball playEric Nizeyimana's document 2006 from gicumbi to ttc nyamata handball play
Eric Nizeyimana's document 2006 from gicumbi to ttc nyamata handball play
enizeyimana36
 
Casting-Defect-inSlab continuous casting.pdf
Casting-Defect-inSlab continuous casting.pdfCasting-Defect-inSlab continuous casting.pdf
Casting-Defect-inSlab continuous casting.pdf
zubairahmad848137
 
The Python for beginners. This is an advance computer language.
The Python for beginners. This is an advance computer language.The Python for beginners. This is an advance computer language.
The Python for beginners. This is an advance computer language.
sachin chaurasia
 
TIME DIVISION MULTIPLEXING TECHNIQUE FOR COMMUNICATION SYSTEM
TIME DIVISION MULTIPLEXING TECHNIQUE FOR COMMUNICATION SYSTEMTIME DIVISION MULTIPLEXING TECHNIQUE FOR COMMUNICATION SYSTEM
TIME DIVISION MULTIPLEXING TECHNIQUE FOR COMMUNICATION SYSTEM
HODECEDSIET
 
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Sinan KOZAK
 
Recycled Concrete Aggregate in Construction Part II
Recycled Concrete Aggregate in Construction Part IIRecycled Concrete Aggregate in Construction Part II
Recycled Concrete Aggregate in Construction Part II
Aditya Rajan Patra
 
Modelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdfModelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdf
camseq
 
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
171ticu
 
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
insn4465
 
官方认证美国密歇根州立大学毕业证学位证书原版一模一样
官方认证美国密歇根州立大学毕业证学位证书原版一模一样官方认证美国密歇根州立大学毕业证学位证书原版一模一样
官方认证美国密歇根州立大学毕业证学位证书原版一模一样
171ticu
 
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODELDEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
gerogepatton
 
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
IJECEIAES
 
Engineering Drawings Lecture Detail Drawings 2014.pdf
Engineering Drawings Lecture Detail Drawings 2014.pdfEngineering Drawings Lecture Detail Drawings 2014.pdf
Engineering Drawings Lecture Detail Drawings 2014.pdf
abbyasa1014
 
Properties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptxProperties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptx
MDSABBIROJJAMANPAYEL
 
Embedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoringEmbedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoring
IJECEIAES
 
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student MemberIEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
VICTOR MAESTRE RAMIREZ
 

Recently uploaded (20)

ML Based Model for NIDS MSc Updated Presentation.v2.pptx
ML Based Model for NIDS MSc Updated Presentation.v2.pptxML Based Model for NIDS MSc Updated Presentation.v2.pptx
ML Based Model for NIDS MSc Updated Presentation.v2.pptx
 
spirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptxspirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptx
 
Textile Chemical Processing and Dyeing.pdf
Textile Chemical Processing and Dyeing.pdfTextile Chemical Processing and Dyeing.pdf
Textile Chemical Processing and Dyeing.pdf
 
CSM Cloud Service Management Presentarion
CSM Cloud Service Management PresentarionCSM Cloud Service Management Presentarion
CSM Cloud Service Management Presentarion
 
Eric Nizeyimana's document 2006 from gicumbi to ttc nyamata handball play
Eric Nizeyimana's document 2006 from gicumbi to ttc nyamata handball playEric Nizeyimana's document 2006 from gicumbi to ttc nyamata handball play
Eric Nizeyimana's document 2006 from gicumbi to ttc nyamata handball play
 
Casting-Defect-inSlab continuous casting.pdf
Casting-Defect-inSlab continuous casting.pdfCasting-Defect-inSlab continuous casting.pdf
Casting-Defect-inSlab continuous casting.pdf
 
The Python for beginners. This is an advance computer language.
The Python for beginners. This is an advance computer language.The Python for beginners. This is an advance computer language.
The Python for beginners. This is an advance computer language.
 
TIME DIVISION MULTIPLEXING TECHNIQUE FOR COMMUNICATION SYSTEM
TIME DIVISION MULTIPLEXING TECHNIQUE FOR COMMUNICATION SYSTEMTIME DIVISION MULTIPLEXING TECHNIQUE FOR COMMUNICATION SYSTEM
TIME DIVISION MULTIPLEXING TECHNIQUE FOR COMMUNICATION SYSTEM
 
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
 
Recycled Concrete Aggregate in Construction Part II
Recycled Concrete Aggregate in Construction Part IIRecycled Concrete Aggregate in Construction Part II
Recycled Concrete Aggregate in Construction Part II
 
Modelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdfModelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdf
 
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
 
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
 
官方认证美国密歇根州立大学毕业证学位证书原版一模一样
官方认证美国密歇根州立大学毕业证学位证书原版一模一样官方认证美国密歇根州立大学毕业证学位证书原版一模一样
官方认证美国密歇根州立大学毕业证学位证书原版一模一样
 
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODELDEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
 
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
 
Engineering Drawings Lecture Detail Drawings 2014.pdf
Engineering Drawings Lecture Detail Drawings 2014.pdfEngineering Drawings Lecture Detail Drawings 2014.pdf
Engineering Drawings Lecture Detail Drawings 2014.pdf
 
Properties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptxProperties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptx
 
Embedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoringEmbedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoring
 
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student MemberIEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
 

CE344L-200365-Lab4.pdf

  • 1. AIR UNIVERSITY Department of Electrical and Computer Engineering Digital Image Processing Lab Lab #4: Sampling and Quantization Variation Student Name: Umar Mustafa Roll No: 200365 Instructor: Engr. M. Farooq Khan Problem 2: Sampling variation </h2> Let us now observe the variation in image perception, when we change the sampling of the image. In this regard, you are required to do the desired tasks, 1. Load the image ‘droplets.jpg’, and convert it from RGB to gray. 2. Now subsample the image by 2. (Take every alternate pixels in rows as well as column) 3. Do you observe any change in the image outlook or your visual perception? Please discuss 4. Repeat step 5 on iteratively twice and for each subsampling result, discuss the variation in the image perception. Can you explain what is happening? Do you observe any change in the image outlook or your visual perception? Please discuss the variation in the image perception. Can you explain what is happening? Yes, there is a change in the image outlook after subsampling the image by 2. The subsampled image has half the dimensions of the original image, and contains only every other pixel in both the rows and columns of the original image. This results in a loss of detail and sharpness in the subsampled image compared to the original image. The subsampled image may appear slightly blurry or pixelated, as some of the fine details in the original image have been lost due to downsampling. However, the overall structure and composition of the image should still be recognizable, and important features such as edges and shapes should still be preserved to some extent. Problem 3: Quantization variation Let us now observe the variation in image perception, when we change the quantization of the image. In this regard, you are required to do the desired tasks, 1. Load the image ‘droplets.jpg’ and convert it from RGB to gray. 2. Now reduce the quantization of the image to 6bit. (the pixel mapping goes from 0-63 instead of 0-255) 3. Do you observe any change in the image outlook or your visual perception? Please discuss 4. Repeat step 5 on for 4-bit, 2-bit and 1-bit quantization, and discuss the variation in the image perception. Can you explain what is happening? Do you observe any change in the image outlook or your visual perception? and discuss the variation in the image perception. Can you explain what is happening? When I performed 6-bit quantization on the image, I reduced the number of possible pixel values from 256 (8-bit) to 64 (6-bit). The result is a loss of detail and a more 'blocky' appearance, as the image is now represented by a smaller set of discrete values. When I repeated the quantization process with lower bit depths (4-bit, 2-bit, and 1-bit), I further reduced the number of possible pixel values and introduce more quantization artifacts. So I observed low visual quality as I decreased the number of bits used to represent this image. Conclusion Subsampling an image by 2 means reducing the dimensions of the image to half in both the rows and columns, resulting in a smaller image with fewer pixels. It can be done using formulae or libraries in Python. Subsampling an image can result in a loss of detail and sharpness, and the degree of loss depends on the degree of subsampling. Libraries such as NumPy and OpenCV make subsampling simpler and more convenient. Overall, subsampling preserves the overall structure and composition of the image, while sacrificing some fine details in the process. Quantization is the process of reducing the number of bits used to represent an image's pixel values. This process reduces the image's file size and computational complexity. However, it also results in a loss of information and visual quality. Higher quantization levels result in greater loss of detail and more significant visual distortions. In [28]: import matplotlib.pyplot as plt import numpy as np import cv2 from IPython import display from PIL import Image # Load an image using cv2.imread img = cv2.imread('F:/imagelab/droplets.jpg') plt.subplot(331) plt.imshow(img,cmap = 'gray') plt.title('Original Image') # Gray (Gray_Scale color space): gray_image = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) # Save the image to a file using cv2.imwrite cv2.imwrite('F:/imagelab/gray.jpg', gray_image) plt.subplot(332) plt.imshow(gray_image,cmap = 'gray') plt.title('Gray Image') gray_image = np.array(gray_image) #With Formula # Subsample the image by a factor of 2 plt.subplot(333) subsampled2 = gray_image[::2, ::2] subsampled2 = Image.fromarray(subsampled2) plt.imshow(subsampled2,cmap = 'gray') plt.title('Sub Sampled') # Subsample the image by a factor of 4 plt.subplot(334) subsampled4 = gray_image[::4, ::4] subsampled4 = Image.fromarray(subsampled4) plt.imshow(subsampled4,cmap = 'gray') plt.title('Sub Sampled4') # Subsample the image by a factor of 6 plt.subplot(335) subsampled6 = gray_image[::6, ::6] subsampled6 = Image.fromarray(subsampled6) plt.imshow(subsampled6,cmap = 'gray') plt.title('Sub Sampled6') #Now without using direct formula plt.subplot(336) subsample2 = cv2.resize(gray_image, (gray_image.shape[1]//2, gray_image.shape[0]//2)) plt.imshow(subsample2,cmap = 'gray') plt.title('Sub Sampled2') plt.subplot(337) subsample4 = cv2.resize(gray_image, (gray_image.shape[1]//4, gray_image.shape[0]//4)) plt.imshow(subsample4,cmap = 'gray') plt.title('Sub Sampled4') plt.subplot(338) subsample6 = cv2.resize(gray_image, (gray_image.shape[1]//6, gray_image.shape[0]//6)) plt.imshow(subsample6,cmap = 'gray') plt.title('Sub Sampled6') plt.show() In [29]: # Load an image using cv2.imread img = cv2.imread('F:/imagelab/droplets.jpg') plt.subplot(331) plt.imshow(img,cmap = 'gray') plt.title('Original Image') # Gray (Gray_Scale color space): gray_image = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) # Save the image to a file using cv2.imwrite cv2.imwrite('F:/imagelab/gray.jpg', gray_image) plt.subplot(332) plt.imshow(gray_image,cmap = 'gray') plt.title('Gray Image') # 6bit Quantization r_6bit = (np.asarray(gray_image) >> 2) << 2 r_6bit = Image.fromarray(r_6bit) plt.subplot(333) plt.imshow(r_6bit,cmap = 'gray') plt.title('quantized 6 bit') # 4bit Quantization r_4bit = (np.asarray(gray_image) >> 4) << 4 r_4bit = Image.fromarray(r_4bit) plt.subplot(334) plt.imshow(r_4bit,cmap = 'gray') plt.title('quantized 4bit') # 2bit Quantization r_2bit = (np.asarray(gray_image) >> 6) << 6 r_2bit = Image.fromarray(r_2bit) plt.subplot(335) plt.imshow(r_2bit,cmap = 'gray') plt.title('quantized 2bit') # 1bit Quantization r_1bit = (np.asarray(gray_image) >> 7) << 7 r_1bit = Image.fromarray(r_1bit) plt.subplot(336) plt.imshow(r_1bit,cmap = 'gray') plt.title('quantized 1bit') plt.show()