MATLAB LECTURE 1 Basic Concepts of Digital Image Processing IMAGE PROCESSING BASIC CONCEPT IP Basic Concepts In this lecture we will introduce some basic image processing concepts, including reading and showing image, performing some image enhancement operations on images, and getting information about an image. Step 1: Read and Display an Image Step 2: Check How the Image Appears in the Workspace Step 3: Image Sampling (Resizing Image) Step 4: Image Quantization (Gray Level Reduction) Step 5: Converting RGB image into grayscale intensity image. STEP 1: READ AND DISPLAY AN IMAGE To Clear Matlab workspace, variables, and figure windows. >> close all To read an image, use the imread command. In the example below reads one of the sample images included with IPT, pout.tif, and stores it in an array named I. Example : >> I = imread('pout.tif'); To display the image, Use the imshow command >> imshow(I) STEP 2: CHECK HOW THE IMAGE APPEARS IN THE WORKSPACE The Workspace browser displays information about all the variables you create during a MATLAB session. The imread function returned the image data in the variable I, which is a 291by-240 element array of uint8 data. MATLAB can store images as uint8, uint16, or double arrays. You can also get information about variables in the workspace by calling the whos command. >>whos Name Size Bytes Class I 291x240 69840 uint8 array STEP3: IMAGE SAMPLING MATLAB: IMRESIZE Resize an image To change the size of an image, use the imresize function. Using imresize, you can specify the size of the output image, specify the interpolation method used, and specify the filter to use to prevent aliasing. Resize Syntax: B = imresize(A,m) B = imresize(A,m,method) B = imresize(A,[mrows ncols],method) B = imresize(...,method,n) B = imresize(...,method,h) DESCRIPTION OF IMRESIZE B = imresize(A,m) returns an image B that is m times the size of A, using nearest-neighbor interpolation. B = imresize(A,m,method) returns an image that is m times the size of A using the interpolation method specified by method. B = imresize(A,[mrows ncols],method) returns an image of the size specified by [mrows ncols]. When the specified output size is smaller than the size of the input image, and method is 'bilinear' or 'bicubic', applies lowpass aliasing. EXAMPLE: SAMPLING (EXAMPLE OF RESIZE) STEP 4: IMAGE QUANTIZATION (GRAY LEVEL REDUCTION) The quantization used to reduce the number of gray levels. Reducing the number of gray levels using the floor function. Floor function is used in the following sytax: X = floor(y/2)*2; It is used to reduce the gray levels in an image. You can divide many times according to the given gray level to see how the image is resulting from reducing the gray levels as in the following figure: IMAGE QUANTIZATION EXAMPLE CONVERTING IMAGE TYPES STEP 5: CONVERTING RGB IMAGE INTO GRAYSCALE INTENSITY IMAGE. rgb2gray Converts RGB image to grayscale. Syntax I = rgb2gray(RGB) Description I = rgb2gray(RGB) converts the truecolor image RGB to the grayscale intensity image I.