Beruflich Dokumente
Kultur Dokumente
CRD Labs
Color images
Color is critical to human understanding, but has not been widely used, until recently, for IP tasks. Colors, and more generally, multi-spectral images, contain more information than monochromatic images. Four prominent color models: RGB, CMY, YIQ, HIS/HSV The chromatic spectrum varies from 400nm to 700nm, and humans detect primary colors red (700 nm), green (546.1 nm) and blue (435.8 nm). Most display use this RGB model. (0,0,0) = black, (kkk) = white, (k,0,0) = red. Here k is the maximum value the quantization levels can take on, e.g., 256. Thus, for 24 bit color we can represent 2^24 colors.
CRD Labs
CMY Model
Based on secondary colors Realizes a subtractive color scheme. Yellow results when the blue is subtracted from white Red is realized when yellow and magenta are removed from white. This approach is used for hard copy devices.
CRD Labs
YIQ Model
Simple linear transform of RGB:
Y 0.299 0.587 0.114 R I 0.596 0.275 0.321 G Q 0.212 0.523 0.311 B Used in TV broadcasting Y component provides information for monochrome display. Exploits human visual system, since we are particularly sensitive to luminance.
CRD Labs
HIS Model
Most relevant to IP is Hue, Saturation, and Intensity (HIS) model Hue = perceived color which is approximately the dominant wavelength Saturation = dilution of color by white light
CRD Labs
CRD Labs
Indexed Images
Consists of a data matrix, I and a colormap matrix, C C is an m-by-3 matrix, with each row specifying the R, G, and B components of a single color. Values in C are floating point numbers in the range [0, 1] Color of each pixel is determined by using the corresponding value of I as an index into the colormap R G B
1
1 10
0 1
0 0
1 2
0.5
0.5
0.5
10
Image Example:. >> [x, map] = imread('forest.tif'); >> imshow(x, map) CRD Labs
Cybernetics Research & Development
Map
0.35
0.25 m
Intensity Images
Consists of a data matrix, I, whose values represent intensities within some range.
For double-precision data, the intensity values are in the range [0, 1], where 0 represents black, and 1 represents white.
Use the following to display intensity images. >> imagesc(I, [0, 1]); colormap(gray);
The second input argument [0, 1] to imagesc specifies the desired intensity range. I is displayed by first mapping the first value in the range to the first colormap entry, and second value in the range to the last colormap entry. Values in between are mapped linearly. To use another colormap, use the following >> colormap(hot); To automatically map the min value in I to the first colormap entry, and the max value in I to the last colormap entry, do the following. >> imagesc(I); colormap(gray);
CRD Labs
10
Consist of a m-by-n-by-3 data array, I, containing the R, G, and B components for each individual pixel
HumVee(:, :, 3)
HumVee(:, :, 1)
CRD Labs
Colormap
CRD Labs
Reading Images
BMP, HDF, JPEG, PCX, TIFF, XWD
12
MATLAB can read images of various formats including Use function imread to read image files
imread reads indexed, intensity, and truecolor images Images are read into a uint8 matrix of appropriate size
imread automatically determines the format of the image based on information in the header
You can specify a format as an optional second argument
CRD Labs
Writing Images
13
MATLAB can write images of various formats including the following BMP, HDF, JPEG, PCX, TIFF, PNG, PNM Use function imwrite to write image files imwrite determines the format from extension of filename
You can specify an optional format if extension is absent or to force a particular format
>> Abrams = imread(Abrams.jpg'); >> image(Abrams) >> whos Abrams Name Size Bytes Class Abrams 511x640x3 981120 uint8 array Grand total is 981120 elements using 981120 bytes >> AbramsGray = rgb2gray(Abrams); >> colormap gray; >> image(AbramsGray) >> imwrite(AbramsGray, 'Abrams.bmp');
CRD Labs
Summary
imread Used to read images imwrite Write matrices to specified image format imshow/image Display images imfinfo Retrieve information about image colormap Set/change colormap used for displaying image
CRD Labs
Use colorbar to add a colorbar to the image.. >> imshow(F,[-1 5]); >> colormap(jet),colorbar
CRD Labs
Image Arithmetic
Standard MATLAB arithmetic operators are defined for double data. The IP toolbox provides a set of functions to do arithmetic on other data types.
CRD Labs