Image Processing: Chapter (3) Part 3:intensity Transformation and Spatial Filters
Image Processing: Chapter (3) Part 3:intensity Transformation and Spatial Filters
Chapter(3)
Part 3:Intensity Transformation and
spatial filters
Solution:
x=imread('cameraman.tif');
y=x;
[w h]=size(x);
for i=1:w
for j=1:h
if x(i,j)>=100 && x(i,j)<=200 y(i,j)=255;
else y(i,j)=0;
end
end
end
figure, imshow(x);
figure, imshow(y);
.Ch3, lesson3: piecewise Linear transformation functions
piecewise Linear transformation functions.
2. Intensity-Level Slicing (gray level slicing)
example: approach 2
example: apply intensity level slicing in Matlab to read
cameraman image , then If the pixel intensity in the old image
is between (100 200) convert it in the new image into 255
(white). Otherwise it leaves it the same.
.Ch3, lesson3: piecewise Linear transformation functions
piecewise Linear transformation functions.
2. Intensity-Level Slicing (gray level slicing)
example: approach 2
example: apply intensity level slicing in Matlab to read
cameraman image , then If the pixel intensity in the old image
is between (100 200) convert it in the new image into 255
(white). Otherwise it leaves it the same.
Solution:
x=imread('cameraman.tif');
y=x;
[w h]=size(x);
for i=1:w
for j=1:h
if x(i,j)>=100 && x(i,j)<=200 y(i,j)=255;
else y(i,j)=x(i,j);
end
end
end
figure, imshow(x);
figure, imshow(y);
.Ch3, lesson3: piecewise Linear transformation functions
piecewise Linear transformation functions.
2. Intensity-Level Slicing (gray level slicing)
Homework
example: apply intensity level slicing (approch2) in Matlab to
read moon image , then If the pixel intensity in the old image
is between (0 20) convert it in the new image into 130.
Bit-plane Slicing
Pixels are digital numbers, each one composed of
bits. Instead of highlighting gray-level range, we
could highlight the contribution made by each bit.
This method is useful and used in image
compression.
Bit-Plane Slicing .3
Bit-Plane Slicing
.Ch3, lesson3: piecewise Linear transformation functions
01100100
0 32 64 0
.Ch3, lesson3: piecewise Linear transformation functions
Bit-Plane Slicing- .3
programmed
example: apply bit-plane slicing in Matlab to read cameraman
image , then extract the image of bit 6.
Solution:
x=imread('cameraman.tif');
y=x*0;
[w h]=size(x);
for i=1:w
for j=1:h
b=bitget(x(i,j),6);
y(i,j)=bitset(y(i,j),6,b);
end
end
figure, imshow(x);
figure, imshow(y);
Histogram Processing
What is a Histogram?
In Statistics, Histogram is a graphical
representation showing a visual
impression of the distribution of data.
An Image Histogram is a type of
histogram that acts as a graphical
representation of the lightness/color
distribution in a digital image. It plots the
number of pixels for each value.
Preview.. histogram
?Histogram
The histogram of a digital image with gray
levels in the range [0, L-1] is a discrete
function:
h(rk) = nk
Where:
rk : kth gray level
nk : # of pixels with having gray level rk
Histogram Processing
It is common practice to normalize a
histogram by dividing each of its values by
the total number of pixels in the image,
denoted by n. Thus, a normalized
histogram is given by p(rk) = nk / n, for k
= 0, 1, …, L -1.
Thus, p(rk) gives an estimate of the
probability of occurrence of gray level rk.
Note that the sum of all components of a
normalized histogram is equal to 1.
?Why Histogram
Histograms are the basis for numerous
spatial domain processing techniques
Histogram manipulation can be used
effectively for image enhancement
Histograms can be used to provide useful
image statistics
Information derived from histograms are
quite useful in other image processing
applications, such as image compression
and segmentation.
Ch3, lesson 4: histogram
histogram
h = imhist(f);
plot (h, ‘color-linestyle-marker’) (3)
>> plot (h, 'color','r','linestyle','--','Marker','s')
the arguments are specified preciously.
Ch3, lesson 5: histogram equalization
Histogram equalization of the
:image
We have this image in matlab called
pout.tif, when we plot its histogram it
is showed like this:
Equalization (mathematically)
g(x) = (L/n). T(X) -1
Where,
G(X) : the new image after equalization
L: No of gray levels 2n
n: No of pixels
T(x): cumulative sum of each gray level
Ch3, lesson 5: histogram equalization
Equalization (mathematically)
G(x) كمي6را666مجموع تT(X) كل66لبكسلل66دد ا6 عX L
لبكسل66ل Graylevel grayl Assume that we have
evels (3bits per pixels) or 8
levels of grayscale,
0 1 1 0 and we want to
equalize the following
0 4 3 1 image example.
1 9 5 2
2 15 6 3 G(x)=(L/n). T(X) -1
=(8/32). T(x) -1
4 21 6 4
5 27 6 5
6 29 2 6
7 32 3 7
8 عدد ال
لكلي66لبكسالتا66دد ا6 عNo of pixels
graylevel