1 / 21

CMPS1371 Introduction to Computing for Engineers

IMAGES. CMPS1371 Introduction to Computing for Engineers. Images. Images are considered as matrices whose elements are the pixel values of the image. Images. Matlab has two main ways to represent an image that consists of M x N pixels:

Download Presentation

CMPS1371 Introduction to Computing for Engineers

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. IMAGES CMPS1371Introduction to Computing for Engineers

  2. Images Images are considered as matrices whose elements are the pixel values of the image

  3. Images Matlab has two main ways to represent an image that consists of M x N pixels: RGB or “true color” image: uses an MxNx3 array where the third index contains the RGB components Indexed color image: uses an MxN array containing integers that are the row entries in a “colormap” that defines the actual color.

  4. RGB Color Image • RGB: MxNx3 8-bit integer array N columns BLUE GREEN Each in range 0→255 RED [215, 43, 62] M rows Divide by 255 => [0.842, 0.175, 0.246]

  5. Indexed Color Image Indexed Color: MxN array with values that index into an NCx3 colormap array that contains the actual RGB colors. N columns 3 256 rows RED 143 BLUE GREEN M rows [0.142, 0.375, 0.846]

  6. Reading Image Files Matlab can read and write data in most common image file formats: jpeg, tif, bmp, png, etc… A = imread(filename, fmt); reads file into an RGB image [A,map] = imread(filename, fmt); reads file into an indexed image

  7. Loading an Image >> a = imread(‘picture.jpg’); >> imshow(a);

  8. Image Characteristics Image (=matrix) size: size(a): 384 512 3 R G B 384 512

  9. RED plane A(:,:,[2 3]) = 0; imshow(a);

  10. GREEN plane A(:,:,[1 3]) = 0; imshow(a);

  11. BLUE plane A(:,:,[1 2]) = 0; imshow(a);

  12. Geometric Manipulation of Images • Let’s rearrange the pixels in the image: • << Left/right = • a(:end:-1:1,:); • << image(Left/right) Reversing the rows Original

  13. Geometric Manipulation of Images • Let’s rearrange the pixels to be upside down: • << updown = • a(end:-1:1,:,:); • << image(updown) Reversing the columns Original

  14. Geometric Manipulation of Images • Suppose we split an image into left and right halves and then replace one half with a mirror image of the other Original

  15. Splitting Code function Anew = splitMirror(A)‏ % ANEW = splitMirror(A)‏ % Splits an image in half and % creates a mirror of the left half [Nr,Nc]=size(A); Anew=A; c2=round(Nc/2); % find midpoint for row=1:Nr for col=(c2+1):Nc cx=Nc+1-col; Anew(row,col)=A(row,cx); end end

  16. Cute Dog Picture

  17. Lake Scene

  18. Collage Design

  19. Collage

  20. Image Arithmetic Adding ‘imadd’: Brighten an image Subtracting ‘imsubtract’ Multiplying ‘immultiply’: Multiply two images multiply image by constant: brightens > 1, darkens < 1 Dividing ‘imdivide’

  21. Spatial Transformations Resizing ‘imresize’: changes the size of the image Rotation ‘imrotate’: rotates the image by given angle Cropping ‘imcrop’: Extract a rectangular part of the image

More Related