1 / 10

Lecture 27: Image Processing

Lecture 27: Image Processing. Images in MATLAB. An image in MATLAB is treated as a matrix Every pixel is a matrix element All the operators in MATLAB defined on matrices can be used on images: +, -, *, /, ^, sqrt, sin, cos etc. Images in MATLAB.

claus
Download Presentation

Lecture 27: Image Processing

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. Lecture 27: Image Processing

  2. Images in MATLAB • An image in MATLAB is treated as a matrix • Every pixel is a matrix element • All the operators in MATLAB defined on matrices can be used on images: +, -, *, /, ^, sqrt, sin, cos etc

  3. Images in MATLAB • MATLAB can import/export several image formats • BMP (Microsoft Windows Bitmap) • GIF (Graphics Interchange Files) • HDF (Hierarchical Data Format) • JPEG (Joint Photographic Experts Group) • PCX (Paintbrush) • PNG (Portable Network Graphics) • TIFF (Tagged Image File Format) • XWD (X Window Dump) • MATLAB can also load raw-data or other types of image data

  4. Images in MATLAB • Binary images : {0,1} • Intensity images : [0,1] or uint8, double etc. • RGB images : m-by-n-by-3 • Indexed images : m-by-3 color map • Multidimensional images m-by-n-by-p (p is the number of layers)

  5. Read and Display an Image • Read in an image Img = imread(‘wholeimg.png’); • Display an image imshow(Img) • Check the image storage information • whos See how wholeimg.png is stored into the MATLAB workspace. • Check pixel values Img(100, 150) Img(50:60, 120:125)

  6. Image Processing • Histogram - display histogram of image data imhist(Img) • Change a gray image into a binary image level = graythresh(Img) Computes a global threshold that can be used to convert an intensity image to a binary image. BW = im2bw(Img, level); bImg = Img >75; • Add noise N = imnoise(Img, ‘gaussian’);

  7. Image Processing • Smoothing the image K = wiener2(N); • Invert an intensity image invImg = 255 - Img; invbImg = 1 - bImg; % inverts the binary image. • Crop the image cImg = Imcrop(Img); cImg = Img(100:200, 150:240);

  8. Image Processing • Multiple-image display subplot(1, 2, 1) subimage(Img) subplot(1, 2, 2) subimage(bImg) • Write the image imwrite(invImg, ‘newImg.jpg’);

  9. Image Processing • Color images rgbImg = imread(‘disc.png’); %store in a 3D matrix imshow(rgbImg) imshow(rgbImg(:, :, 1) gImg = (rgbImg(:,:,1)+rgbImg(:,:,2)+rgbImg(:,:,3))/3; %convert to grey-scale

  10. Practice Question

More Related