Digital Image Processing (01317172)

assoverwroughtΤεχνίτη Νοημοσύνη και Ρομποτική

6 Νοε 2013 (πριν από 3 χρόνια και 9 μήνες)

94 εμφανίσεις

Dr.
Thurdsak

LEAUHATONG

Dept. of electronics,

Faculty of Engineering, KMITL

klthurds@gmail.com

thurdsak@hotmail.com

klthurds@kmitl.ac.th

Schedule

Date

Time

Subject

Nov. 10

15:10



16:40

Introduction and Digital
Image Fundamental

#1

Nov. 17

15:10



16:40

Digital Image
Fundamental #2

Nov. 24

15:10



16:40

Image Transform

Dec. 1

15:10



16:40

Image

Enhancement #1

Dec. 8

15:10



16:40

Image Enhancement

#2
& Assignment #1

Schedule (Continue)

Date

Time

Subject

Dec. 15

15:10



16:40

Image Compression #1

Jan. 12

15:10



16:40

Image Compression #2

Jan. 19

15:10



16:40

Image Compression #3 &
Assignment #2

Jan. 26

15:10



16:40

Image Segmentation

#1

Feb. 2

15:10



16:40

Image Segmentation #2

Text Book

Digital Image
Processing

using MATLAB


by

Rafael C. Gonzalez,

Richard E. Woods,

and Steven L.
Eddins


Text Book

Digital Image
Processing

by

Rafael C. Gonzalez,

Richard E.
Woods


CxImage


www.codeproject.com


Structure of Human Eye

Retina :

Light Sensitive Tissue


Cone Cell :

Red cell, green cell,
and blue cell. Detect
Color. Locate at center
of retina called fovea.


Rod Cell :

One type. Detect
Illumination.

Structure of Human Eye

Camera Structure

Charge
-
Coupled
Device
(
CCD
)
Psychophysical


Psychophysical

Gestalt Law


Similarity


Human often perceive a group of similar objects
as a single object or pattern

Gestalt Law


Anomally


When similarity occurs, an object can be
emphasised

if it is

dissimilar

to the others. This
is called
anomally
.

Getstalt

Law


Continuation


Continuation occurs when the eye is compelled
to
move through

one object and
continue

to
another object.


Getstalt

Law


Closure


Closure

occurs when an object is
incomplete

or a
space is not
completely enclosed
. If enough of
the shape is indicated, people
percieve

the whole
by filling in the missing
infomation
.


Getstalt

Law


Proximity


Proximity

occurs when elements are placed close
together. They tend to be perceived as a group.


Getstalt

Law


Figure and Ground


The eye differentiates an object from its
surrounding area. A form, silhouette, or
shape is naturally perceived as
figure

(object), while the surrounding area is
perceived as
ground

(background).


Balancing figure and ground can make
the perceived image more clear. Using
unusual figure/ground relationships can
add interest and subtlety to an image.


Shape Detection


Gestalt Application


S.
Kiranyaz
, M. Ferreira, and M.
Gabbouj
, “A Generic Shape/ Texture
Descriptor Over
Multiscale

Edge Field: 2
-
D Walking Ant Histogram,” IEEE
Trans. Image Processing, vol. 17, no. 3, pp. 377
-
391, March, 2008.

Gray Image



,
f x y
(
x
,
y
) = An image’s position or pixel

f(
x
,
y
) = The intensity of the image at (
x
,
y
).

Color Image



,
f x y
(
x
,
y
) = An image’s position or pixel

f(
x
,
y
) = (
r,g,b
)



The red, green, and blue components of



the image at (
x
,
y
).

Gray Image Represented by
Color Image



,
f x y
(
x
,
y
) = An image’s position or pixel

f(
x
,
y
) = (
i,i,i
)



The intensity of white color of the



image at (
x
,
y
).

Image Acquisition

Spatial
Sampling
Intensity
Quantization


,
,
f x y
x y


Continue Intensity

Continue Spatial

Image Acquisition

