1.04k likes | 1.17k Views
Lecture 3 Dr. Roger S. Gaborski. Introduction to Computer Vision. Image Models. Task: “ Look for an object in an image ” Assume the task is to find rectangle and washer objects. Image models, continued. Image Models. Task: “ Look for an object in an image ”
E N D
Lecture 3 Dr. Roger S. Gaborski Introduction to Computer Vision Roger S. Gaborski
Image Models • Task: “Look for an object in an image” • Assume the task is to find rectangle and washer objects RS Gaborski
Image models, continued RS Gaborski
Image Models • Task: “Look for an object in an image” • Assume the task is to find rectangle and washer objects • Find edge pixels and group • Find outlines of objects in the image • Create a model of the object • Rectangle: Four straight lines, Opposite lines equal in length, 90 degree angles, lines connected • Washer: Two concentric circles RS Gaborski
Image models, edges RS Gaborski
Matlab Example Roger S. Gaborski
Image models, continued One object partially overlaps another RS Gaborski
Objects are 3 Dimensional Rotating Disk Frame 1 Frame 2 Frame 3 RS Gaborski
License Plate Model • Rectangular (depending on viewpoint) • Aspect ratio 2:1 • Textures (characters on license plate) RS Gaborski
Face Model http://www.faceresearch.org/ RS Gaborski
Face Model http://www.faceresearch.org/ RS Gaborski
Face Model Features: eyes, nose, mouth, shape of face (oval) Spatial orientation of features Issues to investigate: how do we detect features? Normalize for different faces? Scale? Orientation? Cluttered background? RS Gaborski
Finding Cars in ImagesTraining – Modeling Parts RS Gaborski
Testing RS Gaborski
What’s Missing? • perceptual organization • similarity between semantic concepts “The semantic gap” RS Gaborski
Examples of “semantic” similarity From: http://web.cecs.pdx.edu/~mm/ RS Gaborski
From: http://web.cecs.pdx.edu/~mm/ RS Gaborski
SUMMARY: Digital Images • Matrix of numbers • Each number represents a picture element – ‘pixel’ • Pixels are parameterized by • x – y position • intensity (color or monochrome) • time • MATLAB is designed for processing matrices (Matrix Laboratory) RS Gaborski
Overview • Image displaying • Image types • Image adjustment • Gamma transformation • Logarithmic transformation • Component segmentation • Histogram distribution Roger S. Gaborski
A Few Typical Operationswith Images >> ls *jpg OrangeFlower.jpgPatternOne.jpg >> I = imread('OrangeFlower.jpg'); >> whos I Name Size Bytes Class Attributes I 1880x2816x3 15882240 uint8 Roger S. Gaborski
What are maximum and minimum pixel values of I? >> mx = max(I(:)) mx = 255 >> mn = min(I(:)) mn = 0 Roger S. Gaborski
Displaying Images [0, 255] • Consider we would like to display a gray level image that has a possible range of values 0-255 • When we display the image we can arrange for each gray level value to be displayed as a different light level on the display • Black would map to the gray level 0, white would map to the gray level 255. • Gray level values between 0 and 255 would map to shades of gray. Roger S. Gaborski
figure, imshow(I,'InitialMagnification' ,'fit') Roger S. Gaborski
RECALL: Displaying Images [0,1] • The gray level of images can also be represented by real value numbers between 0 and 1. • 0 represents pixels that are black, 1 represents pixels that are white. • Values between 0 and 1 represent gray level values. Roger S. Gaborski
im = uint8([0 50 100; 100 125 200; 200 250 275]) im is of type uint8. What values are min and max values contained in im ? What is the ‘shape’ of variable im? Roger S. Gaborski
im = uint8([0 50 100; 100 125 200; 200 250 275]) im is of type uint8. What values are contained in im ? >> im im = 0 50 100 100 125 200 200 250 255 im is a 3x3 matrix Roger S. Gaborski
Displaying Images >> figure, imshow(im, 'InitialMagnification' ,'fit') >> title('im') What is contrast? Roger S. Gaborski
Range of Gray Level Values • The maximum range of values is [0,1] or [0,255] (for 8 bit images) • It is possible for images to use the maximum range of gray level values, or a subset of possible values • An image may only contain values between 0 and 0.6, or 0.3 and 0.9 • Is the contrast the same? How does the appearance differ? Roger S. Gaborski
Describe the displayed image A >> A = [.14 .15 ; .16 .17] A = 0.1400 0.1500 0.1600 0.1700 >> figure, imshow(A, 'InitialMagnification' ,'fit') Roger S. Gaborski
WHY? Roger S. Gaborski
figure, imshow(A, [ ],'InitialMagnification' ,'fit') The data in A didn’t change, only the display Roger S. Gaborski
mat2gray Change Actual Data Values: mat2gray Convert matrix to intensity image. I = mat2gray(A,[AMIN AMAX]) converts the matrix A to the intensity image I. The returned matrix I contains values in the range 0.0 (black) to 1.0 (full intensity or white). AMIN and AMAX are the values in A that correspond to 0.0 and 1.0 in I. Values less than AMIN become 0.0, and values greater than AMAX become 1.0. I = mat2gray(A) sets the values of AMIN and AMAX to the minimum and maximum values in A. Roger S. Gaborski
>> A A = 0.1400 0.1500 0.1600 0.1700 >> A1 = mat2gray(A) A1 = 0 0.3333 0.6667 1.0000 (Range is [0,1]) Roger S. Gaborski
B = 0.2800 0.3000 0.3200 0.3400 >> B = 2*A B = 0.2800 0.3000 0.3200 0.3400 >> B1 = mat2gray(B) B1 = 0 0.3333 0.6667 1.0000 Recall B = 2*A BUT B1 = A1 Roger S. Gaborski
B = 0 0.5000 5.0000 10.0000 >> B1 = mat2gray(B) B1 = 0 0.0500 0.5000 1.0000 (Range is [0,1]) Roger S. Gaborski
C = -10.0000 0.5000 5.0000 10.0000 >> C1 = mat2gray(B) C1 = 0 0.5250 0.7500 1.0000 The original range is -10 to +10 mat2gray converts the range to 0 to +1 Roger S. Gaborski
double and im2double >> Q=uint8([55, 100, 22]) Q = 55 100 22 >> whos Q Name Size Bytes Class Attributes Q 1x3 3 uint8 >> Qd = double(Q) What is the value of Qd? Roger S. Gaborski
>>> Qd = double(Q) Qd = 55 100 22 >> whos Q Qd Name Size Bytes Class Attributes Q 1x3 3 uint8 Qd 1x3 24 double >> Qid = im2double(Q) What is the value of Qid? Roger S. Gaborski
>> Qid = im2double(Q) Qid = 0.2157 0.3922 0.0863 >> whos Name Size Bytes Class Attributes Q 1x1 1 uint8 Qd 1x1 8 double Qid 1x1 8 double Roger S. Gaborski
>>> Qd = double(Q) Qd = 55 100 22 >> im2double(Qd) = ?????? Roger S. Gaborski
im2double(Qd) (Qd is already type double, no change) ans = 55 100 22 Roger S. Gaborski
Image Types • Intensity images • When elements are class uint8 or uint16 they have integer values in the range [0 255] or [0 65535] • When elements are class double values are floating point numbers. Values are scaled in the range [0 1] by convention • Pixels with value 0.0 are displayed as black • Pixels with value 1.0 are displayed as white • Binary images • RGB images • Indexed images Roger S. Gaborski
Intensity Image >> Im = imread('Flag.jpg'); >> whos I Name Size Bytes Class Attributes Im 320x240 76800 uint8 % Image is of class uint8, >> >> max(Im(:)) ans = 255 >> min(Im(:)) ans = 0 Range 0 to 255 (uint8) >> Im1 = im2double(Im); % Convert to class double >> max(Im1(:)) ans = 1 >> min(Im1(:)) ans = 0 Range now 0 to 1 (im2double) which is default format of images read from disk Roger S. Gaborski
Display Image >> Flag= im2double(imread(‘flag.jpg’)); >> figure, imshow(Flag), title(‘flag’);
Extract a Region of the Image >> imRegion = imcrop(Flag); >> figure, imshow(imRegion), title('imRegion') >> size(imRegion) ans = 321 321 3
R, G, B planes >> imshow(imRegion(:, :, 1)), title(‘RED’); >> imshow(imRegion(:, :, 2)), title(‘GREEN’); >> imshow(imRegion(:, :, 3)), title(‘BLUE’);
Display images imshow(Im) imshow(Im) uint8 im2double(I) Roger S. Gaborski