Images and MATLAB. Matlab Advantages. Every variable in Matlab is a multidimensional matrix. Highly modular. No memory allocation is necessary. Matlab enables its own garbage collection. Simple interface for complex mathematical concepts. Image Types.
Une image / un lien ci-dessous est fourni (tel quel) pour télécharger la présentation
Politique de téléchargement : le contenu du site vous est fourni TEL QUEL pour votre information et votre usage personnel ; il ne peut être vendu, concédé sous licence ni partagé sur d’autres sites sans l’accord de son auteur.Le contenu vous est fourni TEL QUEL, pour votre information et votre usage personnel uniquement.Téléchargez la présentation en cliquant sur ce lien.Lors du téléchargement, si vous ne parvenez pas à télécharger une présentation, l’éditeur a peut-être supprimé le fichier de son serveur.Pendant le téléchargement, si vous ne parvenez pas à obtenir une présentation, le fichier a peut-être été supprimé par l’éditeur.
Matlab Advantages • Every variable in Matlab is a multidimensional matrix. • Highly modular. • No memory allocation is necessary. • Matlab enables its own garbage collection. • Simple interface for complex mathematical concepts.
Image Types • Intensity imagesscaled to represent intensities (uint8 – [0,255], double [0,1]) • Binary imageslogical array of 0s and 1s • Indexed imagesLook up table [x, map] • RGB imagestruecolor, array of (m*n*3) Checking the image type : isind, isbw, isgray, isrgbConverting image types: rgb2ind, rgb2gray, gray2ind, ind2gray,….
Data Classes Converting between types : B = data_class_name(A)for example: B = double(A)
Conversions • When converting between data classes and types it is important to keep the value range for each data class >> img = double(img)/255; >> img = im2double(img);
MATLAB supported image formats • JPEG: Joint Photographics Experts Group • TIFF: Tagged Image File Format • GIF: Graphics Interchange Format • BMP: Microsoft Bitmap Format • PNG: Portable Network Graphics • …
Displaying an image(cont.) • imshow(I, [low, high]) • imshow(I, [ ]) 功用:displays I as a grayscale intensity image, specifying the data range for I. The minimum value in I is displayed as black, and the maximum value is displayed as white. • pixval : 功能:cursor on image to show pixel values 用法: imshow(I),pixval
Displaying an image(cont.) • colorbar • 功能:To display an image with a colorbar that indicates the range of intensity values. • 用法: imshow(I), colorbar ex: I = imread('pout.tif'); imshow(I) , colorbar
Image information • whos 功用:display information about an image . • ex: whos I • Imfinfo( filename ) 功用: display information about image file . • ex: info = imfinfo('saturn.png')
Digital Image processing • 影像二元化 • g = im2bw(I, T); • 功用:Convert intensity image I to binary image g using threshold T, where T must be in range [0, 1]. ex: I= imread('pout.tif'); g = im2bw(I, 0.4); imshow(g); colorbar
Digital Image processing(cont.) • 反相 • imcomplement( ) • 功用:The negative of an image. ex: I2= imread ('onion.png'); figure,imshow(I2); colorbar J2 = imcomplement(g2); figure, imshow(J2); colorbar
Grayscale images 灰階影像 • Matlab example: • w=imread('pout.tif'); • figure, imshow(w), pixval on • figure: create a window to place graphic object • imshow: display matrix • Data type of w? • 291x240 uint8 (unsigned integer 8 bits
Binary image 二元影像 • Matlab example: • w2=imread('circles.png'); • figure, imshow(w2), pixval on • Data type of w? • 256x256 logical • Pixel value is 0 or 1
Pixel depth • Pixel depth: the number of bits used to represent each pixel in RGB space • Full-color image: 24-bit RGB color image • (R, G, B) = (8 bits, 8 bits, 8 bits)
Indexed color image 彩色索引影像 • Matlab example: • wI=imread('trees.tif'); • figure, imshow(w), pixval on • What’s wrong?
Data types and conversion • uint8 image must be converted to double before any arithmetic operation • w=imread('pout.tif'); • w=w+1; % fail • w=double(w); % data type is also conversion func. • w=w+1; % ok
Write image matrix to file • Matlab code • w=imread('pout.tif'); • imwrite(w, 'pout.jpg','jpg'); • General form • imwrite(X, map, ‘filename’, ‘format’);
Zooming and Shrinking Digital Images • Zooming: • Create a new pixel location. • Assign a gray-level to those new locations • Nearest neighbor interpolation • Pixel replication: a checkboard effect • Bilinear interpolation using four nearest neighbors • v(x’, y’)=ax’+by’+cx’y’+d • where a, b, c, and d are determined from the gray-level of the four neighbors. • Shrinking: • Direct shrinking causes aliasing • Expansion then Shrinking: blurring the image before shrinking it and reduce aliasing.
Sampling Methods of Inverse Mapping • If transformed pixel ‘X’ locates among • P1, P2, P3 and P4 • Nearest neighbor method: • I(‘X’) = I(P3 ) • where I(p) is the intensity value of pixel p • Bi-linear interpolation: I(‘X’) = (1-a)(1-b)I( P1 ) + a(1-b)I(P2 ) + (1-a)bI(P3 )+ abI(P4 ) where a, b are the fractional parts of ‘X’ • Bi-cubic interpolation: based on cubic splines P2 P1 P3 P4
Nearest neighbor interpolation • The closest neighbor is chosen , by rounding the “new” indexes to original image’s coordinates .
Digital Image processing(cont.) • 變更影像大小 • imresize(I,scale,method); • 功用:To change the size of an image. • interpolation Method: -'nearest‘ :Nearest-neighbor interpolation -'bilinear‘ :Bilinear (the default) -'bicubic‘ :Bicubic interpolation
Digital Image processing(cont.) • 變更影像大小 • imresize(I,scale,method); • 功用:To change the size of an image. • interpolation Method: -'nearest‘ :Nearest-neighbor interpolation -'bilinear‘ :Bilinear (the default) -'bicubic‘ :Bicubic interpolation