Spatial
Sampling
Intensity
Quantization
f
(
0
,
0
)
f
(
7
,
0
)
f
(
6
,
0
)
f
(
5
,
0
)
f
(
4
,
0
)
f
(
3
,
0
)
f
(
2
,
0
)
f
(
1
,
0
)
f
(
0
,
1
)
f
(
7
,
1
)
f
(
6
,
1
)
f
(
5
,
1
)
f
(
4
,
1
)
f
(
3
,
1
)
f
(
2
,
1
)
f
(
1
,
1
)
f
(
0
,
2
)
f
(
7
,
2
)
f
(
6
,
2
)
f
(
5
,
2
)
f
(
4
,
2
)
f
(
3
,
2
)
f
(
2
,
2
)
f
(
1
,
2
)
f
(
0
,
3
)
f
(
7
,
3
)
f
(
6
,
3
)
f
(
5
,
3
)
f
(
4
,
3
)
f
(
3
,
3
)
f
(
2
,
3
)
f
(
1
,
3
)
f
(
0
,
4
)
f
(
7
,
4
)
f
(
6
,
4
)
f
(
5
,
4
)
f
(
4
,
4
)
f
(
3
,
4
)
f
(
2
,
4
)
f
(
1
,
4
)
f
(
0
,
5
)
f
(
7
,
5
)
f
(
6
,
5
)
f
(
5
,
5
)
f
(
4
,
5
)
f
(
3
,
5
)
f
(
2
,
5
)
f
(
1
,
5
)


,
,
f x y
x y








,
0,1,,1
0,1,,1
f i j
i M
j N

 
 
Continue Intensity

Continue Spatial

Continue Intensity

Discrete Spatial

Image Acquisition

Spatial
Sampling
Intensity
Quantization
a
(
0
,
0
)
a
(
7
,
0
)
a
(
6
,
0
)
a
(
5
,
0
)
a
(
4
,
0
)
a
(
3
,
0
)
a
(
2
,
0
)
a
(
1
,
0
)
a
(
0
,
1
)
a
(
7
,
1
)
a
(
6
,
1
)
a
(
5
,
1
)
a
(
4
,
1
)
a
(
3
,
1
)
a
(
2
,
1
)
a
(
1
,
1
)
a
(
0
,
2
)
a
(
7
,
2
)
a
(
6
,
2
)
a
(
5
,
2
)
a
(
4
,
2
)
a
(
3
,
2
)
a
(
2
,
2
)
a
(
1
,
2
)
a
(
0
,
3
)
a
(
7
,
3
)
a
(
6
,
3
)
a
(
5
,
3
)
a
(
4
,
3
)
a
(
3
,
3
)
a
(
2
,
3
)
a
(
1
,
3
)
a
(
0
,
4
)
a
(
7
,
4
)
a
(
6
,
4
)
a
(
5
,
4
)
a
(
4
,
4
)
a
(
3
,
4
)
a
(
2
,
4
)
a
(
1
,
4
)
a
(
0
,
5
)
a
(
7
,
5
)
a
(
6
,
5
)
a
(
5
,
5
)
a
(
4
,
5
)
a
(
3
,
5
)
a
(
2
,
5
)
a
(
1
,
5
)






,
0,1,,1
0,1,,1
f i j
i M
j N

 
 










,,
0,1,,1
0,1,,1
a i j q f i j
i M
j N

 
 
Continue Intensity

Discrete Spatial

Discrete Intensity

Discrete Spatial

Image Acquisition

q
(
f
(
I
,
j
))
f
(
I
,
j
)






max min
,
,round
,2
k
f i j
q f i j
Q
f f
Q L
L
 

 

 

  
k
=the number of bits

k
=1;
L
=2


k
=5;
L
=32

k
=2;
L
=4


k
=6;
L
=64

k
=3;
L
=8


k
=7;
L
=128

k
=4;
L
=16


k
=8;
L
=256

Sampling with Different
Resolutions

Lena 256x256

Lena 128x128

Lena 64x64

Quantize with Different Levels

L
=2

L
=16

L
=64

L
=8

L
=128

L
=256

Size of Uncompressed Image


Size of Image =
M

x
N

x
k

bits





=
M

x
N

x
k/8

Bytes

64x64x8

=32768 bits

=4kB

256x256x8

=524288 bits

=64kB

Size of Uncompressed Image

128x128x1

=16384 bits

=2kB

128x128x8

=131072 bits

=16kB

Higher Fidelity = Bigger Image Size

Image Representation

a(
0,0)

a(
1,0)

a(
2,0)

a(
3,0)

a(
4,0)

a(
5,0)

a(
6,0)

a(
7,0)

a(
8,0)

a(
9,0)

a(
0,1)

a(
1,1)

a(
2,1)

a(
3,1)

