1) Image Negative: s=L-1-r where r is the input intensity level and s is the output intensity level.
Read northpole.jpg image, obtain its negative. Display the original image and its negative.
clc; clear all;
a=imread('northpole.jpg');
b=255-a;                    % s=L-1-r
subplot(211), imshow(a), title('Northpole Image')
subplot(212), imshow(b), title('Negative of Northpole')
2)   Log
Transformation:   s=T(r)=clog(1+r) where c is a constant
and r is the input gray level.
    Read fourier.jpg image and apply log
transformation and display the fourier Spectrum.
clc; clear all;
in=imread('fourier.jpg');
c=input('Enter the constant value, c = ');
a=im2double(in);
a=a*255;
out=c*log10(1+a);                   % s=T(r)=clog(1+r) 
out=out/max(max(out));              % Normalization
subplot(121), imshow(in), title('Original Image')
subplot(122), imshow(out), title('Log Transformed Image(c=1)')
3)   Power
Law Transformations:
s=crγ. To account for an offset, when the input is zero use s= c(r+ε)γ.
 Read
crt.jpg, apply the transformation function with γ=1/2.5. Display the gamma
corrected image.
clc; clear all;
c=1;
Gamma=input('Enter the Gamma value = ');
x=imread('crt.jpg');
x1=double(x);       
y=c*(x1.^Gamma);                % s=c*(r^ γ) 
subplot(211),imshow(x), title('CRT input image')
subplot(212),imshow((y),[]), title('Corrected image(Gamma=0.4)')
4)     Contrast
Manipulation:
Read
mr.jpg image which is a magnetic resonance image with an upper thoracic human
spine with a fracture dislocation. Apply power law transformation with
exponents γ=0.6,  γ=0.4,  γ=0.3. Display the outputs and comment on the
results.
clc; clear all;
c=1;
Gamma=input('Enter the Gamma value = ');  % Must be vector, Ex:[0.6 0.4 0.3]
x=imread('mr.jpg');
x1=double(x);       
y=c*(x1.^Gamma(1));                             % s=c*(r^ γ) 
y1=c*(x1.^Gamma(2));
y2=c*(x1.^Gamma(3));
subplot(141),imshow(x), title('MRI scanned image')
subplot(142),imshow((y),[]), title('Corrected image(Gamma=0.6)')
subplot(143),imshow((y1),[]), title('Corrected image(Gamma=0.4)')
subplot(144),imshow((y2),[]), title('Corrected image(Gamma=0.3)')




 
No comments:
Post a Comment