280 likes | 293 Views
Explore the basics of image acquisition, sampling, quantization, and storage media in digital image processing. Learn about image formats, operations, and image models with Prof. Amr Goneid from AUC.
E N D
Digital Image Processing&Pattern Analysis (CSCE 563) Fundamentals Prof. Amr Goneid Department of Computer Science & Engineering The American University in Cairo
Image Acquisition & Display • Image Models • Sampling & Quantization • Storage Media • Image Formats • Representation in MATLAB • Loading, Saving and Display • Types of Image Operations • Types of Neighborhoods Prof. Amr Goneid, AUC
Real Image Model A 2-D Signal with amplitude a(x,y) representing light intensity or color at real position (x,y). Amplitude is normally a real number or an integer number. An image may contain a Region of Interest (ROI) (i.e. a sub-image) Signal y ROI a(x,y) x Prof. Amr Goneid, AUC
Digital Image Model An acquisition device converts a real (analog) image a(x,y) into a digital image. Sampling and quantization comprise the digitization process. The output is a matrix f(i,j) of pixels with n rows and m columns. a(x,y) Sampling & Quantization f(i,j) Prof. Amr Goneid, AUC
Image Acquisition:Sampling & Quantization • Sampling Sample at x,y = one pixel at f(i,j) y y x S(x,y) = average Intensity over the area x y Sampling Rate affects image size x Prof. Amr Goneid, AUC
Sampling: Spatial Resolution Low Resolution High Resolution Prof. Amr Goneid, AUC
Sampling & Quantization • Quantization Digital Image f(x,y) Fk+1 f11 f12 … f1m f21 f22 … f2m S(x,y) Fk y fij Fk-1 x Pixel value fn1 fn2 … fnm Prof. Amr Goneid, AUC
Quantization: Color Resolution 16 Colors 256 colors Quantization scale determines number of bits per pixel Prof. Amr Goneid, AUC
Image Storage Media • Magnetic & Video Tapes • Magnetic Disks • Optical Disks ( CD ) Prof. Amr Goneid, AUC
Storage Requirements • Image Size: n x m pixels • n , m depend on sampling rate • B = no. of bits to represent a pixel • L = no. of Quantization levels (gray levels or colors) = 2B • Storage size = n m B/8 bytes • e.g. for 128 x 128 pixels with 256 colors the size is 16 kbytes • When B = 1 we have a Binary Image (Black & White) Prof. Amr Goneid, AUC
Image Formats • Graphics Interchange Format ( .GIF) • Tagged Image File Format (.TIFF) • Bit Map Format (.BMP) • ISO Standard Format (.JPEG , .JPG , .JPE) • Other Formats ( .PCX , .CGI , .PNG, etc) • Viewers ( Image Viewing S/W) Prof. Amr Goneid, AUC
Image Formats 302 Kb (BMP) 80 Kb (jpg) Prof. Amr Goneid, AUC
Representation in MATLAB • Intensity Images (Gray Scale) • Indexed Images • RGB Images • Binary Images • Conversion between Formats • Loading & Saving Images • Displaying Images in MATLAB Prof. Amr Goneid, AUC
Intensity Images • Used for Gray Scale images • One matrix I = f(n,m) • Each pixel f(i,j) is a real number (r) with 0 =< r <= 1 ( 0 : black; 1 : white) Prof. Amr Goneid, AUC
Indexed Images Prof. Amr Goneid, AUC
Indexed Images • For color (and gray scale images) • Uses a color map and a matrix X = f(n,m) with a pixel value f(i,j) = index to the map , • map is (m x 3) array, m = no. of colors • e.g. f(i,j) = 23 G R B 23 0.3 0.1 0.2 Color Map Prof. Amr Goneid, AUC
RGB Images • For color images.Uses 3 matrices : R(n,m) , G(n,m) , B(n,m) • R(i,j) is the red color intensity, etc. RGB R G B Prof. Amr Goneid, AUC
RGB Planes A pixel at (i,j) in an RGB image has components: R(i,j) , G(i,j) , B(i,j) In MATLAB, it is possible to extract the 3 components: If F is an RGB image, FR = F(: , : , 1); FG = F(: , : , 2); FB = F(: , : , 3); B G R Summer 2008 Prof. Amr Goneid, AUC Prof. Amr Goneid, AUC 18
Binary Images • For Black and White images • One matrix B = f(n,m) where a pixel value is f(i,j) = 0 or 1 Prof. Amr Goneid, AUC
Conversion between Formats im2bw ind2rgb Indexed gray2ind rgb2ind RGB Binary gray2ind ind2gray rgb2gray im2bw edge Intensity Prof. Amr Goneid, AUC
Loading & Saving Images • MATLAB reads disk formats and converts to pixel matrices • e.g. for BMP files: [X,map] = imread(‘filename.bmp’) imwrite(X,map,’filename.bmp’) • Some of the types supported: BMP JPG GIF TIFF PCX • Matrix format can be saved on disk: save filenameX map • Matrix format files can be loaded from disk: load filename Prof. Amr Goneid, AUC
Displaying Images in MATLAB • Indexed Images: imshow(X,map) • Intensity Images: imshow(I) • RGB Images: imshow(RGB_image) • Binary Images: imshow(BW) , imshow(~BW) Prof. Amr Goneid, AUC
Example1input color image, output red image [X,map] = imread(‘eaglec.bmp’); % Read eaglec.bmp from disk [n,m] = size(X); % Image size save eaglec X map; % Save in matrix form _________________________________________________ load eaglec; % Load matrix form imshow(X,map); % Display image [L , C] = size(map); % L rows by 3 columns map(: , 2) = zeros(L , 1); % zero green map(: , 3) = zeros(L , 1); % zero blue % now the map contains only red imwrite( X , map , ‘eagler.bmp) % write red image Prof. Amr Goneid, AUC
Example2Convert to Intensity and Binary Images load eaglec; % Load matrix form imshow(X,map); % Display image I = ind2gray(X,map); % Convert to gray imshow(I); % Display BW = im2bw(I); % Convert to binary imshow(BW); % Display imshow(~BW); % Display negative Prof. Amr Goneid, AUC
Types of Image Operations(ref: http://www.ph.tn.tudelft.nl/Courses/FIP/noframes/fip.html ) The types of operations that can be applied to digital images to transform an input image f [m,n] into an output image f’[m,n] can be classified into three categories as shown in the Table. Prof. Amr Goneid, AUC
Types of Image Operations(ref: http://www.ph.tn.tudelft.nl/Courses/FIP/noframes/fip.html ) Prof. Amr Goneid, AUC
Neighborhood Prof. Amr Goneid, AUC
Types of Neighborhoods 4-connected 8-connected 6-connected Rectangular Hexagonal Prof. Amr Goneid, AUC