Académique Documents
Professionnel Documents
Culture Documents
sur
le Traitement numérique
des images
1
TP1
Familiarisation avec,
Les manipulations de base des images numériques sous Matlab
1 . Objectifs
Matlab considère les images comme des matrices. Il utilise 2 types de données (8
bits, 64 bits) et 2 types d’images (Indexed images, TrueColor images).
– Indexed images : Matrices 2D dont les coefficients sont des indices de la table
des couleurs (colormap).
– 8-bit data (unsigned bytes ou uint8) : Les valeurs vont de 0 à 255. Dans le cas
d’images indexées, 1 correspond à la première ligne de la table des couleurs
(colormap). Ce format réduit l’utilisation de la mémoire mais ne permet pas
d’opérations algébriques sur les coefficients.
Pour trouver les spécifications d’une command matlab, taper “help command”.
3. Manipulations de base
>>
2
Name Size Bytes Class
ans =
0 0 0
0.0207 0.0207 0.0207
0.0337 0.0337 0.0337
0.0447 0.0447 0.0447
0.0547 0.0547 0.0547
0.0640 0.0640 0.0640
0.0727 0.0727 0.0727
0.0809 0.0809 0.0809
0.0889 0.0889 0.0889
0.0965 0.0965 0.0965
0.1039 0.1039 0.1039
0.1111 0.1111 0.1111
0.1180 0.1180 0.1180
0.1248 0.1248 0.1248
0.1315 0.1315 0.1315
0.1380 0.1380 0.1380
0.1444 0.1444 0.1444
0.1506 0.1506 0.1506
0.1568 0.1568 0.1568
0.1628 0.1628 0.1628
>>
figure(1);imshow(X, map) %Affiche en niveau de gris the indexed image X with the
colormap(map)
colorbar('vert') %COLORBAR Display color bar (color scale)
figure(2); imagesc(X);
colorbar('vert') %Affichage de l'image et la barre de couleur
3
colormap(gray); %Affichage de l'image en niveau de gris (N&B)
>>
Sa =
301 447
Smap =
4
256 3
a15 =
45 115 123 123 142
107 214 231 216 231
85 231 196 173 231
85 231 215 173 231
83 214 194 215 196
map15 =
1.0000 1.0000 1.0000
0 1.0000 1.0000
1.0000 0 1.0000
0 0 1.0000
1.0000 0.9686 0.9686
c=
Filename: 'flowers.tif'
FileModDate: '25-Oct-1996 23:11:10'
FileSize: 543962
Format: 'tif'
FormatVersion: []
Width: 500
Height: 362
BitDepth: 24
ColorType: 'truecolor'
FormatSignature: [73 73 42 0]
ByteOrder: 'little-endian'
NewSubfileType: 0
BitsPerSample: [8 8 8]
Compression: 'Uncompressed'
PhotometricInterpretation: 'RGB'
StripOffsets: [73x1 double]
SamplesPerPixel: 3
RowsPerStrip: 5
StripByteCounts: [73x1 double]
XResolution: 72
YResolution: 72
ResolutionUnit: 'Inch'
Colormap: []
PlanarConfiguration: 'Chunky'
TileWidth: []
TileLength: []
TileOffsets: []
TileByteCounts: []
Orientation: 1
FillOrder: 1
GrayResponseUnit: 0.0100
MaxSampleValue: [255 255 255]
MinSampleValue: 0
Thresholding: 1
ImageDescription: [1x173 char]
ans =
0 0 0.5625
0 0 0.6250
0 0 0.6875
0 0 0.7500
0 0 0.8125
0 0 0.8750
0 0 0.9375
0 0 1.0000
0 0.0625 1.0000
0 0.1250 1.0000
0 0.1875 1.0000
0 0.2500 1.0000
0 0.3125 1.0000
0 0.3750 1.0000
0 0.4375 1.0000
>>
5
Afficher en ‘’gary’’ l’image ‘’woman2’’ et en ‘’jet’’ l’image ‘’flujet’’.
load flujet
figure(2);image(X)
colormap(jet);
colorbar('vert')
load spine
figure(3);image(X)
colormap(bone)
colorbar('vert')
6
colormap(hsv);
c=hsv2rgb(map); %h=rgb2hsv
colormap(c)
Changer le format de l’image (de « tif » en « jpg » par exemple) puis regarder les
informations.
362 500 3
c1 =
Filename: 'flowers.tif'
FileModDate: '25-Oct-1996 23:11:10'
FileSize: 543962
Format: 'tif'
FormatVersion: []
Width: 500
Height: 362
BitDepth: 24
ColorType: 'truecolor'
FormatSignature: [73 73 42 0]
ByteOrder: 'little-endian'
NewSubfileType: 0
BitsPerSample: [8 8 8]
7
Compression: 'Uncompressed'
PhotometricInterpretation: 'RGB'
StripOffsets: [73x1 double]
SamplesPerPixel: 3
RowsPerStrip: 5
StripByteCounts: [73x1 double]
XResolution: 72
YResolution: 72
ResolutionUnit: 'Inch'
Colormap: []
PlanarConfiguration: 'Chunky'
TileWidth: []
TileLength: []
TileOffsets: []
TileByteCounts: []
Orientation: 1
FillOrder: 1
GrayResponseUnit: 0.0100
MaxSampleValue: [255 255 255]
MinSampleValue: 0
Thresholding: 1
ImageDescription: [1x173 char]
Filename: 'jham'
FileModDate: '03-Mar-2010 20:42:53'
FileSize: 39640
Format: 'jpg'
FormatVersion: ''
Width: 500
Height: 362
BitDepth: 24
ColorType: 'truecolor'
FormatSignature: ''
Filename: 'bham'
FileModDate: '03-Mar-2010 20:42:53'
FileSize: 543054
Format: 'bmp'
FormatVersion: 'Version 3 (Microsoft Windows 3.x)'
Width: 500
Height: 362
BitDepth: 24
8
ColorType: 'truecolor'
FormatSignature: 'BM'
NumColormapEntries: 0
Colormap: []
RedMask: []
GreenMask: []
BlueMask: []
ImageDataOffset: 54
BitmapHeaderSize: 40
NumPlanes: 1
CompressionType: 'none'
BitmapSize: 543000
HorzResolution: 0
VertResolution: 0
NumColorsUsed: 0
NumImportantColors: 0
>>