SUNY Geneseo Department of Mathematics
Wednesday, April 13
Math 230 02
Spring 2016
Prof. Doug Baldwin
imread reads image from file (e.g., JPEG)image creates (and displays) image from arrayimshow displays imageimfinfo returns structure that describes an image fileimwrite writes image to file>> % Make a black color swatch
>> swatch = zeros( 100, 100, 3 );
>> swatch = uint8( swatch );
>> % Display it
>> imshow( swatch )
>> % Make it white
>> swatch( :, :, : ) = 255;
>> imshow( swatch )
>> % Make it gray
>> swatch( :, :, : ) = 155;
>> imshow( swatch )
>> % Make it red-gray (dull pink)
>> swatch( :, :, 1 ) = 255;
>> imshow( swatch )
>> % Save the swatch as a JPEG file
>> imwrite( swatch, 'Swatch.jpg' );
>> % Read in another image and replace part of it by a piece of the pink color swatch
>> baldwinParlor = imread( 'BaldwinParlor.jpg' );
>> imshow( baldwinParlor )
>> size( baldwinParlor )
ans =
387 516 3
>> size( swatch )
ans =
100 100 3
>> baldwinParlor( 100:110, 100:110, : ) = swatch( 1:11, 1:11, : );
>> imshow( baldwinParlor )
>> % Check the numeric values of the colors in a section of the image
>> baldwinParlor( 10:15, 30:35, : )
ans(:,:,1) =
206 206 206 206 206 205
207 207 207 206 206 205
209 209 209 208 208 208
207 207 207 208 208 208
205 205 205 205 205 205
206 206 206 205 205 206
ans(:,:,2) =
207 207 207 207 207 206
207 207 207 206 206 205
209 209 209 208 208 208
207 207 207 208 208 208
205 205 205 205 205 205
206 206 206 205 205 206
ans(:,:,3) =
202 202 202 202 202 201
205 205 205 204 204 203
207 207 207 206 206 206
205 205 205 206 206 206
203 203 203 203 203 203
204 204 204 203 203 204chromakey( subject, background, ... )
look for subject pixels with RGB in certain range
replace found pixels in subject with same pixels f/ background