1.
Quantization Levels (Gray Level Resolution)
(a) MATLAB Code for 4-Level Quantization
b=imread("C:\Users\devpa\OneDrive\Desktop\[Link]");
a=rgb2gray(b);
subplot(2,2,1)
imshow(a);
title('Original Image');
subplot(2,2,2)
imhist(a);
title('Histogram of Original Image');
[m,n] = size(a);
for i = 1:m
for j = 1:n
if a(i,j) < 64
a(i,j) = 32;
elseif a(i,j) < 128
a(i,j) = 96;
elseif a(i,j) < 192
a(i,j) = 160;
else
a(i,j) = 224;
end
end
end
subplot(2,2,3)
imshow(a);
title('Quantized Image (4 Levels)');
subplot(2,2,4)
imhist(a);
title('Histogram of Quantized Image');
(b) Observation
When the image is quantized to only 4 gray levels, the image appears highly distorted compared to the 16-level
quantized image. Fine details and smooth shading are lost, and false contouring becomes clearly visible. The
image looks more like a posterized or cartoon-like image.
(c) Concept: Bit Depth Reduction
Reducing the number of gray levels from 16 levels (4-bit) to 4 levels (2-bit) is called bit depth reduction.
Lower bit depth reduces the amount of information per pixel, resulting in loss of image details and visual
quality.
2. Difference Between Sampling and Quantization
Sampling Quantization
Divides the image in spatial domain Divides the image in intensity domain
Affects number of pixels Affects gray levels
Changes image resolution Changes image contrast levels
Related to pixel spacing Related to pixel intensity
Example: resizing image Example: 256 → 16 gray levels
3. Effect of Up-Sampling an Image
Up-sampling increases the number of pixels in an image by inserting new pixels between existing ones using
interpolation methods.
Effects of Up-Sampling:
Image size increases
No new details are added
Image may appear blurred
Edges may become smooth but not sharper
Conclusion:
Up-sampling improves image size for display purposes but cannot recover lost information.