Image Intensity Transformation Using MATLAB with Source Code

Intensity Transformation Using MATLAB

Theoretical Concepts: Introduction

What is Intensity Transformation?
Intensity transformation is increase the contrast between certain Intensity values, most important application of intensity transformation is Enhance the low Quality image.
Image Enhancement Techniques
Spatial operates on Pixels
Frequency domain operates on Fourier transform of image

Spatial Domain Methods
Spatial Domain Technique a operation (linear or non-linear) is performed on the pixels in the neighborhood of coordinate (x,y) in the input image F, giving enhanced image F’
Neighborhood can be any shape but generally it is rectangular ( 3x3, 5x5, 9x9)
g(x,y) = T[f(x,y)]

Grey Scale Manipulation

Simplest form of window (1x1)
Assume input gray scale values are in range [0, L-1] (in 8 bit images L = 256)
Nth root Transformation S = c (r)n .

Intensity Transformation function

Linear:
Negative
Identity
Logarithmic: 
Log
Inverse Log
Power-Law: 
nth power,
nth root.

Negative Image
S = (L – 1) – r
L- Number of gray Level in image
r- Pixel of input image

(Courtesy of G.E Medical system)
Fig.1. Original Mammogram image
Fig.2.Negative Image Obtained Using Negative Intensity transformation

Log Transformation
Compresses the dynamic range of images with big variations in pixel values
s = c log(1+r)
c: constant



Fourier Spectrum  b) Result of apply log transformation

