FIP 1st Experiment - MATLAB Image Processing PDF

Summary

This document is a set of MATLAB experiments focusing on image processing techniques. The experiments cover topics such as reading, writing, displaying, resizing, and color conversions of images, along with wave generation and use of MATLAB commands and functions. Results from the experiments are included.

Full Transcript

DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Experiment1 Student Name: Sourov Kumar Nandi UID: 22BCS14169 Branch: BE-CSE Section/Group: NTPP-903(B) Semester: 5th D...

DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Experiment1 Student Name: Sourov Kumar Nandi UID: 22BCS14169 Branch: BE-CSE Section/Group: NTPP-903(B) Semester: 5th Date of Performance: /07/24 Subject Name: FIP Subject Code: 22CST-317 1. Aim: Experiment 1: Introduction to MATLAB. Experiment 2: Introduction to the Image Processing Toolbox of MATLAB. Experiment 3: Extracting Image Properties using MATLAB. 2. Requirements (Hardware/Software): 1. Laptop / Computer 2. Internet Connection 3. MATLAB Software or Online MATLAB 3. Implementation: Code: disp("Operation"); a=10; b=12; disp("Add"); c=a+b; disp(c); disp("Subtract"); c=a-b; disp(c); DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING disp("Multiply"); c=a*b; disp(c); disp("Divide"); c=a/b; disp(c); disp("Reminder"); c=rem(a,b); disp(c); Output: Code: name="Sourov"; age=22; uid=14169; disp(['Name :',num2str(name)]); disp(['Age :',num2str(age)]); disp(['UID :',num2str(uid)]); % Use of fprintf fprintf(['My Name is ',num2str(name),' ,Age is ',num2str(age),' ,University ID is ',num2str(uid)]); DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Output: Code: photo = imread("images.jpeg"); imshow(photo); title("Me"); Output: DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING 4. Learning Outcome: ❖ Learn fundamentals of image processing. ❖ Working with the MATLAB user interface ❖ Learn about different command ❖ Learn about the MATLAB toolbox ❖ Know about photo properties DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Experiment-2 Student Name: Sourov Kumar Nandi UID: 22BCS14169 Branch: BE-CSE Section/Group: NTPP-903(B) Semester: 5th Date of Performance: /07/24 Subject Name: FIP Subject Code: 22CST-317 1. Aim: Experiment 4: Reading and Writing Images using MATLAB Experiment 5: Displaying Images using MATLAB Experiment 6: Conversions of images from one format to another using MATLAB 2. Requirements (Hardware/Software): 1. Laptop / Computer 2. Internet Connection 3. MATLAB Software or Online MATLAB 4. Some Downloaded Photos 3. Implementation: Code: photo = imread("images.jpeg"); imshow(photo); title("Me"); Output: DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Code: photo = imread("dfngfjk.jpg"); imshow(photo); title("you"); Output: DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Code: photo = imread("images.jpeg"); imshow(photo); title("Me"); Output: Code: photo = imread("download.jpeg"); imshow(photo); photo1 = imread("images.jpeg"); imshow(photo1); photo2 = imread("dfngfjk.jpg"); imshow(photo2); subplot(3,1,1); imshow(photo); subplot(3,1,2); imshow(photo1); subplot(3,1,3); imshow(photo2); DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Output: Code: photo = imread("images.jpeg"); imshow(photo); red = photo(:,:,1); green=photo(:,:,2); blue=photo(:,:,3); figure,imshow(red); figure,imshow(blue); figure,imshow(green); DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Output: Code: photo = imread("images.jpeg"); imshow(photo); red = photo(:,:,1); green=photo(:,:,2); blue=photo(:,:,3); figure,imhist(red); figure,imhist(blue); figure,imhist(green); Output: Save a photo: saveas(gcf,'original.png'); DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Code: photo = imread("images.jpeg"); imshow(photo); value=photo(50,50,:); disp(num2str(value(:))); % Another Method disp(['The result is: [' num2str(value(:).') ']']) ; Output: Code: photo = imread("images.jpeg"); imshow(photo); area=photo(60:120,80:100); figure,imshow(area); Output: DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING 4. Learning Outcome: ❖ Learn fundamentals of image processing. ❖ Working with the MATLAB user interface ❖ Learn about different command ❖ Learn about the MATLAB toolbox ❖ Know about photo properties DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Experiment-7 Student Name: Sourov Kumar Nandi UID: 22BCS14169 Branch: BE-CSE Section/Group: NTPP-903(B) Semester: 5th Date of Performance:08/08/24 Subject Name: FIP Subject Code: 22CST-317 1. Aim: Resizing images by inbuilt commands. 2. Requirements (Hardware/Software): 1. Laptop / Computer 2. Internet Connection 3. MATLAB Software or Online MATLAB 4. Download the image from the site. 3. Implementation: Code: # Half Image: photo=imread("angel.jpg"); resize1=imresize(photo,0.5); imshow(resize1); title("Anime"); saveas(gcf,"half.png"); Output: DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Code: #Double Photo : p=imread("angel.jpg"); resize2=imresize(p,2.0); imshow(resize2); title("Large _ Anime"); saveas(gcf,"double.png"); Output: #Rand: photo=rand(10,10,3); imshow(photo); DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Learning Outcome: ❖ Learn fundamentals of image processing. ❖ Working with the MATLAB user interface ❖ Learn about different command ❖ Learn about the MATLAB toolbox ❖ Know about photo properties DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Experiment-8 Student Name: Sourov Kumar Nandi UID: 22BCS14169 Branch: BE-CSE Section/Group: NTPP-903(B) Semester: 5th Date of Performance:14/08/24 Subject Name: FIP Subject Code: 22CST-317 1. Aim: Changing Color Space using MATLAB. 2. Requirements (Hardware/Software): 1. Laptop / Computer 2. Internet Connection 3. MATLAB Software or Online MATLAB 4. Some Downloaded Photo 3. Implementation: Code: (RGB2GRAY) photo=imread("angel.jpg"); change=rgb2gray(photo); figure,imshow(change); saveas(gcf,"Colour_Changev.png"); Output: DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Code: (RGB2HSV) photo=imread("angel.jpg"); changeh=rgb2hsv(photo); figure,imshow(changeh); saveas(gcf,"Colour.png"); Output: DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Learning Outcome: ❖ Learn fundamentals of image processing. ❖ Working with the MATLAB user interface ❖ Learn about different command ❖ Learn about the MATLAB toolbox ❖ Know about photo properties ❖ Changing color space DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Experiment-9 Student Name: Sourov Kumar Nandi UID: 22BCS14169 Branch: BE-CSE Section/Group: NTPP-903(B) Semester: 5th Date of Performance:21/08/24 Subject Name: FIP Subject Code: 22CST-317 1. Aim: How to draw Sine and Cosine wave using MATLAB. 2. Requirements (Hardware/Software): 1. Laptop / Computer 2. Internet Connection 3. MATLAB Software or Online MATLAB 4. Some Downloaded Photo 5. Processing of 2D and 3D photos 3. Implementation: Code: (Sine Wave) f=2; t=2:0.001:4; a=0.5; y=a*sin(2*pi*f*t); figure; plot(t,y,'r', 'LineWidth', 3); title("Graph"); xlabel("Time"); ylabel("Value"); grid on; DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Output: Code: (Sine Wave with Photo) img = imread('dark.jpg'); imshow(img); hold on; frequency =0.5; amplitude = 500; x = linspace(3, size(img, 2), 100); y = size(img, 1)/2 + amplitude * sin(frequency * x); plot(x, y, 'white', 'LineWidth', 2); title('Wave Overlay on Image'); hold off; Output: DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Code (Cosine Wave) f = 2; t = 2:0.001:4; a = 0.5; y = a * cos(2 * pi * f * t); figure; plot(t, y, 'black', 'LineWidth', 3); title('Cosine Wave'); xlabel('Time'); ylabel('Value'); grid on; Output: Learning Outcome: ❖ Learn fundamentals of image processing. ❖ Working with the MATLAB user interface ❖ Learn about different command ❖ Learn about the MATLAB toolbox ❖ Draw a wave on a plain and an image DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Experiment-10 Student Name: Sourov Kumar Nandi UID: 22BCS14169 Branch: BE-CSE Section/Group: NTPP-903(B) Semester: 5th Date of Performance:28/08/24 Subject Name: FIP Subject Code: 22CST-317 1. Aim: HOW TO SEE MULTIPLE IMAGES BYUSING SUBPLOT FUNCTION IN MATLAB. 2. Requirements (Hardware/Software): 1. Laptop / Computer 2. Internet Connection 3. MATLAB Software or Online MATLAB 4. Download Some photos. 3. Implementation: Code: (Subplot) photo = imread("download2.jpeg"); photo1 = imread("download3.jpeg"); photo2 = imread("imagesf.jpeg"); subplot(3,1,1); imshow(photo); subplot(3,1,2); imshow(photo1); subplot(3,1,3); imshow(photo2); Output: DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Code: (Subplot with Variable) % Read the images photo = imread('anime1.jpg'); photo2 = imread('Cartoon.png'); % Set up the subplot grid numrows = 1; numcols = 3; % Display the first image subplot(numrows, numcols, 3); imshow(photo); title('Anime 1'); % Display the second image subplot(numrows, numcols, 2); imshow(photo2); title('Cartoon'); saveas(gcf,"Subplot.png"); Output: Learning Outcome: ❖ Learn fundamentals of image processing. ❖ Working with the MATLAB user interface ❖ Learn about different command ❖ Learn about the MATLAB toolbox ❖ Know about photo properties DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING 2. AIM: Introduction to the Image Processing Toolbox of MATLAB. Requirements (Hardware/Software): 1. Laptop / Computer 2. Internet Connection 3. MATLAB Software or Online MATLAB 4. Some Downloaded Photo Implementation: # Show Photo and Title Code: photo = imread("images.jpeg"); imshow(photo); title("Me"); Output: DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Code: photo = imread("dfngfjk.jpg"); imshow(photo); title("you"); Output: Code: photo = imread("images.jpeg"); imshow(photo); title("Me"); Output: DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING #Resize Code: photo=imread("images.jpeg"); resize=imresize(photo,1.5); imshow(resize); Output: DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING % Sharp sharp=imsharpen(photo); figure,imshow(sharp); Output: 3. Aim: Extracting Image Properties using MATLAB. #Requirements Crop, Rotate and Sharp (Hardware/Software): photo = imread("images.jpeg"); 1. Laptop / Computer 2. Internet Connection % Crop 3. MATLAB Software or Online MATLAB crop=imcrop(photo,[35,40,75,100]); 4. Some Downloaded Photo imshow(crop); 5. Processing of 2D and 3D photos % Rotate rotate=imrotate(photo,90); figure,imshow(rotate); DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Implementation: Code: (RGB photos) photo = imread("images.jpeg"); imshow(photo); red = photo(:,:,1); green=photo(:,:,2); blue=photo(:,:,3); figure,imshow(red); figure,imshow(blue); figure,imshow(green); Output: Code:(Size and Color) photo=imread("images.jpeg"); showsize=size(photo); showclass=class(photo); disp(showsize); disp(showclass); Output: DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Code: (Subplot) photo = imread("download.jpeg"); imshow(photo); photo1 = imread("images.jpeg"); imshow(photo1); photo2 = imread("dfngfjk.jpg"); imshow(photo2); subplot(3,1,1); imshow(photo); subplot(3,1,2); imshow(photo1); subplot(3,1,3); imshow(photo2); Output: DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Code: (Histogram) photo = imread("images.jpeg"); red = photo(:,:,1); green=photo(:,:,2); blue=photo(:,:,3); figure,imhist(red); figure,imhist(green); figure,imhist(blue); Output: Code: (Pixel Values) photo = imread("images.jpeg"); imshow(photo); value=photo(50,50,:); disp(num2str(value(:))); % Another Method disp(['The result is: [' num2str(value(:).') ']']) ; Output: DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Code: (Area) photo = imread("images.jpeg"); imshow(photo); area=photo(60:120,80:100); figure,imshow(area); Output: Code :(Mean Value) photo = imread("images.jpeg"); v=mean(photo(:)); disp(num2str(v)); Output: # Save a photo saveas(gcf,'original.png'); Learning Outcome: ❖ Learn fundamentals of image processing. ❖ Working with the MATLAB user interface ❖ Learn about different command ❖ Learn about the MATLAB toolbox ❖ Know about photo properties DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Experiment-11 Student Name: Sourov Kumar Nandi UID: 22BCS14169 Branch: BE-CSE Section/Group: NTPP-903(B) Semester: 5th Date of Performance:04/09/24 Subject Name: FIP Subject Code: 22CST-317 1. Aim: How to Rotate of an Image by Clockwise and Anti Clock wise Rotation. 2. Requirements (Hardware/Software): 1. Laptop / Computer 2. Internet Connection 3. MATLAB Software or Online MATLAB 4. Download Some photos. 3. Implementation: Code: (Anti-Clockwise) photo=imread("you.jpg"); imshow(photo); title("Anime"); cl=imrotate(photo,-90); imshow(cl); title("New Anime"); Output: DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Code: (Clockwise) photo=imread("you.jpg"); imshow(photo); title("Anime"); cl=imrotate(photo,90); imshow(cl); title("New Anime"); saveas(gcf,"anti-clockwise.png"); Output: Code: (Subplot + Rotation) % Read the images photo = imread('anime1.jpg'); photo2 = imread('Cartoon.png'); % Set up the subplot grid numrows = 1; numcols = 3; % Display the first image subplot(numrows, numcols, 3); imshow(photo); f=imrotate(photo,-90); imshow(f); % Display the second image subplot(numrows, numcols, 2); imshow(photo2); saveas(gcf,"Subplot2.png"); DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING s=imrotate(photo2,90); imshow(s); Output: Learning Outcome: ❖ Learn fundamentals of image processing. ❖ Working with the MATLAB user interface ❖ Learn about different command ❖ Learn about the MATLAB toolbox ❖ Know about photo properties. DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Experiment-12 Student Name: Sourov Kumar Nandi UID: 22BCS14169 Branch: BE-CSE Section/Group: NTPP-903(B) Semester: 5th Date of Performance:04/09/24 Subject Name: FIP Subject Code: 22CST-317 1. Aim: How to Flipped of an Image Left to Right & Up to Down Using MATLAB. 2. Requirements (Hardware/Software): 1. Laptop / Computer 2. Internet Connection 3. MATLAB Software or Online MATLAB 4. Download Some photos. 3. Implementation: Code: (Flip) photo=imread("imagess.jpg"); imshow(photo); title("Flip"); d=flip(photo,2); figure; imshow(d); e=flip(photo,1); figure; imshow(e); saveas(gcf,"Photo.tiff"); Output: DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Code: (Subplot + Flip) % Load the original image photo = imread("imagess.jpg"); % Create a new figure figure; % Display the original image subplot(3, 1, 1); imshow(photo); title("Original Photo"); % Flip image horizontally d = flip(photo, 2); subplot(3, 1, 2); imshow(d); title("Horizontally Flipped Photo"); % Flip image vertically e = flip(photo, 1); subplot(3, 1, 3); imshow(e); title("Vertically Flipped Photo"); % Save the figure with flipped images saveas(gcf, "Photo_flips.png"); DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Output: Learning Outcome: ❖ Learn fundamentals of image processing. ❖ Working with the MATLAB user interface ❖ Learn about different command ❖ Learn about the MATLAB toolbox ❖ Know about photo properties. DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Experiment-13 Student Name: Sourov Kumar Nandi UID: 22BCS14169 Branch: BE-CSE Section/Group: NTPP-903(B) Semester: 5th Date of Performance:11/09/24 Subject Name: FIP Subject Code: 22CST-317 1. Aim: Separating Channels to MATLAB. 2. Requirements (Hardware/Software): 1. Laptop / Computer 2. Internet Connection 3. MATLAB Software or Online MATLAB 4. Download Different Image from Online Implementation: Code: (Separating Channels + Subplot) % Read photo = imread("you.jpg"); % Display figure; subplot(2, 3, 1); imshow(photo); title("Original"); % Extract color channels red = photo(:, :, 1); green= photo(:, :, 2); blue = photo(:, :, 3); % Display the red subplot(2, 3, 2); imshow(red); title("Red Color"); DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING % Display the green subplot(2, 3, 3); imshow(green); title("Green Color"); % Display the blue subplot(2, 3, 4); imshow(blue); title("Blue Color"); % Combine into one image combine= cat(3, red, green, blue); % Display the combined image subplot(2, 3, 5); imshow(combine); title("Combined Image"); Output: Learning Outcome: ❖ Learn fundamentals of image processing. ❖ Working with the MATLAB user interface ❖ Learn about different command ❖ Learn about the MATLAB toolbox ❖ Know about photo properties DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING 3. AIM: Introduction to the Image Processing Toolbox of MATLAB. Requirements (Hardware/Software): 1. Laptop / Computer 2. Internet Connection 3. MATLAB Software or Online MATLAB 4. Some Downloaded Photo Implementation: # Show Photo and Title Code: photo = imread("images.jpeg"); imshow(photo); title("Me"); Output: DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Code: photo = imread("dfngfjk.jpg"); imshow(photo); title("you"); Output: Code: photo = imread("images.jpeg"); imshow(photo); title("Me"); Output: DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING #Resize Code: photo=imread("images.jpeg"); resize=imresize(photo,1.5); imshow(resize); Output: # Crop, Rotate and Sharp photo = imread("images.jpeg"); % Crop crop=imcrop(photo,[35,40,75,100]); imshow(crop); % Rotate rotate=imrotate(photo,90); figure,imshow(rotate); DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING % Sharp sharp=imsharpen(photo); figure,imshow(sharp); Output: 4. Aim: Extracting Image Properties using MATLAB. Requirements (Hardware/Software): 1. Laptop / Computer 2. Internet Connection 3. MATLAB Software or Online MATLAB 4. Some Downloaded Photo 5. Processing of 2D and 3D photos DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Implementation: Code: (RGB photos) photo = imread("images.jpeg"); imshow(photo); red = photo(:,:,1); green=photo(:,:,2); blue=photo(:,:,3); figure,imshow(red); figure,imshow(blue); figure,imshow(green); Output: Code:(Size and Color) photo=imread("images.jpeg"); showsize=size(photo); showclass=class(photo); disp(showsize); disp(showclass); Output: DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Code: (Subplot) photo = imread("download.jpeg"); imshow(photo); photo1 = imread("images.jpeg"); imshow(photo1); photo2 = imread("dfngfjk.jpg"); imshow(photo2); subplot(3,1,1); imshow(photo); subplot(3,1,2); imshow(photo1); subplot(3,1,3); imshow(photo2); Output: DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Code: (Histogram) photo = imread("images.jpeg"); red = photo(:,:,1); green=photo(:,:,2); blue=photo(:,:,3); figure,imhist(red); figure,imhist(green); figure,imhist(blue); Output: Code: (Pixel Values) photo = imread("images.jpeg"); imshow(photo); value=photo(50,50,:); disp(num2str(value(:))); % Another Method disp(['The result is: [' num2str(value(:).') ']']) ; Output: DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Code: (Area) photo = imread("images.jpeg"); imshow(photo); area=photo(60:120,80:100); figure,imshow(area); Output: Code :(Mean Value) photo = imread("images.jpeg"); v=mean(photo(:)); disp(num2str(v)); Output: # Save a photo saveas(gcf,'original.png'); Learning Outcome: ❖ Learn fundamentals of image processing. ❖ Working with the MATLAB user interface ❖ Learn about different command ❖ Learn about the MATLAB toolbox ❖ Know about photo properties DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Experiment-14 Student Name: Sourov Kumar Nandi UID: 22BCS14169 Branch: BE-CSE Section/Group: NTPP-903(B) Semester: 5th Date of Performance:13/09/24 Subject Name: FIP Subject Code: 22CST-317 1. Aim: Neighboring of Pixel IN MATLAB. 2. Requirements (Hardware/Software): 1. Laptop / Computer 2. Internet Connection 3. MATLAB Software or Online MATLAB 4. Download Some photos. 3. Implementation: Code: (Horizontal) % Read the image photo = imread('angel.jpg'); % Define coordinates for the pixel X = 400; Y = 250; % Extract pixel values at the center, left, and right of the specified point pixel_center = photo(X, Y); pixel_left = photo(X, Y - 1); pixel_right = photo(X, Y + 1); % Calculate the horizontal gradient horizontal_gradient = pixel_right - pixel_left; % Display the gradient disp(“Horizontal Value : ”+horizontal_gradient); figure; imshow(photo); hold on; plot(X,Y,'g*','MarkerSize',100); plot(X,Y-1,'bo','MarkerSize',30); saveas(gcf,"Mark.png"); DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Output: Code: (Vertical) % Read the image photo = imread('angel.jpg'); % Define coordinates for the pixel X = 400; Y = 190; % Extract pixel values at the center, left, and right of the specified point pixel_center = photo(X, Y); pixel_top = photo(X - 1, Y); pixel_bottom = photo(X + 1, Y); % Calculate the vertical_gradient vertical_gradient = pixel_bottom - pixel_top; % Display the gradient disp(['Vertical Gradient: ', num2str(vertical_gradient)]); figure; imshow(photo); hold on; plot(X,Y,'go','MarkerSize',100); plot(X,Y-1,'b*','MarkerSize',30); saveas(gcf,"Marker.png"); DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Output: Learning Outcome: Understand Image Learn how images are stored as matrices of pixel values. Gain the ability to access specific pixel values from an image. Develop skills in computing horizontal and vertical gradients for edge detection. Learn how to overlay graphical elements on an image using plotting functions. Enhance proficiency in MATLAB for image processing tasks. DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Experiment-15 Student Name: Avishek Golder UID: 22BCS10052 Branch: BE-CSE Section/Group: NTPP-903(A) Semester: 5th Date of Performance:20/09/24 Subject Name: FIP Subject Code: 22CST-317 1. Aim: Accessing the Pixel Value of a Grayscale Image using MATLAB. 2. Requirements (Hardware/Software): 1. Laptop / Computer 2. Internet Connection 3. MATLAB Software or Online MATLAB 4. Some Downloaded Photo 3. Implementation: Code: photo = imread('cricket.jpg'); x = 200; y = 150; % Get the pixel intensity at (x, y) intensity = photo(y, x); % Display the result disp(['Pixel intensity at (' num2str(x) ',' num2str(y) '): ' num2str(intensity())]); imshow(photo); Output: DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Learning Outcome: 1. Understanding how to load an image using imread. 2. Extracting pixel intensity values using matrix indexing in MATLAB. 3. Learning how to access individual gray channel values from a color image. 4. Using disp and num2str for dynamic string and numeric value output. 5. Representing pixel data for display, including reshaping for color channels. DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Experiment-16 Student Name: Avishek Golder UID: 22BCS10052 Branch: BE-CSE Section/Group: NTPP-903(A) Semester: 5th Date of Performance:20/09/24 Subject Name: FIP Subject Code: 22CST-317 1. Aim: Accessing Pixel Values of an RGB Image using MATLAB. 2. Requirements (Hardware/Software): 1. Laptop / Computer 2. Internet Connection 3. MATLAB Software or Online MATLAB 4. Some Downloaded Photo 3. Implementation: Code: photo = imread('cricket.jpg'); x = 200; y = 150; % RGB color red=photo(x,y,1); green=photo(x,y,2); blue=photo(x,y,3); % display intensity Value disp(['Red: ' num2str(red) ', Green: ' num2str(green) ', Blue: ' num2str(blue)]); Output: DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Learning Outcome: 1. Understanding how to load an image using imread. 2. Extracting pixel intensity values using matrix indexing in MATLAB. 3. Learning how to access individual RGB channel values from a color image. 4. Using disp and num2str for dynamic string and numeric value output. 5. Representing pixel data for display, including reshaping for color channels. DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Experiment-17 Student Name: Sourov Kumar Nandi UID: 22BCS14169 Branch: BE-CSE Section/Group: NTPP-903(B) Semester: 5th Date of Performance:26/09/24 Subject Name: FIP Subject Code: 22CST-317 1. Aim: Convolution of 1D Signal using MATLAB. 2. Requirements (Hardware/Software): 1. Laptop / Computer 2. Internet Connection 3. MATLAB Software or Online MATLAB 4. Download Some photos. 3. Implementation: Code: % Define the sequences x = [1 2 3 4 5]; h = [1 -1 1]; % Compute the convolution y = conv(x, h); % Plot the sequences figure; plot(x, '-o', 'DisplayName', 'x', 'LineWidth', 1); hold on; plot(h, '-o', 'DisplayName', 'h', 'LineWidth', 1); plot(y, '-o', 'DisplayName', 'y', 'LineWidth', 1); xlabel('X-axis'); ylabel('Y-axis'); legend; % each plot has the correct label grid on; % plot, making it easier to read and interpret % Display the convolution result in the console disp("Convolution: "), disp(y); saveas(gcf,"Convolution of 1D Signal.png"); DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Output: Learning Outcome: Learn to compute the convolution of two discrete sequences using conv(). Learn how to plot signals (input sequences and convolution output) with proper labels and styles. Understand how to overlay multiple plots on a single figure using hold on. Gain knowledge about customizing plots (adding legends, labels, and grids). Learn to save figures to a file using saveas(). DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Experiment-18 Student Name: Sourov Kumar Nandi UID: 22BCS14169 Branch: BE-CSE Section/Group: NTPP-903(B) Semester: 5th Date of Performance:26/09/24 Subject Name: FIP Subject Code: 22CST-317 1. Aim: Convolution of 2D Signal using MATLAB. 2. Requirements (Hardware/Software): 1. Laptop / Computer 2. Internet Connection 3. MATLAB Software or Online MATLAB 4. Download Some photos. 3. Implementation: Code: % Read the image photo = imread('Anime-Girl.jpg'); % Convert the image to grayscale gray = im2gray(photo); % Define a 2D convolution kernel kernel = [-1 0 1; -2 0 2; -1 0 1]; % kernel = [-1 -1 -1; -1 8 -1; -1 -1 -1]; % kernel = fspecial('gaussian', [3 3], 1); % kernel = ones(3, 3) / 9; % kernel =[-1 -1 -1; 0 0 0; 1 1 1] % kernel =[[0, 0, 0],[0, 1, 0],[0, 0, 0]]; % kernel=[[ 0, 0, 0],[-1, 1, 0],[ 0, 0, 0]]; % kernel=[[-2, -1, 0],[-1, 1, 1],[ 0, 1, 2]]; % kernel=[[-1, 0, 1],[-1, 0, 1],[-1, 0, 1]]; % kernel=[[ 0, -1, 0],[-1, 5, -1],[ 0, -1, 0]]; % kernel=[[ 0, -1, 0],[-1, 4, -1],[ 0, -1, 0]]; % kernel=[[-1, -2, -1],[ 0, 0, 0],[ 1, 2, 1]]; % kernel=1/16 * [[1, 2, 1],[2, 4, 2],[1, 2, 1]]; % kernel=1/9 * [[1, 1, 1],[1, 1, 1],[1, 1, 1]]; % Perform the 2D convolution convolved_img = conv2(double(gray), kernel); DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING % Display the original image figure; imshow(gray); title('Original Image'); % Display the convolved image figure; imshow(uint8(convolved_img)); title('Convolved Image'); Output: Learning Outcome: Learn how to read and convert an RGB image to grayscale using imread() and im2gray(). Understand how to create a convolution kernel for edge detection. Learn how to use conv2() to apply a convolution operation to a grayscale image. Understand the importance of converting data types (double() for computation and uint8() for display). Learn to use imshow() to display both the original and convolved images in separate figures. DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Experiment-19 Student Name: Sourov Kumar Nandi UID: 22BCS14169 Branch: BE-CSE Section/Group: NTPP-903(B) Semester: 5th Date of Performance:03/10/24 Subject Name: FIP Subject Code: 22CST-317 1. Aim: Image Construction using Sample Points. 2. Requirements (Hardware/Software): 1. Laptop / Computer 2. Internet Connection 3. MATLAB Software or Online MATLAB 4. Download Some photos. 3. Implementation: Code: % Load and convert image to grayscale image_var = imread('download.jpeg'); gray_img = rgb2gray(image_var); gray_img = double(gray_img); % Get image dimensions [rows, columns] = size(gray_img); % Create zero image of equal size zero_img = zeros(rows, columns); % Randomly sample points, using 20% of all pixels random_points = rand(rows, columns) < 0.2; zero_img(random_points) = gray_img(random_points); % Plotting the images figure; % Plot the original grayscale image subplot(1, 2, 1); imagesc(gray_img); axis image off; colormap(gray); title('Actual Image'); DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING % Plot the image with sampled points subplot(1, 2, 2); imagesc(zero_img); axis image off; colormap(gray); title('Object Points'); saveas(gcf,"exp_19.png"); Output: Learning Outcome: I. Understand how digital images are represented as matrices in MATLAB. II. Learn methods for selecting sample points, such as uniform and random sampling. III. Explore interpolation methods (e.g., nearest neighbor, bilinear) for image reconstruction. IV. Analyze and quantify reconstruction errors using metrics like Mean Squared Error (MSE). V. Improve programming skills in MATLAB, focusing on matrix manipulation and image processing functions. DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Experiment-18 Student Name: Sourov Kumar Nandi UID: 22BCS14169 Branch: BE-CSE Section/Group: NTPP-903(B) Semester: 5th Date of Performance:26/09/24 Subject Name: FIP Subject Code: 22CST-317 1. Aim: Convolution of 2D Signal using MATLAB. 2. Requirements (Hardware/Software): 1. Laptop / Computer 2. Internet Connection 3. MATLAB Software or Online MATLAB 4. Download Some photos. 3. Implementation: Code: photo = imread("images.jpeg"); imshow(photo); title("Me"); Output: DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Code: photo = imread("dfngfjk.jpg"); imshow(photo); title("you"); Output: Code: photo = imread("images.jpeg"); imshow(photo); title("Me"); Output: DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING #Resize Code: photo=imread("images.jpeg"); resize=imresize(photo,1.5); imshow(resize); Output: DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING % Sharp sharp=imsharpen(photo); figure,imshow(sharp); Output: 2. Aim: Extracting Image Properties using MATLAB. #Requirements Crop, Rotate and Sharp (Hardware/Software): photo = imread("images.jpeg"); 1. Laptop / Computer 2. Internet Connection % Crop 3. MATLAB Software or Online MATLAB crop=imcrop(photo,[35,40,75,100]); 4. Some Downloaded Photo imshow(crop); 5. Processing of 2D and 3D photos % Rotate rotate=imrotate(photo,90); figure,imshow(rotate); DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Implementation: Code: (RGB photos) photo = imread("images.jpeg"); imshow(photo); red = photo(:,:,1); green=photo(:,:,2); blue=photo(:,:,3); figure,imshow(red); figure,imshow(blue); figure,imshow(green); Output: Code:(Size and Color) photo=imread("images.jpeg"); showsize=size(photo); showclass=class(photo); disp(showsize); disp(showclass); Output: DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Code: (Subplot) photo = imread("download.jpeg"); imshow(photo); photo1 = imread("images.jpeg"); imshow(photo1); photo2 = imread("dfngfjk.jpg"); imshow(photo2); subplot(3,1,1); imshow(photo); subplot(3,1,2); imshow(photo1); subplot(3,1,3); imshow(photo2); Output: DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Code: (Histogram) photo = imread("images.jpeg"); red = photo(:,:,1); green=photo(:,:,2); blue=photo(:,:,3); figure,imhist(red); figure,imhist(green); figure,imhist(blue); Output: Code: (Pixel Values) photo = imread("images.jpeg"); imshow(photo); value=photo(50,50,:); disp(num2str(value(:))); % Another Method disp(['The result is: [' num2str(value(:).') ']']) ; Output: DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Code: (Area) photo = imread("images.jpeg"); imshow(photo); area=photo(60:120,80:100); figure,imshow(area); Output: Code :(Mean Value) photo = imread("images.jpeg"); v=mean(photo(:)); disp(num2str(v)); Output: # Save a photo saveas(gcf,'original.png'); Learning Outcome: ❖ Learn fundamentals of image processing. ❖ Working with the MATLAB user interface ❖ Learn about different command ❖ Learn about the MATLAB toolbox ❖ Know about photo properties DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Experiment-20 Student Name: Sourov Kumar Nandi UID: 22BCS14169 Branch: BE-CSE Section/Group: NTPP-903(B) Semester: 5th Date of Performance:16/10/24 Subject Name: FIP Subject Code: 22CST-317 1. Aim: Adding Pixel Values using MATLAB. 2. Requirements (Hardware/Software): 1. Laptop / Computer 2. Internet Connection 3. MATLAB Software or Online MATLAB 4. Some Downloaded Photo 3. Implementation: Code: photo=imread("download.jpeg"); add_50=imadd(photo,50); add_100=imadd(photo,100); add_150=imadd(photo,150); add_5=imadd(photo,30); subplot(3,3,1); imshow(photo); title("Original Photo"); subplot(3,3,2); imshow(add_50); title("1st Photo"); subplot(3,3,3); imshow(add_100); title("2nd Photo"); subplot(3,3,4); imshow(add_150); title("3rd Photo"); subplot(3,3,5); imshow(add_5); title("4th Photo"); saveas(gcf,"exp_20"); DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Output: Learning Outcome: 1. Gained hands-on experience in image manipulation using MATLAB functions like `imadd()` and `imshow()`. 2. Enhanced understanding of adjusting image brightness and visualizing results through subplots. 3. Developed skills in organizing multiple image outputs for comparative analysis. 4. Learned how to label and save visual outputs using `title()` and `saveas()` functions. 5. Improved ability to effectively manage and display complex data in concise formats. DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Experiment-21 Student Name: Sourov Kumar Nandi UID: 22BCS14169 Branch: BE-CSE Section/Group: NTPP-903(B) Semester: 5th Date of Performance:16/10/24 Subject Name: FIP Subject Code: 22CST-317 1. Aim: Image Subtraction using MATLAB. 2. Requirements (Hardware/Software): a. Laptop / Computer b. Internet Connection c. MATLAB Software or Online MATLAB d. Some Downloaded Photo 3. Implementation: Code: photo=imread("sonic.jpg"); photo1=imread("sonic.jpg"); sub=photo-photo1; subtract = photo - 150; subplot(2,2,1); imshow(photo); title("Original Photo"); subplot(2,2,2); imshow(photo1); title("Original Photo"); subplot(2,2,3); imshow(sub); title("Image Subtraction (150) "); subplot(2,2,4); imshow(subtract); title("Image Subtraction"); DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Output: Learning Outcome: Learnt to perform image subtraction using MATLAB, enhancing understanding of pixel- level operations. Gained insight into how identical images yield a zero result when subtracted from each other. Improved skills in manipulating image brightness through constant pixel value subtraction. Developed proficiency in using imshow() and title() functions to visualize and annotate image results. Enhanced understanding of MATLAB's ability to handle matrices for effective image processing. DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Experiment-22 Student Name: Sourov Kumar Nandi UID: 22BCS14169 Branch: BE-CSE Section/Group: NTPP-903(B) Semester: 5th Date of Performance:16/10/24 Subject Name: FIP Subject Code: 22CST-317 1. Aim: Multiplication and Division on Image in MATLAB. 2. Requirements (Hardware/Software): 1. Laptop / Computer 2. Internet Connection 3. MATLAB Software or Online MATLAB 4. Some Downloaded Photo 3. Implementation: Code: photo=imread("new.png"); mul=immultiply(photo,2.5); div=imdivide(photo,4); subplot(2,2,1); imshow(photo); title("Original Photo"); subplot(2,2,2); imshow(mul); title("Multiply Photo"); subplot(2,2,3); imshow(div); title("Divide Image"); saveas(gcf,"exp_22.png"); DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Output: Learning Outcome: Developed proficiency in using MATLAB functions immultiply() and imdivide() for pixel- wise image operations. Gained practical experience in manipulating image brightness by applying multiplication and division factors. Enhanced skills in visualizing image transformations through subplot organization and clear labeling. Improved understanding of how scaling factors affect image properties, such as brightness and contrast. Learned to effectively present and compare original and modified images in a single figure for analysis. DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Experiment-23 Student Name: Sourov Kumar Nandi UID: 22BCS14169 Branch: BE-CSE Section/Group: NTPP-903(B) Semester: 5th Date of Performance:17/10/24 Subject Name: FIP Subject Code: 22CST-317 1. Aim: Image Complement using MATLAB. 2. Requirements (Hardware/Software): 1. Laptop / Computer 2. Internet Connection 3. MATLAB Software or Online MATLAB 4. Some Downloaded Photo 3. Implementation: Code: photo=imread("new.jpg"); change=rgb2gray(photo); complement=imcomplement(change); subplot(2,2,1); imshow(photo); title("Original Photo"); subplot(2,2,2); imshow(change); title("Gray Scale Photo"); subplot(2,2,3); imshow(complement); title("After Image Complement"); saveas(gcf,"Exp_23.png"); DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Output: Learning Outcome: Learned how to read and display an image using imread and imshow in MATLAB. Gained knowledge of converting a color image to grayscale using rgb2gray. Understood how to compute the complement of an image using imcomplement. Practiced plotting multiple images in a grid using subplot. Learned how to save the generated figure to a file using saveas. DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Experiment-24 Student Name: Sourov Kumar Nandi UID: 22BCS14169 Branch: BE-CSE Section/Group: NTPP-903(B) Semester: 5th Date of Performance:17/10/24 Subject Name: FIP Subject Code: 22CST-317 1. Aim: Max and Min Filtering in Image Processing using Matlab. 2. Requirements (Hardware/Software): a. Laptop / Computer b. Internet Connection c. MATLAB Software or Online MATLAB d. Some Downloaded Photo 3. Implementation: Code: photo = imread("new2.jpg"); convert = im2bw(photo, 0.4); maxf = @(x) max(x(:)); minf = @(x) min(x(:)); midf = @(x) median(x(:)); max_img = nlfilter(convert, [3,3], maxf); min_img = nlfilter(convert, [3,3], minf); mid_img = nlfilter(convert, [3,3], midf); subplot(3,2,1); imshow(photo); title("Original Photo"); subplot(3,2,2); imshow(convert); title("Converted Photo"); subplot(3,2,3); imshow(max_img); title("Max Filter"); subplot(3,2,4); DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING imshow(min_img); title("Min Filter"); subplot(3,2,5); imshow(mid_img); title("Median Filter"); saveas(gcf,"Exp_24.png"); Output: Learning Outcome: Learned how to read and display an image using MATLAB functions such as imread and imshow. Understood the concept of converting an image to binary using a threshold value (im2bw function). Applied non-linear filtering (max, medium and min filters) to a binary image using nlfilter and custom functions. Gained experience in using subplot to display multiple images (original, binary, filtered) in a single figure window. Practiced saving figures as image files using saveas function. DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Experiment-25 Student Name: Sourov Kumar Nandi UID: 22BCS14169 Branch: BE-CSE Section/Group: NTPP-903(B) Semester: 5th Date of Performance:23/10/24 Subject Name: FIP Subject Code: 22CST-317 1. Aim: Adding Salt and Pepper Noise using MATLAB. 2. Requirements (Hardware/Software): 1. Laptop / Computer 2. Internet Connection 3. MATLAB Software or Online MATLAB 4. Some Downloaded Photo 3. Implementation: Code: photo=imread("new2.jpg"); noise=imnoise(photo,'salt & pepper',0.05); subplot(1, 2, 1); imshow(photo); title('Original Image'); subplot(1, 2, 2); imshow(noise); title('Image with Salt & Pepper Noise'); saveas(gcf,"Exp_25.png"); DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Output: Learning Outcome: Learned to manipulate images in MATLAB by adding noise. Explored the characteristics and effects of salt-and-pepper noise. Gained proficiency in using MATLAB functions for image processing. Improved visualization skills by comparing original and noisy images. Developed file management skills by saving figures with saveas. DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Experiment-26 Student Name: Sourov Kumar Nandi UID: 22BCS14169 Branch: BE-CSE Section/Group: NTPP-903(B) Semester: 5th Date of Performance:23/10/24 Subject Name: FIP Subject Code: 22CST-317 1. Aim: Removing Salt and Pepper Noise using Mean Filter in Matlab. 2. Requirements (Hardware/Software): a. Laptop / Computer b. Internet Connection c. MATLAB Software or Online MATLAB d. Some Downloaded Photo 3. Implementation: Code: photo=imread("new2.jpg"); noise=imnoise(photo,'salt & pepper',0.05); mean=ones(3,3)/9; noise_free=imfilter(noise,mean); subplot(2, 2, 1); imshow(photo); title('Original Image'); subplot(2, 2, 2); imshow(noise); title('Image with Salt & Pepper Noise'); subplot(2, 2, 3); imshow(noise_free); title('Noise Free Using Filter'); saveas(gcf,"Exp_26_1.png"); DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Output: Code: photo=imread("new2.jpg"); % noise=imnoise(photo,'salt & pepper',0.05); mean=ones(3,3)/9; noise_free=imfilter(photo,mean); subplot(2, 2, 1); imshow(photo); title('Original Image'); %subplot(2, 2, 2); %imshow(noise); %title('Image with Salt & Pepper Noise'); subplot(2, 2, 3); imshow(noise_free); title('Noise Free Using Filter'); saveas(gcf,"Exp_26.png"); DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Output: Learning Outcome: Learned to add salt-and-pepper noise using imnoise. Applied a mean filter to reduce noise with imfilter. Created a 3x3 mean filter for image smoothing. Visualized original, noisy, and filtered images using subplot. Saved processed image results with saveas. DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Experiment 27 Student Name: Sourov Kumar Nandi UID: 22BCS14169 Branch: BE-CSE Section/Group: NTPP-903(B) Semester: 5th Date of Performance:23/10/24 Subject Name: FIP Subject Code: 22CST-317 1. Aim: Gaussian Filter. 2. Requirements (Hardware/Software): a. Laptop / Computer b. Internet Connection c. MATLAB Software or Online MATLAB d. Some Downloaded Photo 3. Implementation: Code: photo = imread('new.jpg'); gaussian = fspecial('gaussian', [10 10], 4); filter = imfilter(photo, gaussian, 'circular'); subplot(1, 2, 1); imshow(photo); title('Original Image'); subplot(1, 2, 2); imshow(filter); title('Gaussian Filtered Image'); saveas(gcf,"Exp_27.png"); DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Output: Learning Outcome: Created a Gaussian filter using fspecial for image smoothing. Applied a Gaussian filter to an image using imfilter with circular padding. Gained experience in visualizing both original and processed images using subplot. Understood the effects of Gaussian filtering on image blurring. Improved skills in using MATLAB for image filtering and processing tasks. DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Experiment-28 Student Name: Sourov Kumar Nandi UID: 22BCS14169 Branch: BE-CSE Section/Group: NTPP-903(B) Semester: 5th Date of Performance:25/10/24 Subject Name: FIP Subject Code: 22CST-317 1. Aim: Roberts Edge Detector using MATLAB. 2. Requirements (Hardware/Software): 1. Laptop / Computer 2. Internet Connection 3. MATLAB Software or Online MATLAB 4. Some Downloaded Photo 3. Implementation: Code: photo = imread('new.jpg'); change = rgb2gray(photo); Final = edge(change, 'roberts'); subplot(2, 2, 1); imshow(photo); title('Original Image'); subplot(2, 2, 2); imshow(change); title('Gray Image'); subplot(2, 2, 3); imshow(Final); title('Detected Edges'); saveas(gcf,"Exp_28_.png"); DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Output: Learning Outcome: 1. The code reads an image file using `imread`, allowing it to be processed within MATLAB. 2. It converts the color image to grayscale using `rgb2gray`, simplifying the image for edge detection. 3. Edge detection is applied using the `roberts` method, identifying sharp transitions in pixel intensity. 4. Images are displayed in a 2x2 grid using `subplot` and `imshow` to visualize original, grayscale, and edge-detected images side by side. 5. The processed figure is saved as a PNG file using `saveas`, making the output accessible outside MATLAB. DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Experiment-26 Student Name: Sourov Kumar Nandi UID: 22BCS14169 Branch: BE-CSE Section/Group: NTPP-903(B) Semester: 5th Date of Performance:25/10/24 Subject Name: FIP Subject Code: 22CST-317 1. Aim: Prewitt Edge Detection in Matlab. 2. Requirements (Hardware/Software): a. Laptop / Computer b. Internet Connection c. MATLAB Software or Online MATLAB d. Some Downloaded Photo 3. Implementation: Code: photo = imread('new.jpg'); change = rgb2gray(photo); Final = edge(change, 'prewitt'); subplot(2, 2, 1); imshow(photo); title('Original Image'); subplot(2, 2, 2); imshow(change); title('Gray Image'); subplot(2, 2, 3); imshow(Final); title('Detected Edges'); saveas(gcf,"Exp_29_.png"); DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Output: Learning Outcome: 1. Learn to read and store an image using MATLAB. 2. Practice converting a color image to grayscale for simplified processing. 3. Understand the Prewitt method for detecting edges in images. 4. Learn to display multiple stages of image processing in a single figure. 5. Gain experience saving processed images or figures to files in MATLAB. DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Experiment 30 Student Name: Sourov Kumar Nandi UID: 22BCS14169 Branch: BE-CSE Section/Group: NTPP-903(B) Semester: 5th Date of Performance:25/10/24 Subject Name: FIP Subject Code: 22CST-317 1. Aim: Sobel Edge Detector. 2. Requirements (Hardware/Software): a. Laptop / Computer b. Internet Connection c. MATLAB Software or Online MATLAB d. Some Downloaded Photo 3. Implementation: Code: photo = imread('new.jpg'); change = rgb2gray(photo); Final = edge(change, 'sobel'); subplot(2, 2, 1); imshow(photo); title('Original Image'); subplot(2, 2, 2); imshow(change); title('Gray Image'); subplot(2, 2, 3); imshow(Final); title('Detected Edges'); saveas(gcf,"Exp_30.png"); DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Output: Learning Outcome: Learn to read and store an image using MATLAB. Practice converting a color image to grayscale for simplified processing. Understand the Sobel method for detecting edges in images. Learn to display multiple stages of image processing in a single figure. Gain experience saving processed images or figures to files in MATLAB.

Use Quizgecko on...
Browser
Browser