12.07.2015 Views

Basics of MATLAB and Beyond

Basics of MATLAB and Beyond

Basics of MATLAB and Beyond

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

An Application <strong>of</strong> RGB ImagesTo see how RGB images can be used, we look at how an image can befiltered. An image <strong>of</strong> the Cat’s Eye Nebula, which is stored on disk as aJPEG image, can be read into matlab using the imread comm<strong>and</strong>:>> q = imread(’ngc6543a.jpg’);>> size(q)ans =650 600 3The result is a 650×600×3 matrix, where the “pages” represent respectivered, green, <strong>and</strong> blue intensities. We can display the image by typing:image(q)axis image <strong>of</strong>f(See page 120 for a description <strong>of</strong> axis image.) On your screen thisappears as a colour image. Suppose we want to filter out the red component.We do this by setting the first “page”, the red component <strong>of</strong>the image, equal to zero. First we take a copy <strong>of</strong> the original so we canlater plot the two images side by side:q_original = q;q(:,:,1) = 0;subplot(221)image(q_original)axis image <strong>of</strong>fsubplot(222)image(q)axis image <strong>of</strong>f29.4 Example: SonarLet us look at some sonar data consisting <strong>of</strong> sound spectral power levelsmeasured as a function <strong>of</strong> frequency, direction <strong>of</strong> arrival, <strong>and</strong> time. Loadthis data from the file sonar.mat:>> load sonarc○ 2000 by CRC Press LLC

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!