0% found this document useful (0 votes)
16 views

DIP File

The document describes 4 image processing programs: 1) Reads an image and displays it 2) Reads an image, partitions it into 4 equal quadrants, and displays each quadrant 3) Reads an image, performs an identity function on it (leaving it unchanged), and displays the original and processed images 4) Reads an image, converts it to grayscale, calculates its negative by subtracting each pixel value from 255, and displays the original and negative images

Uploaded by

animesharnav
Copyright
© © All Rights Reserved
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views

DIP File

The document describes 4 image processing programs: 1) Reads an image and displays it 2) Reads an image, partitions it into 4 equal quadrants, and displays each quadrant 3) Reads an image, performs an identity function on it (leaving it unchanged), and displays the original and processed images 4) Reads an image, converts it to grayscale, calculates its negative by subtracting each pixel value from 255, and displays the original and negative images

Uploaded by

animesharnav
Copyright
© © All Rights Reserved
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
You are on page 1/ 5

Program 1 : Write a script to read an image and show it on the figure window .

Code:

% Read the image


image_data = imread('kola.jpg');

% Display the image


figure;
imshow(image_data);

Output:
Program 2: Read an image and partition it into four equal quadrants.

Code:
% Read the image
image_data = imread('your_image.jpg');
% Determine the size of the image
[rows, cols, ~] = size(image_data);

% Partition the image into four equal quadrants


quad1 = image_data(1:rows/2, 1:cols/2, :);
quad2 = image_data(1:rows/2, cols/2+1:end, :);
quad3 = image_data(rows/2+1:end, 1:cols/2, :);
quad4 = image_data(rows/2+1:end, cols/2+1:end, :);

% Display the quadrants


figure;
subplot(2, 2, 1);
imshow(quad1);
title('Quadrant 1');

subplot(2, 2, 2);
imshow(quad2);
title('Quadrant 2');

subplot(2, 2, 3);
imshow(quad3);
title('Quadrant 3');

subplot(2, 2, 4);
imshow(quad4);
title('Quadrant 4');

output:
Program 3: Write a script to perform identity function on an image.

Code:
% Read the image
image_data = imread('kola.jpg');

% Display the original image


figure;
subplot(1, 2, 1);
imshow(image_data);
title('Original Image');
% Apply the identity function
identity_image = image_data;
% Display the identity function result
subplot(1, 2, 2);
imshow(identity_image);
title('Identity Function Result');

Output:
Program 4: Write a script to find the negative of an image.

Code:

% Read the image


image_data = imread('your_image.jpg');

% Convert the image to grayscale


image_data = rgb2gray(image_data);
end

% Find the negative of the image


negative_image = 255 - image_data;

% Display the original and negative images


figure;
subplot(1, 2, 1);
imshow(image_data);
title('Original Image');

subplot(1, 2, 2);
imshow(negative_image);
title('Negative Image');

Output:

You might also like