Skip to content

Basic Image Transformations

 

(A) Log Transformation
(B) Power Law Transformation
(C) Negation Of An Image

(A) Log Transformation

Code:-

clear all;
clc;
close all;
a=imread('Muzic.jpg');
a=double(rgb2gray(a));
[row col]=size(a);
c=input('Enter value for Constant: ');
for x=1:row
               for y=1:col
                        b(x,y)=c*log(1+a(x,y));
                    end
            end
subplot(1,2,1)
imshow(uint8(a));
title('Original Image')
subplot(1,2,2)
imshow(uint8(b));
title('Log Transformed Image');

Output Of An Log Transformation

(B)Power Law Transformation

Code:-

clear all;
clc;
close all;
a=imread('D:\final print\dip speech\images4.jpg');
a=double(rgb2gray(a));
[row col]=size(a);
c=input('Enter value of Constant: ');
g=input('Enter value of Gamma: ');
for x=1:row
               for y=1:col
                        v=a(x,y);
                        d=power(v,g);
                        b=c*d;
                    end
            end
subplot(1,2,1)
imshow(uint8(a));
title('Original Image')
subplot(1,2,2)
imshow(uint8(b));
title('Power Law Transformed Image');

Output Of An Power Law Transformation

 

 

 

 

 

 

 

(C)Negation Of An Image

Code:-

a=imread('E:\Daniel\daniel-radcliffe-20071006-321486.jpg');
a=double(a);
neg=255-a;
subplot(2,2,1)
imshow(uint8(a));
title('Original Image')
subplot(2,2,2)
imshow(uint8(neg));
title('Negative image');
 a=imread('E:\Daniel\daniel-radcliffe-20071006-321486.jpg');
a=double(a);
neg=255-a;
subplot(2,2,1)
imshow(uint8(a));
title('Original Image')
subplot(2,2,2)
imshow(uint8(neg));
title('Negative image');

Output For Negation

Leave a Reply

Your email address will not be published. Required fields are marked *

error: Content is protected !!