04-06-2012, 10:24 AM
More on Images and Matlab
More on Images and Matlab.pdf (Size: 248.66 KB / Downloads: 269)
Matlab Data Types
• Different means of representing numbers
depending on what you want to do
• Examples:
– Floating point numbers for scientific applications
• 2.3543, -7.8956
– Integers: 1, 2, -7, 6354, -2333430948
– Unsigned integers for positive things (like pixel
values): 255, 7, 0
– True/false quantities (a.k.a. Boolean or logical)
take values of 1 or 0.
Representing numbers
• Computer memory arranges as set of bits organized into bytes.
– Bit = zero or one
– Byte = eight bits
• Each type of number is allocated a certain number of bytes
• 3 bit numbers integers
– 3 locations: b2b1b0
– Each bi can be 0 or 1
– Eight patterns: 000, 001, 010, 011, 100, 101, 110, 111
– How to interpret? Many ways.
Representing numbers
• Internal representation in computer a bit more
convoluted than this
– Based on something known as two’s complement
– Makes left bit really the sign bit (1 = negative and
0 = zero or positive)
– Makes hardware-based arithmetic easy
– Another way of interpreting the 256 patterns of
zeros and ones
• Floating point
– Really complicated story here. We’ll not touch it.
Displaying images
• colormap
– Many rows by 3 column matrix (R, G, B columns)
– Each column has doubles between 0 and 1 indicating intensity of
each coponent
– Grayscale images index into the rows
– See help for list of built in colormaps (gray, winer, autumn, cool,
hot, jet, …)
• image
– For grayscale, use colormap to set the colors
– For color images, works as expected
• imshow
– Works fine for uint8 and logical
– For binary images, make sure they are not uint8, but rather
logical
– For doubles, need to scale pixel values between 0 and 1
Matlab concepts covered
• Use of whos command to see contents of workspace
• Differences between image and imshow
• Use of colormap to provide false color to grayscale images
• Type casting with commands like double, logical, and
uint8
• Use of bitget to extract bitplanes from uint8 images
• Use of for loops
• Use of isa to find types
• Logical operators (and, or not, &, |, ~)
• Programming functions
– Use of error to do input checking
– Utility of comments