a(
4,1)

a(
5,1)

a(
6,1)

a(
7,1)

a(
8,1)

a(
9,1)

a(
0,2)

a(
1,2)

a(
2,2)

a(
3,2)

a(
4,2)

a(
5,2)

a(
6,2)

a(
7,2)

a(
8,2)

a(
9,2)

a(
0,3)

a(
1,3)

a(
2,3)

a(
3,3)

a(
4,3)

a(
5,3)

a(
6,3)

a(
7,3)

a(
8,3)

a(
9,3)

a(
0,4)

a(
1,4)

a(
2,4)

a(
3,4)

a(
4,4)

a(
5,4)

a(
6,4)

a(
7,4)

a(
8,4)

a(
9,4)

a(
0,5)

a(
1,5)

a(
2,5)

a(
3,5)

a(
4,5)

a(
5,5)

a(
6,5)

a(
7,5)

a(
8,5)

a(
9,5)

a(
0,6)

a(
1,6)

a(
2,6)

a(
3,6)

a(
4,6)

a(
5,6)

a(
6,6)

a(
7,6)

a(
8,6)

a(
9,6)

a(
0,7)

a(
1,7)

a(
2,7)

a(
3,7)

a(
4,7)

a(
5,7)

a(
6,7)

a(
7,7)

a(
8,7)

a(
9,7)

a(
0,8)

a(
1,8)

a(
2,8)

a(
3,8)

a(
4,8)

a(
5,8)

a(
6,8)

a(
7,8)

a(
8,8)

a(
9,8)

An image with size
M
x
N

is an array of
a(
x
,
y
)
with
x
ϵ
{0
,M
-
1} and
y
ϵ
{0
,N
-
1}

Programming


VC++, Visual Studio 2008


CxImage

Build
CxImgLib

1.
Unzip CxImage600_full.zip into a folder,
for example, at C:
\
CxImage

2.
Open C:
\
CxImage
\
CxImgLib.dsw

3.
Select Menu Build
-
> Batch Build

4.
Click Select All

5.
Rebuild

4

5

Run
Demo Program

1.
Go to Solution Explorer (at the left/right
panel of VS2008)

2.
Right click at demo and select


“set as start up project”

3.
Click green arrow at toolbar


to run Demo program

3

2

Demo Program


Build a New Program

1.
Select Menu File
-
> New
-
> Project

2.
Select MFC
-
> MFC Application

Build a New Program (2)

1.
Click Browse and select the
CxImage

folder, for example, “c:
\
CxImage”

2.
Enter Project Name

1

2

Set Project Properties

1.
Right Click at Project Name

2.
Select Properties

3.
Select Configuration Properties

4.
Select General

5.
Set Character Set to


“Use Multi
-
Byte


Character Set”


1

5

Set Project Properties

6.
Select C/C++
-
> General

7.
Set Additional Include Directories to


..
\
..
\
CxImage


7

Set Project Properties

8.
Select C/C++
-
> Preprocessor

9.
Set Preprocessor Directories to


WIN32;_DEBUG;_WINDOWS;VATI_EX
TENSIONS;_CRT_SECURE_NO_DEPRE
CATE


9

Set Project Properties

10.
Select Linker
-
> Input

11.
Set Additional Dependencies to



../../
png
/Debug/png.lib
../../jpeg/Debug/jpeg.lib ../../
zlib
/Debug/zlib.lib
../../tiff/Debug/tiff.lib ../../
jbig
/Debug/jbig.lib
../../jasper/Debug/jasper.lib
../../
mng
/Debug/mng.lib
../../
cximage
/Debug/cximage.lib
../../raw/debug/libdcr.lib


9

Example of Load an Image File


void CDIP1Dlg::
OnBnClickedOpen
()


