02_DigitalImagesAndMatlab (1).ppt
-
Upload
suranga-sampath -
Category
Documents
-
view
214 -
download
0
Transcript of 02_DigitalImagesAndMatlab (1).ppt
-
7/25/2019 02_DigitalImagesAndMatlab (1).ppt
1/32
February 9, 2016 1
Image Processing
Instructor: Juyong [email protected]
htt!:""sta##.ustc.eu.cn"$juyong
Digital Images and Matlab
. {. . . .
mailto:[email protected]://staff.ustc.edu.cn/~juyonghttp://staff.ustc.edu.cn/~juyongmailto:[email protected] -
7/25/2019 02_DigitalImagesAndMatlab (1).ppt
2/32
%igita& Image
a grid of squares,
each of whichcontains a single
color
each square is
called a pixel (for
picture element)
Color images have 3 values perpixel monochrome images have !
value per pixel"
February 9, 2016 2
-
7/25/2019 02_DigitalImagesAndMatlab (1).ppt
3/32
' igita& image,I, is a ma!!ing #rom a 2% grio# uni#orm&y s!ace iscrete !oints, (p = )r,c*+,
into a set o# !ositie integer a&ues, (I)p*+, or aset o# ector a&ues, e.g., (-RGB#)p*+.
't each co&umn &ocation in each ro/ o#Ithereis a a&ue.
he !air )p, I)p** is ca&&e a !ie&3 )#orpicture element*.
Pie&s
February 9, 2016 4
-
7/25/2019 02_DigitalImagesAndMatlab (1).ppt
4/32
p = )r,c*is the !ie& &ocation inee by ro/, r,an co&umn, c.
I)p* = I)r,c* is the a&ue o# the !ie& at &ocationp.
I#I)p* is a sing&e number thenIismonochrome.
I#I)p* is a ector )orere &ist o# numbers* thenI has mu&ti!&e bans )e.g.,a co&or image*.
Pie&s
February 9, 2016 5
-
7/25/2019 02_DigitalImagesAndMatlab (1).ppt
5/32
Pie&s
Pixel Location:p = )r ,c*
Pixel Value:I)p*= I)r ,c* Pixel :$p, I)p*
February 9, 2016
-
7/25/2019 02_DigitalImagesAndMatlab (1).ppt
6/32
Pixel :$p, I)p*Pie&s
February 9, 2016 6
-
7/25/2019 02_DigitalImagesAndMatlab (1).ppt
7/32
7oing
Matlab
%penC&
February 9, 2016 8
-
7/25/2019 02_DigitalImagesAndMatlab (1).ppt
8/32
ea a rueco&or Image into at&ab
February 9, 2016 ;
-
7/25/2019 02_DigitalImagesAndMatlab (1).ppt
9/32
ea a rueco&or Image into at&ab
February 9, 2016 9
-
7/25/2019 02_DigitalImagesAndMatlab (1).ppt
10/32
ea a rueco&or Image into at&ab
February 9, 2016 10
-
7/25/2019 02_DigitalImagesAndMatlab (1).ppt
11/32
7ro! the Image
First, select aregion usingthe magnifier.
left click here and hold
drag to here and release
Cut out a region
from the image
February 9, 2016 11
-
7/25/2019 02_DigitalImagesAndMatlab (1).ppt
12/32
ea a 7o&orma!!e Image into at&ab
February 9, 2016 12
-
7/25/2019 02_DigitalImagesAndMatlab (1).ppt
13/32
ea a 7o&orma!!e Image into at&ab
February 9, 2016 14
-
7/25/2019 02_DigitalImagesAndMatlab (1).ppt
14/32
7o&orma!!e s. rueco&or in at&ab
February 9, 2016 15
-
7/25/2019 02_DigitalImagesAndMatlab (1).ppt
15/32
7o&orma!!e s. rueco&or in at&ab
row: 231
co
l:
326
T(231,326,:)
image class' uintimage tpe' truecolor
227
222
96
Intensity valuesare integersbetween and !"".
February 9, 2016 1
-
7/25/2019 02_DigitalImagesAndMatlab (1).ppt
16/32
7o&orma!!e s. rueco&or in at&ab
row: 231
co
l:
326
T(231,326,:)
image class' doubleimage tpe' truecolor
0.89
0.87
0.38
Intensity valuesare numbersbetween and #.
February 9, 2016 16
-
7/25/2019 02_DigitalImagesAndMatlab (1).ppt
17/32
7o&orma!!e s. rueco&or in at&ab
image class' uint
image tpe' colormapped
255 = [226 231 65]TI(231,326,:) =0.1804 0.1882 0.0627
0.6863 0.7098 0.2902
0.8863 0.9059 0.2549
red green blue
colormap
214
1
256
row: 231
co
l:
326 226
231
65
$umber at %ixellocation is an indexinto a colorma%.
Intensity valuesare integersbetween and #.
February 9, 2016 18
http://../Fall%202007/Lectures/%20%20%20%200.1804%20%20%20%200.1882%20%20%20%200.0627%0D%0A%20%20%20%200.6863%20%20%20%200.7098%20%20%20%200.2902%0D%0A%20%20%20%200.8863%20%20%20%200.9059%20%20%20%200.2549http://../Fall%202007/Lectures/%20%20%20%200.1804%20%20%20%200.1882%20%20%20%200.0627%0D%0A%20%20%20%200.6863%20%20%20%200.7098%20%20%20%200.2902%0D%0A%20%20%20%200.8863%20%20%20%200.9059%20%20%20%200.2549http://../Fall%202007/Lectures/%20%20%20%200.1804%20%20%20%200.1882%20%20%20%200.0627%0D%0A%20%20%20%200.6863%20%20%20%200.7098%20%20%20%200.2902%0D%0A%20%20%20%200.8863%20%20%20%200.9059%20%20%20%200.2549http://../Fall%202007/Lectures/%20%20%20%200.1804%20%20%20%200.1882%20%20%20%200.0627%0D%0A%20%20%20%200.6863%20%20%20%200.7098%20%20%20%200.2902%0D%0A%20%20%20%200.8863%20%20%20%200.9059%20%20%20%200.2549http://../Fall%202007/Lectures/%20%20%20%200.1804%20%20%20%200.1882%20%20%20%200.0627%0D%0A%20%20%20%200.6863%20%20%20%200.7098%20%20%20%200.2902%0D%0A%20%20%20%200.8863%20%20%20%200.9059%20%20%20%200.2549 -
7/25/2019 02_DigitalImagesAndMatlab (1).ppt
18/32
-
7/25/2019 02_DigitalImagesAndMatlab (1).ppt
19/32
-
7/25/2019 02_DigitalImagesAndMatlab (1).ppt
20/32
7o&orma!!e Image, Inices, = 7o&or a!
>> [M,CMAP] = imread(button_mapped.bmp,bmp);
! "# "# $ "# $
$ ! "# !
! "# $ "# $ ! "# ! $
$% $.&'## $."$& $.#" $ $.!%& $.'&% $.!#!"
$."$& $."' $.'%& ! $.' $."$# $.&'##
$.!#!" $.!%& $."'
$% !$ !&
$ '& "$ ! !$ ## '! ! & $"
! '&
##
Indices contained in &'!"(:!"),!"(:!")* actual values in +&P'#-:##,:*
!""/+&P'#-:##,:*
0 1 2
0 1 2Last
cols.only
February 9, 2016 20
-
7/25/2019 02_DigitalImagesAndMatlab (1).ppt
21/32
>o/ to conert a co&orma!!e image to true co&or
>> [M,*map] = imread(button_mapped.bmp,bmp);
>> + = uint#(re-ape(*map(M,/),[i0e(M) ])1!'');
& is a "#!x"#!x#, )3bit image.It has !4!,#(( %ixels.5ach %ixel has a value between 6 !"".
cma% is the colorma% that is stored in 7button8ma%%ed.bm%9along with image. cma% is a !"4x ty%e3double matrix, eachrow of which lists a color in terms of its 0, 1, 6 2 intensities,which are given as fractions between and #.
2y concatenating &9s columns, &atlabrearranges & into a !4!,#(( x # list. 5achnumber in the list 'if it has # added to it*refers to a row of the colorma%. hen,cma%'&;#,:* %roduces a !4!,#(( x matrix ofintensity values of ty%e double between 6 #.
he !4!,#(( x matrix ofintensity values is resha%edinto a "#!x"#!x image ofty%e double. he values arescaled to lie between 6 !""then converted to ty%e uint).
['! '!]
February 9, 2016 21
-
7/25/2019 02_DigitalImagesAndMatlab (1).ppt
22/32
?aing Images as Fi&es
>>>> 2 true*o3or a .bmp
>> im4rite(5,ima6e_name.bmp,bmp);>>
>> 2 true*o3or a .7p6 (de8au3t 9ua3it: = ')
>> im4rite(5,ima6e_name.7p6,7p6);
>>>> 2 true*o3or a .7p6 (9ua3it: = $$)
>> im4rite(5,ima6e_name.7p6,7p6,ua3it:,$$);
>>>> 2 *o3ormapped a .bmp
>> im4rite(5,*map,ima6e_name.bmp,bmp);>>
>> 2 *o3ormapped a .6i8
>> im4rite(5,*map,ima6e_name.6i8,6i8);>>
ssuming that7I9 contains the imageof the correct class,
that
7cma%9 is a colorma%,and that
7image8name9 is thefile3name that youwant.
February 9, 2016 22
-
7/25/2019 02_DigitalImagesAndMatlab (1).ppt
23/32
he 5cstasy of +ecelia
%oub&e
-
7/25/2019 02_DigitalImagesAndMatlab (1).ppt
24/32
>> *d
-
7/25/2019 02_DigitalImagesAndMatlab (1).ppt
25/32
%oub&e > B = imread( ima6e(B)
>> truei0e
>> tit3e( F3abe3( MG = imread( ima6e(MG)>> truei0e
>> tit3e( F3abe3( [GMG,CMG,MG] = i0e(MG);
>> [GB,CB,B] = i0e(B);
>> rb = round((GBDGMG)I!);
>> *b = round((CBDCMG)I!);>> Bp3uMG = uint#((doub3e(B(rb/(rbGMGD),*b/(*bCMGD),/))doub3e(MG))I!);
>> 8i6ure
>> ima6e(Bp3uMG)>> truei0e
>> tit3e( F3abe3(
-
7/25/2019 02_DigitalImagesAndMatlab (1).ppt
26/32
>> *d
-
7/25/2019 02_DigitalImagesAndMatlab (1).ppt
27/32
>> *d
-
7/25/2019 02_DigitalImagesAndMatlab (1).ppt
28/32
Intensity asing:u&ti!&ying /o Images
he 5cstasy of +ecelia
0ayden =oodring > 2um%erillo 5cstasy '?*
February 9, 2016 2;
-
7/25/2019 02_DigitalImagesAndMatlab (1).ppt
29/32
Intensity asing: u&ti!&ying /o Images>> B = imread( rb = round((GBDGMG)I!);
>> *b = round((CBDCMG)I!);
>> Bp3uMG = uint#((doub3e(B(rb/(rbGMGD),*b/(*bCMGD),/))doub3e(MG))I!);
>> 8i6ure
>> ima6e(Bp3uMG)
>> truei0e
>> tit3e( F3abe3( BtimeMG = doub3e(B(rb/(rbGMGD),*b/(*bCMGD),/)).1doub3e(MG);
>> M = maF(BtimeMG(/));
>> m = min(BtimeMG(/));
>> BtimeMG = uint#(!''1(doub3e(BtimeMG)Dm)I(MDm));
>> 8i6ure>> ima6e(BtimeMG)
>> truei0e
>> tit3e(
-
7/25/2019 02_DigitalImagesAndMatlab (1).ppt
30/32
Intensity asing: u&ti!&ying /o Images>> B = imread( rb = round((GBDGMG)I!);
>> *b = round((CBDCMG)I!);
>> Bp3uMG = uint#((doub3e(B(rb/(rbGMGD),*b/(*bCMGD),/))doub3e(MG))I!);
>> 8i6ure
>> ima6e(Bp3uMG)
>> truei0e
>> tit3e( F3abe3( BtimeMG = doub3e(B(rb/(rbGMGD),*b/(*bCMGD),/)).1doub3e(MG);
>> M = maF(BtimeMG(/));
>> m = min(BtimeMG(/));
>> BtimeMG = uint#(!''1(doub3e(BtimeMG)Dm)I(MDm));
>> 8i6ure>> ima6e(BtimeMG)
>> truei0e
>> tit3e(
-
7/25/2019 02_DigitalImagesAndMatlab (1).ppt
31/32
Pie& Ineing in at&ab>> 5 = imread(> r = randperm('&);>> * = randperm();
>> B = 5(r,*,/);>> 8i6ure
>> ima6e(B)
>> truei0e>> tit3e( F3abe3(
-
7/25/2019 02_DigitalImagesAndMatlab (1).ppt
32/32
Pie& Ineing in at&ab
>> >> F3abe3( (r,*,/) = B;
>> 8i6ure
>> ima6e()>> truei0e>> tit3e( F3abe3(