Power Law Transformation
s = crγ  for various values of  ( (c=1 in all case)
C, ( : positive constants
Gamma correction

Contrast Stretching
To increase the dynamic range of the gray levels in the image is being processed.

The locations of r1, s1 and r2, s2 control the shape of the transformation function.
If r1= s1 and r2= s2 the transformation is a linear function and produces no changes.
If r1=r2, s1=0 and s2=L-1, the transformation becomes a thresholding function that creates a binary image.
Intermediate values of r1, s1 and r2, s2 produce various degrees of spread in the gray levels of the output image, thus affecting its contrast.
Commonly, r1≤r2 and s1≤s2 is assumed.

Histogram Processing
The histogram of a digital image by gray levels from 0 to L-1 is a discrete function h(rk)=nk, anywhere:

rk is the kth gray level
nk is the # pixels in the image by that gray level
n is the total number of pixels in the image
k = 0, 1, 2, …, L-1
Normalized histogram: p(rk)=nk/n
sum of all constituents = 1

Histogram Equalization

Histogram equalization results are alike to contrast stretching however offer the advantage of full automation, since HE automatically determines a transformation function to yield a new image with a uniform histogram.

Histogram Matching (or Specification)
Histogram equalization does not allow collaborating image enhancement and generates only one result: an approximation to a constant histogram.

Sometimes however, we need to be able to specify particular histogram forms capable of highlighting certain gray-level ranges.

Frequency Domain Methods
We simply compute the Fourier transform of the image to be enhanced, multiply the result by a filter and take the reverse transform to produce the enhanced image.
Low pass filtering involves the rejection of the high frequency components in the image. It outcomes in blurring of the image

MATLAB program Image Intensity Transformation

clc;
clear all;
close all;
%Read Input Image
a=imread('C:\Users\natheem\Desktop\images\mri.jpg');
subplot(2,2,1);
imshow(a);
title('original image');

%negative image
b=255-a;                        
subplot(2,2,2);
imshow(b);
title('negative image');

%log transform
l=255; 
d=l/log10(1+l);
e=d*log10(1+double(a));
f=uint8(e);
subplot(2,2,3);
imshow(f);
title('log transform');

%power law transform
gamma=1.1;        
g=double(a).^gamma;
subplot(2,2,4);
imshow(uint8(g));
title('power law transform');

RESULT

Fig.2.1 Intensity Transformation using Subplots

MATLAB PROGRAM USING INDIVIDUAL FIGURE

clc;
clear all;
close all;

%Read Input Image
a=imread('C:\Users\natheem\Desktop\images\mri.jpg');
figure(1);
imshow(a);
title('original image');

%negative image
b=255-a;                        
figure(2);
imshow(b);
title('negative image');

%log transform
l=255; 
d=l/log10(1+l);
e=d*log10(1+double(a));
f=uint8(e);
figure(3);
imshow(f);
title('log transform');

%power law transform
gamma=1.1;        
g=double(a).^gamma;
figure(4);
imshow(uint8(g));
title('power law transform');

RESULT

Fig.2.1.1.Original Image

Fig.2.1.2.Negative Image

Fig.2.1.3.Log Transformation

Fig.2.1.4. Power Law transformation

OUTPUT FOR X-RAY IMAGE USING SUBPLOT

Original Image
Negative Image
Log transformation
Power law transformation

OUTPUT FOR X-RAY IMAGE USING SEPARATE FIGURE

Fig.2.2.1 Original image

Fig.2.2.2 Negative Image

Fig.2.2.3 Log Transformation

Fig.2.2.4 Power law Transformation

Introduction

What is Intensity Transformation?
Intensity transformation is increase the contrast between certain Intensity values, most important application of intensity transformation is Enhance the low Quality image.
Image Enhancement Techniques
Spatial operates on Pixels
Frequency domain operates on Fourier transform of image

Spatial Domain Methods
Spatial Domain Technique a operation (linear or non-linear) is performed on the pixels in the neighborhood of coordinate (x,y) in the input image F, giving enhanced image F’
Neighborhood can be any shape but generally it is rectangular ( 3x3, 5x5, 9x9)
g(x,y) = T[f(x,y)]

Grey Scale Manipulation

Simplest form of window (1x1)
Assume input gray scale values are in range [0, L-1] (in 8 bit images L = 256)
Nth root Transformation S = c (r)n .

Intensity Transformation function

Linear:
Negative
Identity
Logarithmic: 
Log
Inverse Log
Power-Law: 
nth power,
nth root.

Negative Image
S = (L – 1) – r
L- Number of gray Level in image
r- Pixel of input image

(Courtesy of G.E Medical system)
Fig.1. Original Mammogram image
Fig.2.Negative Image Obtained Using Negative Intensity transformation

Log Transformation
Compresses the dynamic range of images with big variations in pixel values
s = c log(1+r)
c: constant

Fourier Spectrum  b) Result of apply log transformation

Power Law Transformation
s = crγ  for various values of  ( (c=1 in all case)
C, ( : positive constants
Gamma correction

Contrast Stretching
To increase the dynamic range of the gray levels in the image is being processed.

The locations of r1, s1 and r2, s2 control the shape of the transformation function.
If r1= s1 and r2= s2 the transformation is a linear function and produces no changes.
If r1=r2, s1=0 and s2=L-1, the transformation becomes a thresholding function that creates a binary image.
Intermediate values of r1, s1 and r2, s2 produce various degrees of spread in the gray levels of the output image, thus affecting its contrast.
Commonly, r1≤r2 and s1≤s2 is assumed.

Histogram Processing
The histogram of a digital image by gray levels from 0 to L-1 is a discrete function h(rk)=nk, anywhere:

rk is the kth gray level
nk is the # pixels in the image by that gray level
n is the total number of pixels in the image
k = 0, 1, 2, …, L-1
Normalized histogram: p(rk)=nk/n
sum of all constituents = 1

Histogram Equalization

Histogram equalization results are alike to contrast stretching however offer the advantage of full automation, since HE automatically determines a transformation function to yield a new image with a uniform histogram.

Histogram Matching (or Specification)
Histogram equalization does not allow collaborating image enhancement and generates only one result: an approximation to a constant histogram.

Sometimes however, we need to be able to specify particular histogram forms capable of highlighting certain gray-level ranges.

Frequency Domain Methods
We simply compute the Fourier transform of the image to be enhanced, multiply the result by a filter and take the reverse transform to produce the enhanced image.
Low pass filtering involves the rejection of the high frequency components in the image. It outcomes in blurring of the image

Practical approach:

MATLAB program Image Intensity Transformation

clc;
clear all;
close all;
%Read Input Image
a=imread('C:\Users\natheem\Desktop\images\mri.jpg');
subplot(2,2,1);
imshow(a);
title('original image');

%negative image
b=255-a;                        
subplot(2,2,2);
imshow(b);
title('negative image');

%log transform
l=255; 
d=l/log10(1+l);
e=d*log10(1+double(a));
f=uint8(e);
subplot(2,2,3);
imshow(f);
title('log transform');

%power law transform
gamma=1.1;        
g=double(a).^gamma;
subplot(2,2,4);
imshow(uint8(g));
title('power law transform');

RESULT

Fig.2.1 Intensity Transformation using Subplots

MATLAB PROGRAM USING INDIVIDUAL FIGURE

clc;
clear all;
close all;

%Read Input Image
a=imread('C:\Users\natheem\Desktop\images\mri.jpg');
figure(1);
imshow(a);
title('original image');

%negative image
b=255-a;                        
figure(2);
imshow(b);
title('negative image');

%log transform
l=255; 
d=l/log10(1+l);
e=d*log10(1+double(a));
f=uint8(e);
figure(3);
imshow(f);
title('log transform');

%power law transform
gamma=1.1;        
g=double(a).^gamma;
figure(4);
imshow(uint8(g));
title('power law transform');

RESULT

Fig.2.1.1.Original Image

Fig.2.1.2.Negative Image

Fig.2.1.3.Log Transformation

Fig.2.1.4. Power Law transformation

OUTPUT FOR X-RAY IMAGE USING SUBPLOT

Original Image
Negative Image
Log transformation
Power law transformation

OUTPUT FOR X-RAY IMAGE USING SEPARATE FIGURE

Fig.2.2.1 Original image

Fig.2.2.2 Negative Image

Fig.2.2.3 Log Transformation

Fig.2.2.4 Power law Transformation

Comments

Popular posts from this blog

Spatial Intensity Resolution Project Using MATLAB with Source Code

Histogram Equalization Project Using MATLAB with Source Code