SlideShare a Scribd company logo
Mathematical Techniques
of Image Processing
Master of Applied Mathematics
Department of Mathematics
College of Science - University of Baghdad
Saad Al-Momen
1
Grayscale Digital Images
01
Working with Images in MATLAB
02
Images and Statistical Description of Quantitative Data
 Image Histograms
 Measures of Center and Spread
03
Color Images and Color Spaces
04
Grayscale Digital
Images
01
• A gray scale digital image is just an
M  N matrix of discrete pixel values.
Grayscale Digital Images
𝐴 =
𝑎1,1 𝑎1,2
𝑎2,1 𝑎2,2
⋯
𝑎1,𝑁−1 𝑎1,𝑁
𝑎2,𝑁−1 𝑎2,𝑁
⋮ ⋱ ⋮
𝑎𝑀−1,1 𝑎𝑀−1,2
𝑎𝑀,1 𝑎𝑀,2
⋯
𝑎𝑀−1,𝑁−1 𝑎𝑀−1,𝑁
𝑎𝑀,𝑁−1 𝑎𝑀,𝑁
• The maximal light intensity is
represented by the pixel value of 255
• The absence of light is represented
by the pixel value 0
• The shades of gray thus represented
by the values between 0 and 255
223 111
127 255
159 47
63 143
191 79
95 175
207 15
31 239
⇔
Working with Images in
MATLAB
02
MATLAB
Implementation
• The MATLAB function imread is used to
read the image from a graphics file of any
of a large number of common formats
>> A=imread(‘trees.tif’);
• To know the size of the image we use the
MATLAB function size
>> [M,N]=size(A)
For example, if it return the values M=258
and N=350, that indicates that the image has
dimensions 258350.
• Entering the MATLAB function
>> class(A)
into the command line returns the value
“uint8”, which tells us that the pixel values are
represented by 8-bit unsigned integers,
providing for 28 = 256 possible shades of
gray.
MATLAB
Implementation
• The MATLAB function imshow is used to
display the image that we are already read
>> imshow(A)
where A is the image matrix in the “uint8”
type obtained by executing the imread
command.
MATLAB
Implementation
• If we just use the function imshow in its
basic form, all the pixels whose values
exceed 1.0 will be interpreted as white
and displayed accordingly.
• However, in order to properly display an
image whose matrix is of the data type
“double”, we need to modify our usage of
the imshow function by supplying the range
of the pixel values. For example, we can
use
>> imshow(A,[0,255])
• If we want MATLAB to perform floating-
point arithmetic on pixels values, we must
convert the matrix type from “uint8” to
“double” by means of the command
>> A=double(A)
MATLAB
Implementation
• The MATLAB function subplot enables us to
fit several images or other graphics into the
same figure. Executing the command
>> subplot(m,n,p)
divides the current figure into an mn grid
and prepares to display an object in the
position of that grid specified by p.
A=imread('coins.png');
B=imread('trees.tif');
subplot(1,2,1);
imshow(A);
subplot(1,2,2);
imshow(B);
12
1 2
Images and Statistical
Description of Quantitative Data
03
• A matrix of a digital image may considered as a type of statistical data,
and we can analyze it with the help of statistical methods.
Image Histograms
• A common way to summarize quantitative data is by constructing
frequency distributions.
 Calculate the range of the dataset (the difference between the largest and
the smallest values)
 Decide on the number of bins (the number of subintervals to divide the data
into)
The subintervals are always adjacent to each other and are usually selected
to be of equal width.
 Count the frequencies (the numbers of data values that fall within each
subinterval).
 Dividing frequencies by the size of the data set (the total number of data
points) gives us relative frequencies.
 These bins, together with the frequencies, constitute a frequency distribution
