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

DIP Exer 3

Uploaded by

Jhon Loui
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 views4 pages

DIP Exer 3

Uploaded by

Jhon Loui
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/ 4

Palawan State University

College of Sciences
Computer Studies Department

DIGITAL IMAGE PROCESSING LABORATORY EXERCISE #3

Implementation of Transformations of an Image


The implementation of transformations of an image involves modifying the pixel values or spatial characteristics
of the image to achieve specific objectives. Image transformations are widely used in digital image processing for
tasks such as enhancement, correction, and feature extraction. Here are some common types of image
transformations and their implementations:

1. Intensity Transformations:
• Linear Scaling: Multiply each pixel value by a constant factor and add another constant. It is often
used for contrast stretching or normalization.
• Logarithmic and Power-law Transformations: Used for adjusting the dynamic range of pixel
intensities.
2. Spatial Transformations:
• Translation: Shift the image in the x and y directions.
• Rotation: Rotate the image by a specified angle.
• Scaling: Resize the image by a scaling factor.
3. Geometric Transformations:
• Affine Transformation: Combines translation, rotation, scaling, and shearing.
• Projective Transformation (Homography): Used for perspective corrections.
4. Color Transformations:
• Grayscale Conversion: Convert a color image to grayscale using different methods.
• Color Space Conversion: Convert between different color representations (e.g., RGB to HSV).
5. Frequency Domain Transformations:
• Fourier Transform: Analyze the image in the frequency domain.
• Inverse Fourier Transform: Convert the frequency domain representation back to the spatial domain.
6. Histogram Transformations:
• Histogram Equalization: Enhance the contrast of an image by redistributing pixel intensities.

The choice of transformation depends on the specific requirements and objectives of the image processing task.
Implementation details may vary based on the programming language and libraries used.

%Scaling & Rotation

% Scaling (Resize) I=imread('earcell.jpg');


subplot(2,2,1); subimage(I); title('Original Image');

s=input('Enter Scaling Factor'); j=imresize(I,s);


subplot(2,2,2); subimage(j); title('Scaled Image');

% Rotation K=imrotate(j,60);
subplot(2,2,3); imshow(K); title('Rotated Image 60deg');

R=imrotate(j,45);
subplot(2,2,4); imshow(R); title('Rotated Image 45deg');
Prepared by: Demy Dizon
CS14/L – DIP subject
%Display the color image and its Resized images by different methods

%Display the color image I=imread('embryo.jpg');


figure, subplot(2,2,1); subimage(I); title('Original Image');

%Display Resized image by Bilinear method


B=imresize(I,5); subplot(2,2,2);
subimage(B);
title('Bilinear Image');

%Display Resized image by Nearest method


C=imresize(I,5,'nearest'); subplot(2,2,3); subimage(C); title('Nearest Image');

%Display Resized image by Bicubic method


D=imresize(I,5,'Bicubic'); subplot(2,2,4); subimage(D); title('Bicubic Image');

Prepared by: Demy Dizon


CS14/L – DIP subject
Python code:

1. Intensity Transformations:
• Linear Scaling: output_image = a * input_image + b
• Logarithmic and Power-law Transformations: output_image = c * log(1 + input_image) #
Logarithmic output_image = c * (input_image ** gamma) # Power-law
2. Spatial Transformations:
• Translation: T = [1 0 tx; 0 1 ty]; output_image = imwarp(input_image, affine2d(T));
• Rotation: output_image = imrotate(input_image, angle);
• Scaling: output_image = imresize(input_image, scale_factor);
3. Geometric Transformations:
• Affine Transformation: T = [a b 0; c d 0; tx ty 1]; output_image = imwarp(input_image, affine2d(T));
• Projective Transformation (Homography): tform = projective2d(H); output_image =
imwarp(input_image, tform);
4. Color Transformations:
• Grayscale Conversion: output_image = rgb2gray(input_image);
• Color Space Conversion: output_image = rgb2hsv(input_image);
5. Frequency Domain Transformations:
• Fourier Transform: F = fft2(input_image);
• Inverse Fourier Transform: output_image = ifft2(F);
6. Histogram Transformations:
• Histogram Equalization: output_image = histeq(input_image);

Prepared by: Demy Dizon


CS14/L – DIP subject
Exercise #3
Implementation of Transformations of an Image

Name:
Year/Block:
Application/Software:

1. Codes
2. Output
3. Answer the following questions:
A. Intensity Transformations:
- Explain the importance of intensity transformations in image processing. How might linear scaling
and logarithmic transformations be used to enhance features such as terrain or vegetation?
B. Spatial Transformations:
- Discuss the significance of spatial transformations in image analysis. How could translation,
rotation, and scaling be applied to align images from different passes or correct for geometric
distortions?
C. Geometric Transformations:
- Elaborate on the role of geometric transformations, especially affine transformations and
projective transformations (homography), in image processing. Provide examples of real-world
scenarios where these transformations are crucial for accurate analysis.
D. Color Transformations:
- In the context of satellite imagery, explain why color transformations might be relevant. Discuss
scenarios where converting images to grayscale or transitioning between different color spaces
(e.g., RGB to HSV) could aid in better interpretation and analysis.
E. Frequency Domain Transformations:
- Explore the potential applications of Fourier Transform in image processing. How might analyzing
images in the frequency domain help identify patterns, anomalies, or specific environmental
features?
F. Histogram Transformations:
- Describe how histogram equalization could be beneficial in enhancing contrast in images. Discuss
any potential challenges or limitations when applying this technique to large datasets.

Prepared by: Demy Dizon


CS14/L – DIP subject

You might also like