110 likes | 287 Views
Matlab Lecture 1. Basic Concepts of Digital Image Processing. Image processing Basic Concept. IP Basic Concepts
E N D
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 anImage • 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 Appearsin 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 291-by-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 SamplingMatlab: 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,[mrowsncols],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,[mrowsncols],method) returns an image of the size specified by [mrowsncols]. When the specified output size is smaller than the size of the input image, and method is 'bilinear' or 'bicubic', applies lowpass aliasing.
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:
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.