{



CFileDialog

fOpenDlg
(TRUE, "jpg", NULL,
OFN_HIDEREADONLY|OFN_FILEMUSTEXIST,




"JPEG (*.jpg)|*.
jpg|BITMAP

(*.bmp)|*.bmp||", this);




fOpenDlg.m_pOFN
-
>
lpstrTitle
="Select an Image File";




fOpenDlg.m_pOFN
-
>
lpstrInitialDir
="c:";




if(
fOpenDlg.DoModal
()==IDOK)



{




CString

FN =
fOpenDlg.GetPathName
();




int

Type =
CxImage
::
GetTypeIdFromName
(
FN.Mid
(
FN.ReverseFind
('.')+1));





m_ViewImage.Load
(
FN,Type
);




RedrawWindow
();



}


}

Example of Save an Image File


void CDIP1Dlg::
OnBnClickedSave
()


{



CFileDialog

fOpenDlg
(FALSE, "jpg", NULL,
OFN_HIDEREADONLY|OFN_FILEMUSTEXIST,




"JPEG (*.jpg)|*.
jpg|BITMAP

(*.bmp)|*.bmp||", this);




fOpenDlg.m_pOFN
-
>
lpstrTitle
="Select an Image File";




fOpenDlg.m_pOFN
-
>
lpstrInitialDir
="c:";




if(
fOpenDlg.DoModal
()==IDOK)



{




CString

FN =
fOpenDlg.GetPathName
();




int

Type =
CxImage
::
GetTypeIdFromName
(
FN.Mid
(
FN.ReverseFind
('.')+1));





m_ViewImage.Save
(
FN,Type
);



}


}

Example of Changing from a
Color Image to a Gray Image


void CDIP1Dlg::
OnBnClickedGrayImage
()


{



DWORD Width =
m_ViewImage.GetWidth
();



DWORD Height =
m_ViewImage.GetHeight
();



DWORD
x,y
;



RGBQUAD
rgb
;



BYTE Gray;






for(y=0;y<
Height;y
++)




for(x=0;x<
Width;x
++)




{





rgb

=
m_ViewImage.GetPixelColor
(
x,y
);





Gray = (BYTE) ((((float)
rgb.rgbRed
) + ((float)
rgb.rgbGreen
) + ((float)
rgb.rgbBlue
))/3.0);





rgb.rgbRed

= Gray;





rgb.rgbGreen

= Gray;





rgb.rgbBlue

= Gray;





m_ViewImage.SetPixelColor
(
x,y,rgb
);




}




RedrawWindow
();


}

Example of Displaying an
Image


void CDIP1Dlg::
OnPaint
()


{



if (
IsIconic
())



{


:



}



else



{




CPaintDC

dc(this); // device context for painting




CRect

rect
;




CWnd

*
pWnd
;




pWnd

=
GetDlgItem
(IDC_IMAGE_VIEW);




pWnd
-
>
GetWindowRect
( &
rect

);




ScreenToClient
( &
rect

);




if(
m_ViewImage.IsValid
())





m_ViewImage.Stretch
(
dc.GetSafeHdc
(),
rect
);




CDialog
::
OnPaint
();



}


}


How Computer Store an Image

a(
0,0)

a(
1,0)

a(
2,0)

a(
3,0)

a(
4,0)

a(
5,0)

a(
6,0)

a(
7,0)

a(
8,0)

a(
9,0)

a(
0,1)

a(
1,1)

a(
2,1)

a(
3,1)

a(
4,1)

a(
5,1)

a(
6,1)

a(
7,1)

a(
8,1)

a(
9,1)

a(
0,2)

a(
1,2)

a(
2,2)

a(
3,2)

a(
4,2)

a(
5,2)

a(
6,2)

a(
7,2)

a(
8,2)

a(
9,2)

a(
0,3)

a(
1,3)

a(
2,3)

a(
3,3)

a(
4,3)

a(
5,3)

a(
6,3)

a(
7,3)

a(
8,3)

a(
9,3)

a(
0,4)

a(
1,4)

a(
2,4)

a(
3,4)

a(
4,4)

a(
5,4)

a(
6,4)

a(
7,4)

a(
8,4)

a(
9,4)

a(
0,5)

a(
1,5)

a(
2,5)

a(
3,5)

a(
4,5)

a(
5,5)

a(
6,5)

a(
7,5)

a(
8,5)

a(
9,5)

a(
0,6)

a(
1,6)

a(
2,6)

a(
3,6)

a(
4,6)

a(
5,6)

a(
6,6)

a(
7,6)

a(
8,6)

a(
9,6)

a(
0,7)

a(
1,7)

a(
2,7)

a(
3,7)

a(
4,7)

a(
5,7)

a(
6,7)

a(
7,7)

a(
8,7)

a(
9,7)

a(
0,8)

a(
1,8)

a(
2,8)

a(
3,8)

a(
4,8)

a(
5,8)

a(
6,8)

a(
7,8)

a(
8,8)

a(
9,8)