SlideShare a Scribd company logo
1 of 1
Download to read offline
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

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.pdfagmbro1
 
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 LearningIRJET 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 & hwamalalhait
 
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 learningAnil 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 lectureISRAR HUSSAIN
 
Paper id 25201490
Paper id 25201490Paper id 25201490
Paper id 25201490IJRAT
 
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 queryeSAT 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 NetworkIRJET 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 queryeSAT 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 extractionTELKOMNIKA JOURNAL
 
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 StylizationSherozbekJumaboev
 
ee8220_project_W2013_v5
ee8220_project_W2013_v5ee8220_project_W2013_v5
ee8220_project_W2013_v5Farhad Gholami
 
image compression using matlab project report
image compression  using matlab project reportimage compression  using matlab project report
image compression using matlab project reportkgaurav113
 
Photoshop_CS3_Review
Photoshop_CS3_ReviewPhotoshop_CS3_Review
Photoshop_CS3_Reviewtutorialsruby
 
Photoshop_CS3_Review
Photoshop_CS3_ReviewPhotoshop_CS3_Review
Photoshop_CS3_Reviewtutorialsruby
 

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

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
 
image compression using matlab project report
image compression  using matlab project reportimage compression  using matlab project report
image compression using matlab project report
 
Photoshop_CS3_Review
Photoshop_CS3_ReviewPhotoshop_CS3_Review
Photoshop_CS3_Review
 
Photoshop_CS3_Review
Photoshop_CS3_ReviewPhotoshop_CS3_Review
Photoshop_CS3_Review
 

More from UmarMustafa13

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

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

(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Serviceranjana rawat
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...ranjana rawat
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
Analog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog ConverterAnalog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog ConverterAbhinavSharma374939
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Christo Ananth
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptxthe ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptxhumanexperienceaaa
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidNikhilNagaraju
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxwendy cai
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingrakeshbaidya232001
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxupamatechverse
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations120cr0395
 

Recently uploaded (20)

(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
Analog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog ConverterAnalog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog Converter
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptxthe ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfid
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptx
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writing
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptx
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations
 

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()