0% found this document useful (0 votes)
11 views16 pages

P 5

Djdiisks

Uploaded by

raajanraaj867
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)
11 views16 pages

P 5

Djdiisks

Uploaded by

raajanraaj867
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/ 16

LAB -5

LAB-5
1. X shear
2. Y shear
3. Program for Xshear and Yshear
4. Program for getting negative of the image
AIM: Shear transformation in X direction
• % Read an image
• img = imread('peppers.png’);

• % Define shearing factors


• shx =0.5; % Shearing in x-direction

• % Create a shearing matrix


• shearing_matrix = [1 shx 0; 0 1 0; 0 0 1];


• % Create a 2D affine transformation object
• tform = affine2d(shearing_matrix);
• % Apply the shearing to the image
• sheared_img = imwarp(img, tform);
• % Display the original and sheared images
• figure;
• subplot(1, 2, 1);
• imshow(img);
• title('Original Image');
• subplot(1, 2, 2);
• imshow(sheared_img);
• title('Sheared Image');
• AIM: Shear transformation in Y direction

• % Read an image
• img = imread('peppers.png');

• % Define shearing factors


• shy = 0.5; % Shearing in y-direction

• % Create a shearing matrix


• shearing_matrix1= [1 0 0;shy 1 0;0 0 1]


• % Create a 2D affine transformation object
• tform = affine2d(shearing_matrix1);

• % Apply the shearing to the image


• sheared_img = imwarp(img, tform);

• % Display the original and sheared images


• figure;
• subplot(1, 2, 1);
• imshow(img);
• title('Original Image');
• subplot(1, 2, 2);
• imshow(sheared_img);
• title('Sheared Image');
Shear transformation in X and Y directions
AIM :
• % Read an image
• img = imread('peppers.png');
• % Define shearing factors
• shx =0.5; % Shearing in x-direction
• shy = 0.5; % Shearing in y-direction
• % Create a shearing matrix
• shearing_matrix = [1 shx 0; shy 1 0; 0 0 1];



• % Create a 2D affine transformation object
• tform = affine2d(shearing_matrix);
• % Apply the shearing to the image
• sheared_img = imwarp(img, tform);
• % Display the original and sheared images
• figure;
• subplot(1, 2, 1);
• imshow(img);
• title('Original Image');
• subplot(1, 2, 2);
• imshow(sheared_img);
• title('Sheared Image');
Point processing techniques
• AIM : Negative of the image
• % Read the image
• original_image = imread('peppers.png');
• % Convert the image to grayscale (if not already)
• gray_image = rgb2gray(original_image);
• % In case of 8 Bit image
• L = 256;
• % The below operation is equivalent to 255 - img
• s = (L - 1) - gray_image;
• figure,imshow(s); title('Inverted Image')

POINT PROCESSING TECHNIQUES
AIM :
Program to get negative of an image
• % Read the image
• original_image = imread('peppers.png');
• % Convert the image to grayscale (if not already)
• gray_image = rgb2gray(original_image);
• % Get the maximum intensity value based on the image type
• max_intensity = double(max(gray_image(:)));
• % Get the maximum intensity value based on the image type

• negative_image = max_intensity - double(gray_image);

• % Convert the image back to uint8 (if necessary)


• negative_image = uint8(negative_image);
• % Display the original and negative images
• figure;
• subplot(1, 2, 1);
• imshow(gray_image);
• title('Original Image');

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

You might also like