To display image ETC - To display image: 1. For color...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: To display image: 1. For color image, use [img,map]=imread(‘bla.jpg’); %read in the image to matrix img and the colormap into map figure, image(img), axis equal, colormap(map) %This will display the color image 2. For gray image, use img=imread(‘bla.jpg’); %read in the image to matrix img figure, imagesc(img), axis equal, colormap(gray) % intensity will be scaled (while image() won’t) The Image Processing Toolbox comes with imshow() that takes care of color and gray automatically. To convert from rgb to gray: Suppose you have a RGB image (of double class), use the standard NTSC conversion formula intensity = 0.2989*red + 0.5870*green + 0.1140*blue The following code show this: % Assume you have an RGB image of class double, or create a random one rgb = rand(200,200,3); % Convert it gray = 0.2989 * rgb(:,:,1) + 0.5870 * rgb(:,:,2) + 0.1140 * rgb(:,:,3); The directory structure in Matlab: 1. You can read files from a subdirectory, change directory, write a file in a subdirectory,…, in Matlab. Indeed, Matlab has a structure dir: listing = dir('name') returns attributes about name to an m‐by‐1 structure, where m is the number of files or folders in name. For example, a = dir(‘images’) will return the names of all the files and folders in subdirectory named “images” and for each file or folder, a has an entry with following structure: name date bytes isdir datenum So, to get the file or folder name of a(2), we use a(2).name 2. Please view‐basics‐getting‐a‐directory‐listing/ ...
View Full Document

This note was uploaded on 01/16/2012 for the course MAD 4103 taught by Professor Li during the Spring '11 term at University of Central Florida.

Ask a homework question - tutors are online