1 / 13

Image and Video Processing in MATLAB

Image and Video Processing in MATLAB. Partly based on slides by Dmitri Roduy. Topics. Data Types Image Representation Image/Video I/O Matrix access Image Manipulation Application: Bright Cars Detection in Video. Image Data Types. Relevant data types

fritz
Download Presentation

Image and Video Processing in MATLAB

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. Image and Video Processing in MATLAB Partly based on slides by Dmitri Roduy

  2. Topics • Data Types • Image Representation • Image/Video I/O • Matrix access • Image Manipulation • Application: Bright Cars Detection in Video

  3. Image Data Types • Relevant data types • uint8 – [0 255] – native for natural images • uint16 – [0 65,535] – common for medical images • Logical – [0 1] – native for masks, morph. elements • double – 64bit floating point (default range [0 1]) • single – when you want to save memory (32bit floating point) • Simple casting: double(), uint8(). • Type Conversion (of images): • im2double(),im2single(),im2uint8(), im2unit16() • Works for colors, gray-scale, logical images

  4. Common problem I = imread(‘pears.png'); I2 = I-1.4; diffI = I-I2; fprintf('Max difference between images: %d\n',max(diffI(:))); figure(1); subplot(1,2,1); imshow(I); title('I'); subplot(1,2,2); imshow(I2); title('I2');

  5. Common problem I = double(imread('pears.png')); I2 = I-1.4; diffI = I-I2; fprintf('Max difference between images: %2.1f\n',max(diffI(:))); figure(1); subplot(1,2,1); imshow(I); title('I'); subplot(1,2,2); imshow(I2); title('I2');

  6. Possible Solution I = double(imread('pears.png')); I2 = I-1.4; diffI = I-I2; fprintf('Max difference between images: %2.1f\n',max(diffI(:))); figure(1); subplot(1,2,1); max_I= 255; imshow(I/max_I); title('I'); subplot(1,2,2); imshow(I2/max_I); title('I2');

  7. Image Representation 2D Matrix • Intensity: Each pixel value in the dynamic range [minP, maxP]. • Can represent a grayscale image, results of a 2d function etc. • Useful commands: imshow (), imagesc(), colormap(). • Binary: a.k.a masks. • Can represent areas of interest in image, morphological structuring elements and more… • Useful commands: bwlabel(),bwmorph(),bwdist(),im2bw(),bwperim().

  8. Image Representation 3D Matrix • True Color: Three 2D matrices stacked. Each represents a color component. (e.g. RGB) • Can represent an RGB color image, Ycbcr image, LAB image, etc. • Useful commands: imshow(),rgb2gray(),rgb2ycbcr(), ycbcr2rgb(), rgb2lab().

  9. Image/Video I/O Useful Commands • imread() – read image • imwrite() – write image • im2frame() – convert image to movie frame • movie2avi() – write avi file • aviread() – read avi file • mmreader()/VideoReader() – read video (better) • VideoWriter() – create video file (2011b+) • movie() – show movie • implay() – show video interactively

  10. Matrix access Useful Commands: • sub2ind()– convert subscript (e.g. (r,c,clr)) to index (n). • ind2sub() – convert index (n) to subscipt (e.g. (r,c,clr)). • meshgrid() – generate X,Y grids.

  11. Image Manipulation Useful Functions: • imrotate()– Rotate image. • imfilter() – Use kernal to convolve/correlation. • nlfilter() – Sliding neighborhood operation. • blkproc() – Perform function on (semi-)distinct blocks. • fspecial() – Create common image filter kernels. • imresize() – scale up/down image using defined interpolation. • padarray() – Pad image. • colfilt() – Column-stack filtering (faster) • Many more – see IP toolbox help

  12. Application: Bright Cars Detection in Video • Objective: Tag with a red square bright colored cars in a color video with moving cars. • Stages: • Convert each RGB frame to gray scale. • Search for regional maximas above a brightness threshold • Remove small regions (i.e morphology) • Compute centroid of each region • Place a red square in centroid location • Repeat 1-5 for all video frames

  13. Morphological Open Erosion of the image with the Structuring Element followed by Dilation of the image with the Structuring Element.

More Related