The frequency distribution of the data set {0, 2, 4, 4, 4, 4, 4, 6, 7, 10}
using 4 bins is
Example
• An image histogram in its simplest form is a graphical representation of
the number of times each pixel value (that is, each gray level) occurs in
the image.
• By default, an image histogram has 256 bins.
Image Histograms
MATLAB
Implementation
• In order to display an image histogram, we
can use the MATLAB function imhist. For
example, typing
>> imhist(A);
into the command window produces a
histogram consisting of as many as 256
bars (one for each possible gray level),
where as typing in
>> imhist(A,16);
results in the histogram of the image A
using 16 bins.
MATLAB
Implementation
A=imread('img01.jpg');
B=imread('img02.jpg');
C=imread('img03.jpg');
A=rgb2gray(A);
B=rgb2gray(B);
C=rgb2gray(C);
subplot(3,2,1);
imshow(A,[0,255]);
subplot(3,2,2);
imhist(A);
subplot(3,2,3);
imshow(B,[0,255]);
subplot(3,2,4);
imhist(B);
subplot(3,2,5);
imshow(C,[0,255]);
subplot(3,2,6);
imhist(C);
Example
Consider a somewhat unrealistic example of an opulent $10,000,000
mansion in the middle of a modest community of 49 other houses,
each worth about $200,000. The mean property value in the
community is
𝑦 =
$10,000,000+$200,000+⋯+$200,000
50
= $369,000 per house
which, unfortunately, is representative of neither the opulent mansion
nor of the rest of the properties. It just would not be reasonable to
claim that the average house in the community is worth $396,000.
The obvious conclusion is that if the data are skewed or contain
outliers, the mean is not a very useful measure of center of the
dataset. Instead, in such circumstances, the other measure of
average - the median – is usually used.
Measures of Center and Spread
Mean & Median
For example, in order to calculate
the median of the even-size data
set
{5, 1, 4, 8, 2, 6, 11, 72, 4, 7, 1,
9}
We first rearrange it in the
ascending order as
{1, 1, 2, 4, 4, 5, 6, 7, 8,
9, 11, 72}
and then observe that the average
of the two middle entries of the
list is
m =(5 +6)/2= 5.5
Which is precisely the median of
Measures of Center and Spread
Mean & Median
In order to calculate the median of
the odd-size data set
{5, 1, 4, 8, 2, 6, 17, 72, 4, 7, 10}
We first rewrite it as
{1, 2, 4, 4, 5, 6, 7, 8, 10,
17, 72}
and then observe that the middle
entry is 6, which is precisely the
median of these data.
We note that the
median property value
in the real estate
example we
considered earlier is
$200,000, and it is
quite reasonable to
state that the average
house in the
community is worth
that amount
• We could define the mainstream of a data set as its middle half –
the part of the data that falls between the thresholds for the lower
quarter and the upper quarter.
• These thresholds are called quartiles.
• The first quartile 𝑄1 is the median of the lower half of the data set.
• The third quartile 𝑄3 is the median of the upper half.
• The second quartile 𝑄2 is the median of the entire data set.
• The interquartile range
𝐼𝑄𝑅 = 𝑄3 − 𝑄1
is a meaningful measure of spread of data.
Measures of Center and Spread
The Mainstream
In connection with the quartiles and the interquartile range, we mention
one more concept that might prove useful in image analysis is – that
of an outlier –a value that is vastly different from most of the rest of
the data.
There exist several technical definitions of the term outlier. One of
them is the Tukey fences definition, defines an outlier to be any value
outside the range
[𝑄1 − 1.5 × 𝐼𝑄𝑅, 𝑄3 + 1.5 × 𝐼𝑄𝑅]
and a strong outlier to be any value outside the range
[𝑄1 − 3 × 𝐼𝑄𝑅, 𝑄3 + 3 × 𝐼𝑄𝑅]
Measures of Center and Spread
The Outlier
To find the quartiles of the familiar data set
{5, 1, 4, 8, 2, 6, 17, 72, 4, 7, 1, 10}
we first rearrange it in the ascending order as
{1, 1, 2, 4, 4, 5, 6, 7, 8, 10, 17, 72}
and then observe that 𝑄1 = 3 and 𝑄3 = 9 as the medians of the lower
and upper halves respectively.
𝐼𝑄𝑅 = 𝑄3 − 𝑄1 = 6
The value 72 is a strong outlier because it is larger than the upper Tukey
fence
𝑄3 + 3 × 𝐼𝑄𝑅 = 9 + 3  6 = 27
whereas the value 17 is not an outlier because it falls within the Tukey
fences
[𝑄1 − 1.5 × 𝐼𝑄𝑅, 𝑄3 + 1.5 × 𝐼𝑄𝑅] = [3 − 1.5  6, 9 + 1.5  6] = [−6, 18]
Example
Is there any outliers in the following image
222 115
127 251
159 47
63 143
191 79
95 175
207 25
31 249
First we reshape the 2-D matrix representing the image into a 1-D list values
{222, 115, 159, 47, 127, 251, 63, 143, 191, 79, 207, 25, 95, 175, 31, 249}
which, after rearranging, becomes
{25, 31, 47, 63, 79, 95, 115, 127, 143, 159, 175, 191, 207,
222, 249, 251}
and we can look up the values
𝑄1 = 71, 𝑄2 = 135, 𝑎𝑛𝑑 𝑄3 = 199
𝐼𝑄𝑅 = 199 – 71 = 128
[𝑄1 − 1.5 × 𝐼𝑄𝑅, 𝑄3 + 1.5 × 𝐼𝑄𝑅] = [71 − 1.5  128, 199 + 1.5  128] = [−121, 391]
There are no outliers because all the values fall within this interval.
Example
MATLAB
Implementation
A=imread('cameraman.tif');
[M,N]=size(A);
A=reshape(A,[1,M*N]);
Q1=prctile(A,25)
Q3=prctile(A,75)
IQR=Q3-Q1
LowerBound=Q1-1.5*IQR
UpperBound=Q3+1.5*IQR
Quartiles provide thresholds for breaking data sets up into
quarters. But this is not the only possible useful way to
subdivide data.
More generally, the 𝑘𝑡ℎ percentile, denoted by 𝑃𝑘, is a value
with the property that 𝑘% of the data are less than or equal
to it.
Color Images and Color
Spaces
04
• A color image is a stack of three
matrices which contain information on
the three color channels. The exact
composition of those color channels
differs from model to model.
• We will focus on just two commonly
used color models -the RGB model
and the YCbCr model.
• In the RGB color model, the three
primary colors -Red, Green, and
Blue- are added together, which, at
least in theory, enables us to
reproduce as many as 2563 =
16,777,216 synthetic colors.
Color Images and Color Spaces
MATLAB
Implementation
imshow(A);
% Showing the channels in gray scale
Red=A(:,:,1); Green=A(:,:,2); Blue=A(:,:,3);
figure;
subplot(1,3,1); imshow(Red); title('(a)The red channel');
subplot(1,3,2); imshow(Green); title('(b)The green
channel');
subplot(1,3,3); imshow(Blue); title('(c)The blue
channel');
The RGB color model is most commonly used for displaying images, but it
is not very efficient for storage and transmission due to its inherent
redundancy. The reason is that we perceive the brightness and color
separately and are much more sensitive to small distortions in brightness
than to those in color. In most cases, we can readily sacrifice the latter for
the sake of increasing the speed of transmission.
For that reason, several color models that separate light intensity and color
into different channels have been developed. One of the most commonly
used models of this kind is YCbCr. The luminance channel Y contains the
information on the light intensity and is stored with high resolution, whereas
the two chrominance channels-Cb and Cr-represent the difference from pure
Blue and pure Red and can be compress data very high compression ratio.
Color Images and Color Spaces
MATLAB
Implementation
A=imread('FlagOfSeychelles.jpg’); B=rgb2ycbcr(A);
imshow(B);
% Showing the channels in gray scale
Y=B(:,:,1); Cb=B(:,:,2); Cr=B(:,:,3);
figure;
subplot(1,3,1); imshow(Y); title('(a)The Y channel');
subplot(1,3,2); imshow(Cb); title('(b)The Cb channel');
subplot(1,3,3); imshow(Cr); title('(c)The Cr channel');
THANK YOU
Any questions?
You can find me at:
saad.m@sc.uobaghdad.edu.iq

More Related Content

Similar to Basics of Digital Images

Programming in matlab lesson5
Programming in matlab lesson5Programming in matlab lesson5
Programming in matlab lesson5
najmah17
 
Engineering Numerical Analysis-Introduction.pdf
Engineering Numerical Analysis-Introduction.pdfEngineering Numerical Analysis-Introduction.pdf
Engineering Numerical Analysis-Introduction.pdf
ssuseraae901
 
Introduction to MATLAB
Introduction to MATLABIntroduction to MATLAB
Introduction to MATLAB
Damian T. Gordon
 
Matlab Tutorial.ppt
Matlab Tutorial.pptMatlab Tutorial.ppt
Matlab Tutorial.ppt
RaviMuthamala1
 
NumPy_Broadcasting Data Science - Python.pptx
NumPy_Broadcasting Data Science - Python.pptxNumPy_Broadcasting Data Science - Python.pptx
NumPy_Broadcasting Data Science - Python.pptx
JohnWilliam111370
 
Matlab intro
Matlab introMatlab intro
Matlab introfvijayami
 
Variables in matlab
Variables in matlabVariables in matlab
Variables in matlabTUOS-Sam
 
ModuleII.ppt
ModuleII.pptModuleII.ppt
ModuleII.ppt
SKILL2021
 
ModuleII.ppt
ModuleII.pptModuleII.ppt
ModuleII.ppt
AkashVerma916093
 
ModuleII.ppt
ModuleII.pptModuleII.ppt
ModuleII.ppt
nishashreyan1
 
Introduction to matlab lecture 2 of 4
Introduction to matlab lecture 2 of 4Introduction to matlab lecture 2 of 4
Introduction to matlab lecture 2 of 4
Randa Elanwar
 
Introduction to Data Science With R Lab Record
Introduction to Data Science With R Lab RecordIntroduction to Data Science With R Lab Record
Introduction to Data Science With R Lab Record
Lakshmi Sarvani Videla
 
Vectormaths and Matrix in R.pptx
Vectormaths and Matrix in R.pptxVectormaths and Matrix in R.pptx
Vectormaths and Matrix in R.pptx
Ramakrishna Reddy Bijjam
 
R Programming Intro
R Programming IntroR Programming Intro
R Programming Intro
062MayankSinghal
 
Summarizing Data : Listing and Grouping pdf
Summarizing Data : Listing and Grouping pdfSummarizing Data : Listing and Grouping pdf
Summarizing Data : Listing and Grouping pdf
JustynOwen
 
Lecture1_computer vision-2023.pdf
Lecture1_computer vision-2023.pdfLecture1_computer vision-2023.pdf
Lecture1_computer vision-2023.pdf
ssuserff72e4
 
BMVA summer school MATLAB programming tutorial
BMVA summer school MATLAB programming tutorialBMVA summer school MATLAB programming tutorial
BMVA summer school MATLAB programming tutorial
potaters
 

Similar to Basics of Digital Images (20)

Matlab for marketing people
Matlab for marketing peopleMatlab for marketing people
Matlab for marketing people
 
Programming in matlab lesson5
Programming in matlab lesson5Programming in matlab lesson5
Programming in matlab lesson5
 
Matlab1
Matlab1Matlab1
Matlab1
 
Engineering Numerical Analysis-Introduction.pdf
Engineering Numerical Analysis-Introduction.pdfEngineering Numerical Analysis-Introduction.pdf
Engineering Numerical Analysis-Introduction.pdf
 
Introduction to MATLAB
Introduction to MATLABIntroduction to MATLAB
Introduction to MATLAB
 
Matlab Tutorial.ppt
Matlab Tutorial.pptMatlab Tutorial.ppt
Matlab Tutorial.ppt
 
NumPy_Broadcasting Data Science - Python.pptx
NumPy_Broadcasting Data Science - Python.pptxNumPy_Broadcasting Data Science - Python.pptx
NumPy_Broadcasting Data Science - Python.pptx
 
Matlab intro
Matlab introMatlab intro
Matlab intro
 
bobok
bobokbobok
bobok
 
Variables in matlab
Variables in matlabVariables in matlab
Variables in matlab
 
ModuleII.ppt
ModuleII.pptModuleII.ppt
ModuleII.ppt
 
ModuleII.ppt
ModuleII.pptModuleII.ppt
ModuleII.ppt
 
ModuleII.ppt
ModuleII.pptModuleII.ppt
ModuleII.ppt
 
Introduction to matlab lecture 2 of 4
Introduction to matlab lecture 2 of 4Introduction to matlab lecture 2 of 4
Introduction to matlab lecture 2 of 4
 
Introduction to Data Science With R Lab Record
Introduction to Data Science With R Lab RecordIntroduction to Data Science With R Lab Record
Introduction to Data Science With R Lab Record
 
Vectormaths and Matrix in R.pptx
Vectormaths and Matrix in R.pptxVectormaths and Matrix in R.pptx
Vectormaths and Matrix in R.pptx
 
R Programming Intro
R Programming IntroR Programming Intro
R Programming Intro
 
Summarizing Data : Listing and Grouping pdf
Summarizing Data : Listing and Grouping pdfSummarizing Data : Listing and Grouping pdf
Summarizing Data : Listing and Grouping pdf
 
Lecture1_computer vision-2023.pdf
Lecture1_computer vision-2023.pdfLecture1_computer vision-2023.pdf
Lecture1_computer vision-2023.pdf
 
BMVA summer school MATLAB programming tutorial
BMVA summer school MATLAB programming tutorialBMVA summer school MATLAB programming tutorial
BMVA summer school MATLAB programming tutorial
 

Recently uploaded

Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
chanes7
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
Nguyen Thanh Tu Collection
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
TechSoup
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Akanksha trivedi rama nursing college kanpur.
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
vaibhavrinwa19
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
EduSkills OECD
 
The Diamond Necklace by Guy De Maupassant.pptx
The Diamond Necklace by Guy De Maupassant.pptxThe Diamond Necklace by Guy De Maupassant.pptx
The Diamond Necklace by Guy De Maupassant.pptx
DhatriParmar
 
Best Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDABest Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDA
deeptiverma2406
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
tarandeep35
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
SACHIN R KONDAGURI
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBCSTRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
kimdan468
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
Scholarhat
 

Recently uploaded (20)

Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
 
The Diamond Necklace by Guy De Maupassant.pptx
The Diamond Necklace by Guy De Maupassant.pptxThe Diamond Necklace by Guy De Maupassant.pptx
The Diamond Necklace by Guy De Maupassant.pptx
 
Best Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDABest Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDA
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBCSTRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
 

Basics of Digital Images

  • 1. Mathematical Techniques of Image Processing Master of Applied Mathematics Department of Mathematics College of Science - University of Baghdad Saad Al-Momen 1
  • 2.
  • 3. Grayscale Digital Images 01 Working with Images in MATLAB 02 Images and Statistical Description of Quantitative Data  Image Histograms  Measures of Center and Spread 03 Color Images and Color Spaces 04
  • 5. • A gray scale digital image is just an M  N matrix of discrete pixel values. Grayscale Digital Images 𝐴 = 𝑎1,1 𝑎1,2 𝑎2,1 𝑎2,2 ⋯ 𝑎1,𝑁−1 𝑎1,𝑁 𝑎2,𝑁−1 𝑎2,𝑁 ⋮ ⋱ ⋮ 𝑎𝑀−1,1 𝑎𝑀−1,2 𝑎𝑀,1 𝑎𝑀,2 ⋯ 𝑎𝑀−1,𝑁−1 𝑎𝑀−1,𝑁 𝑎𝑀,𝑁−1 𝑎𝑀,𝑁 • The maximal light intensity is represented by the pixel value of 255 • The absence of light is represented by the pixel value 0 • The shades of gray thus represented by the values between 0 and 255 223 111 127 255 159 47 63 143 191 79 95 175 207 15 31 239 ⇔
  • 6. Working with Images in MATLAB 02
  • 7. MATLAB Implementation • The MATLAB function imread is used to read the image from a graphics file of any of a large number of common formats >> A=imread(‘trees.tif’); • To know the size of the image we use the MATLAB function size >> [M,N]=size(A) For example, if it return the values M=258 and N=350, that indicates that the image has dimensions 258350. • Entering the MATLAB function >> class(A) into the command line returns the value “uint8”, which tells us that the pixel values are represented by 8-bit unsigned integers, providing for 28 = 256 possible shades of gray.
  • 8. MATLAB Implementation • The MATLAB function imshow is used to display the image that we are already read >> imshow(A) where A is the image matrix in the “uint8” type obtained by executing the imread command.
  • 9. MATLAB Implementation • If we just use the function imshow in its basic form, all the pixels whose values exceed 1.0 will be interpreted as white and displayed accordingly. • However, in order to properly display an image whose matrix is of the data type “double”, we need to modify our usage of the imshow function by supplying the range of the pixel values. For example, we can use >> imshow(A,[0,255]) • If we want MATLAB to perform floating- point arithmetic on pixels values, we must convert the matrix type from “uint8” to “double” by means of the command >> A=double(A)
  • 10. MATLAB Implementation • The MATLAB function subplot enables us to fit several images or other graphics into the same figure. Executing the command >> subplot(m,n,p) divides the current figure into an mn grid and prepares to display an object in the position of that grid specified by p. A=imread('coins.png'); B=imread('trees.tif'); subplot(1,2,1); imshow(A); subplot(1,2,2); imshow(B); 12 1 2
  • 11. Images and Statistical Description of Quantitative Data 03
  • 12. • A matrix of a digital image may considered as a type of statistical data, and we can analyze it with the help of statistical methods. Image Histograms • A common way to summarize quantitative data is by constructing frequency distributions.  Calculate the range of the dataset (the difference between the largest and the smallest values)  Decide on the number of bins (the number of subintervals to divide the data into) The subintervals are always adjacent to each other and are usually selected to be of equal width.  Count the frequencies (the numbers of data values that fall within each subinterval).  Dividing frequencies by the size of the data set (the total number of data points) gives us relative frequencies.  These bins, together with the frequencies, constitute a frequency distribution
  • 13. The frequency distribution of the data set {0, 2, 4, 4, 4, 4, 4, 6, 7, 10} using 4 bins is Example
  • 14. • An image histogram in its simplest form is a graphical representation of the number of times each pixel value (that is, each gray level) occurs in the image. • By default, an image histogram has 256 bins. Image Histograms
  • 15. MATLAB Implementation • In order to display an image histogram, we can use the MATLAB function imhist. For example, typing >> imhist(A); into the command window produces a histogram consisting of as many as 256 bars (one for each possible gray level), where as typing in >> imhist(A,16); results in the histogram of the image A using 16 bins.
  • 17. Consider a somewhat unrealistic example of an opulent $10,000,000 mansion in the middle of a modest community of 49 other houses, each worth about $200,000. The mean property value in the community is 𝑦 = $10,000,000+$200,000+⋯+$200,000 50 = $369,000 per house which, unfortunately, is representative of neither the opulent mansion nor of the rest of the properties. It just would not be reasonable to claim that the average house in the community is worth $396,000. The obvious conclusion is that if the data are skewed or contain outliers, the mean is not a very useful measure of center of the dataset. Instead, in such circumstances, the other measure of average - the median – is usually used. Measures of Center and Spread Mean & Median
  • 18. For example, in order to calculate the median of the even-size data set {5, 1, 4, 8, 2, 6, 11, 72, 4, 7, 1, 9} We first rearrange it in the ascending order as {1, 1, 2, 4, 4, 5, 6, 7, 8, 9, 11, 72} and then observe that the average of the two middle entries of the list is m =(5 +6)/2= 5.5 Which is precisely the median of Measures of Center and Spread Mean & Median In order to calculate the median of the odd-size data set {5, 1, 4, 8, 2, 6, 17, 72, 4, 7, 10} We first rewrite it as {1, 2, 4, 4, 5, 6, 7, 8, 10, 17, 72} and then observe that the middle entry is 6, which is precisely the median of these data.
  • 19. We note that the median property value in the real estate example we considered earlier is $200,000, and it is quite reasonable to state that the average house in the community is worth that amount
  • 20. • We could define the mainstream of a data set as its middle half – the part of the data that falls between the thresholds for the lower quarter and the upper quarter. • These thresholds are called quartiles. • The first quartile 𝑄1 is the median of the lower half of the data set. • The third quartile 𝑄3 is the median of the upper half. • The second quartile 𝑄2 is the median of the entire data set. • The interquartile range 𝐼𝑄𝑅 = 𝑄3 − 𝑄1 is a meaningful measure of spread of data. Measures of Center and Spread The Mainstream
  • 21. In connection with the quartiles and the interquartile range, we mention one more concept that might prove useful in image analysis is – that of an outlier –a value that is vastly different from most of the rest of the data. There exist several technical definitions of the term outlier. One of them is the Tukey fences definition, defines an outlier to be any value outside the range [𝑄1 − 1.5 × 𝐼𝑄𝑅, 𝑄3 + 1.5 × 𝐼𝑄𝑅] and a strong outlier to be any value outside the range [𝑄1 − 3 × 𝐼𝑄𝑅, 𝑄3 + 3 × 𝐼𝑄𝑅] Measures of Center and Spread The Outlier
  • 22. To find the quartiles of the familiar data set {5, 1, 4, 8, 2, 6, 17, 72, 4, 7, 1, 10} we first rearrange it in the ascending order as {1, 1, 2, 4, 4, 5, 6, 7, 8, 10, 17, 72} and then observe that 𝑄1 = 3 and 𝑄3 = 9 as the medians of the lower and upper halves respectively. 𝐼𝑄𝑅 = 𝑄3 − 𝑄1 = 6 The value 72 is a strong outlier because it is larger than the upper Tukey fence 𝑄3 + 3 × 𝐼𝑄𝑅 = 9 + 3  6 = 27 whereas the value 17 is not an outlier because it falls within the Tukey fences [𝑄1 − 1.5 × 𝐼𝑄𝑅, 𝑄3 + 1.5 × 𝐼𝑄𝑅] = [3 − 1.5  6, 9 + 1.5  6] = [−6, 18] Example
  • 23. Is there any outliers in the following image 222 115 127 251 159 47 63 143 191 79 95 175 207 25 31 249 First we reshape the 2-D matrix representing the image into a 1-D list values {222, 115, 159, 47, 127, 251, 63, 143, 191, 79, 207, 25, 95, 175, 31, 249} which, after rearranging, becomes {25, 31, 47, 63, 79, 95, 115, 127, 143, 159, 175, 191, 207, 222, 249, 251} and we can look up the values 𝑄1 = 71, 𝑄2 = 135, 𝑎𝑛𝑑 𝑄3 = 199 𝐼𝑄𝑅 = 199 – 71 = 128 [𝑄1 − 1.5 × 𝐼𝑄𝑅, 𝑄3 + 1.5 × 𝐼𝑄𝑅] = [71 − 1.5  128, 199 + 1.5  128] = [−121, 391] There are no outliers because all the values fall within this interval. Example
  • 25. Quartiles provide thresholds for breaking data sets up into quarters. But this is not the only possible useful way to subdivide data. More generally, the 𝑘𝑡ℎ percentile, denoted by 𝑃𝑘, is a value with the property that 𝑘% of the data are less than or equal to it.
  • 26. Color Images and Color Spaces 04
  • 27. • A color image is a stack of three matrices which contain information on the three color channels. The exact composition of those color channels differs from model to model. • We will focus on just two commonly used color models -the RGB model and the YCbCr model. • In the RGB color model, the three primary colors -Red, Green, and Blue- are added together, which, at least in theory, enables us to reproduce as many as 2563 = 16,777,216 synthetic colors. Color Images and Color Spaces
  • 28. MATLAB Implementation imshow(A); % Showing the channels in gray scale Red=A(:,:,1); Green=A(:,:,2); Blue=A(:,:,3); figure; subplot(1,3,1); imshow(Red); title('(a)The red channel'); subplot(1,3,2); imshow(Green); title('(b)The green channel'); subplot(1,3,3); imshow(Blue); title('(c)The blue channel');
  • 29. The RGB color model is most commonly used for displaying images, but it is not very efficient for storage and transmission due to its inherent redundancy. The reason is that we perceive the brightness and color separately and are much more sensitive to small distortions in brightness than to those in color. In most cases, we can readily sacrifice the latter for the sake of increasing the speed of transmission. For that reason, several color models that separate light intensity and color into different channels have been developed. One of the most commonly used models of this kind is YCbCr. The luminance channel Y contains the information on the light intensity and is stored with high resolution, whereas the two chrominance channels-Cb and Cr-represent the difference from pure Blue and pure Red and can be compress data very high compression ratio. Color Images and Color Spaces
  • 30. MATLAB Implementation A=imread('FlagOfSeychelles.jpg’); B=rgb2ycbcr(A); imshow(B); % Showing the channels in gray scale Y=B(:,:,1); Cb=B(:,:,2); Cr=B(:,:,3); figure; subplot(1,3,1); imshow(Y); title('(a)The Y channel'); subplot(1,3,2); imshow(Cb); title('(b)The Cb channel'); subplot(1,3,3); imshow(Cr); title('(c)The Cr channel');
  • 31. THANK YOU Any questions? You can find me at: saad.m@sc.uobaghdad.edu.iq

Editor's Notes

  1. السلام عليكم هذه هي المحاضرة الاولى في موضوع تقنيات رياضية لمعالجة الصور راح نركز بهذا الكورس على افكار الرياضيات المستخدمة في مجال معلجة الصور شنو اساسها الرياضي وشلون ممكن نختار الطرق الامثل لمعالجة الحالات المختلفة
  2. يتم الحديث عن تطبيقات القطاع الصحي المرور التحقق من الشخصية الحربي
  3. اجندة هذه المحاضرة راح تكون كالتالي
  4. الفرق بين التسمية صور اسود وابيض وهذه التي تدرجاتها رمادية
  5. كل Gray level يعامل على انه Bin بالتالي نعرف كل تدرج لوني كم مرة ظهر بالصورة
  6. opulent $10,000,000 mansion قصر فخم 10000000 دولار modest community of 49 other houses مجتمع متواضع من 49 منزلا آخر
  7. يمكننا تحديد الاتجاه السائد لمجموعة البيانات بالنصف الأوسط Quartile كورتايل
  8. اوتلير vastly different مختلفة إلى حد كبير Tukey fences definition تعريف توكي فينسيس سترونغ اوتلير
  9. ممكن تعميم الفكرة مال الكوارتيلز الي تعتمد على ربع ونص وثلاث ارباع الى نسب مئوية وهذه خارج موضوع الكورس هذا
  10. شوف اللون البرتقالي خلط احمر واخضر بينما ازرق لايوجد الابيض خلط للالوان الثلاث
  11. عادة نستخدم RGB لعرض الصور ، ولكنه ليس فعالًا جدًا للتخزين والنقل بسبب الفائضية . عين الانسان تتحسس للسطوع واللون بشكل منفصل وأننا أكثر حساسية للتشوهات الصغيرة في السطوع من تلك الموجودة في الألوان. في معظم الحالات ، يمكننا التضحية بالأخيرة بسهولة من أجل زيادة سرعة الإرسال. luminance الانارة او السطوع Chrominance التلوين او اللون