You are on page 1of 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