0% found this document useful (0 votes)
15 views7 pages

NM Week1 Final

The document outlines a basic image processing experiment using MATLAB, detailing objectives such as importing images, visualizing data, and performing operations like sampling, quantization, enhancement, and transformations. It includes code snippets for various tasks, including edge detection and frequency analysis. The results indicate successful execution of image operations and insights gained from frequency and wavelet analyses.

Uploaded by

22l121
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)
15 views7 pages

NM Week1 Final

The document outlines a basic image processing experiment using MATLAB, detailing objectives such as importing images, visualizing data, and performing operations like sampling, quantization, enhancement, and transformations. It includes code snippets for various tasks, including edge detection and frequency analysis. The results indicate successful execution of image operations and insights gained from frequency and wavelet analyses.

Uploaded by

22l121
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
You are on page 1/ 7

Exp 1 Basic Image Processing Using MATLAB

27/2/25

OBJECTIVE:
To perform the following Operations on images using MATLAB
Software: I. Importing an image
II. Visualizing and Extracting Information from Images
III. Sampling & Quantisation of Images
IV. Image Enhancement
V. Image Blurring Image Deblurring RGB Conversion
VI. Grayscale Conversion of Images Discrete Wavelet Transform
VII. Discrete Fourier Transform

PROCEDURE:
• Load and display the image using imread and imshow.

• Extract image properties like size, data type, and number of channels. •

Convert RGB to grayscale using rgb2gray and to binary using imbinarize.

• Perform sampling by reducing resolution and apply quantization to limit intensity


levels.
• Access and modify specific pixel values using matrix indexing.

• Enhance images with histogram equalization and blur using Gaussian filter. •

Restore blurred images using Wiener deconvolution with a motion PSF. • Apply
geometric transformations like rotation using imrotate.

• Use dwt2 to decompose images into wavelet subbands (LL, LH, HL, HH). •

Apply fft2 and fftshift to visualize frequency components.

• Detect edges with Sobel operator and segment objects using thresholding.
1. Import – Visualize and Extract Information from Images
CODE:
% Load an image
img = imread('img1.png');

% Display the image


figure;
imshow(img);
title('Original Image');

% Extract image information


disp('Image Information:');
disp(['Size: ', num2str(size(img))]);
disp(['Data Type: ', class(img)]);
disp(['Color Channels: ', num2str(size(img, 3))]);

2. Sampling & Quantization of Images


CODE:
% Load an image (ensure it's in the workspace)
img = imread('img1.png');
gray_img = rgb2gray(img); % Convert to grayscale for simplicity

% Define quantization levels (e.g., 4 levels)


quant_levels = 4;

% Step 1: Normalize image to [0, 1] and scale to quant_levels


normalized_img = double(gray_img) / 255; % Range: 0 to 1
quantized_img = round(normalized_img * (quant_levels - 1)) /
(quant_levels - 1);

% Step 2: Scale back to 0-255 for display


quantized_img = uint8(quantized_img * 255);

% Display original vs. quantized


figure;
subplot(1,2,1); imshow(gray_img); title('Original Grayscale');
subplot(1,2,2); imshow(quantized_img); title(['Quantized (',
num2str(quant_levels), ' Levels)']);
colormap(gray); % Ensures grayscale display
1. OUTPUT: Visualize and Extract Information from Images

2. OUTPUT: Sampling & Quantization of Images

3. OUTPUT: Pixels & Operations on Pixels


3. Pixels & Operations on Pixels
CODE:
% Load the image
img = imread('img1.png');

% Access a specific pixel value (row 100, column 150)


pixel_value = img(100, 150, :);

% Modify pixel value (change to red)


img(100, 150, 1) = 255; % Red channel
img(100, 150, 2) = 0; % Green channel
img(100, 150, 3) = 0; % Blue channel

% Display modified image


figure;
imshow(img);
title('Modified Pixel at (100,150) to Red');

4. Image Enhancement – Image Blurring – Image Deblurring – Transformation


CODE:
% Load the image
img = imread('img1.png');
gray_img = rgb2gray(img);

% Image Blurring using Gaussian filter


blurred_img = imgaussfilt(gray_img, 2);

% Deblurring using Wiener filter


PSF = fspecial('motion', 11, 45);
deblurred_img = deconvwnr(blurred_img, PSF);

% Transformation - Rotate Image


rotated_img = imrotate(gray_img, 45);

% Display results
figure;
subplot(2,2,1); imshow(gray_img); title('Original');
subplot(2,2,2); imshow(blurred_img); title('Blurred');
subplot(2,2,3); imshow(deblurred_img); title('Deblurred');
subplot(2,2,4); imshow(rotated_img); title('Rotated');

5. RGB Conversion – Grey Scale Conversion of Images


CODE:
% Load image
img = imread('img1.png');

% Convert to grayscale
gray_img = rgb2gray(img);
4.OUTPUT: Image Enhancement – Image Blurring – Image Deblurring
– Transformation

5.OUTPUT: RGB Conversion – Grey Scale Conversion of Images

6. OUTPUT: Discrete Wavelet Transform – Discrete Fourier Transform


% Convert grayscale to binary image
binary_img = imbinarize(gray_img);

% Display images
figure;
subplot(1,3,1); imshow(img); title('RGB Image');
subplot(1,3,2); imshow(gray_img); title('Grayscale Image');
subplot(1,3,3); imshow(binary_img); title('Binary Image');

6. Discrete Wavelet Transform – Discrete Fourier Transform


CODE:
% Load grayscale image
img = imread('img1.png');
gray_img = rgb2gray(img);

% Discrete Wavelet Transform (DWT)


[LL, LH, HL, HH] = dwt2(double(gray_img), 'haar');

% Display DWT subbands


figure;
subplot(2,2,1); imshow(uint8(LL)); title('Approximation (LL)');
subplot(2,2,2); imshow(uint8(LH)); title('Horizontal Detail (LH)');
subplot(2,2,3); imshow(uint8(HL)); title('Vertical Detail (HL)');
subplot(2,2,4); imshow(uint8(HH)); title('Diagonal Detail (HH)');

% Discrete Fourier Transform (DFT)


fft_img = fft2(double(gray_img));
fft_img_shifted = fftshift(fft_img);
magnitude = log(1 + abs(fft_img_shifted));

% Display Fourier magnitude spectrum


figure;
imshow(mat2gray(magnitude)); title('DFT Magnitude Spectrum');

7. Algorithmic Applications on Images


CODE:
% Load grayscale image
img = imread('img1.png');
gray_img = rgb2gray(img);
% Edge Detection using Sobel operator
edges = edge(gray_img, 'sobel');
% Thresholding for object segmentation
threshold_value = 100;
binary_img = gray_img > threshold_value;
% Display result
figure;
subplot(1,2,1); imshow(edges); title('Edge Detection');
subplot(1,2,2); imshow(binary_img); title('Thresholded Image');
7. OUTPUT: Algorithmic Applications on Images

RESULT:
Basic image operations like loading, visualization, sampling, and enhancement were
performed. Different image formats and transformations were explored. Frequency
and wavelet analyses provided deeper image insights.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy