EE 20 Lab 02 Image and Video Processing
v=[1:64];
image(v);
//generate a default gradient image
map=colormap
//to see colormap numerically
size(map)
//ans = 1 3
//to verify the size of the map
//Notice that it has 64 rows and three columns. Each row is one entry
in the colormap. The three
columns give the amounts of red, green, and blue respectively in the
colormap.
//These amounts range
from 0 (none of the color present) to 1.0 (the maximum amount of the
color possible).
map=gray(256);
colormap(map);
//generate a plain gray
image([1:256]);
//generate a gray gradient
map=white(256);
axis image
//force matlab not to stretch
cd U:
cd lab02
//change to directory
imfinfo('helen.jpg')
//get image information
helen=imread('helen.jpg');
//image read
image(helen);
//display image in a stretched version
axis image
//display image in the original dimension
whos
//display info of everything in the workspace
pixel = helen(1,1,:)
//upper left pixel of the image (3 basic colors)
//looks like bright color is high number, dark color is small number
whos helen
//display the array information
rgb=squeeze(pixel)
//squeeze the info for array of length one
helen = imread('helen.jpg');
image(helen)
axis image
red = helen(:,:,1);
image(red), axis image
//display only the red color
bwImage = double(red);
image(bwImage), axis image
colormap(gray(256))
//The first line converts the image to an array of doubles instead of unsigned
8-bit integers
because Matlab cannot operate numerically on unsigned 8-bit integers. The
remaining two
lines simply display the image using a grayscale colormap.
|