Loading presentation...

Present Remotely

Send the link below via email or IM

Copy

Present to your audience

Start remote presentation

  • Invited audience members will follow you as you navigate and present
  • People invited to a presentation do not need a Prezi account
  • This link expires 10 minutes after you close the presentation
  • A maximum of 30 users can follow your presentation
  • Learn more about this feature in our knowledge base article

Do you really want to delete this prezi?

Neither you, nor the coeditors you shared it with will be able to recover it again.

DeleteCancel

Make your likes visible on Facebook?

Connect your Facebook account to Prezi and let your likes appear on your timeline.
You can change this under Settings & Account at any time.

No, thanks

Introduction to Matlab: Image Processing

Basic commands to perform image processing in Matlab
by

Jose Bastidas

on 16 April 2013

Comments (0)

Please log in to add your comment.

Report abuse

Transcript of Introduction to Matlab: Image Processing

Introduction to Matlab Introduction to Image Processing in Matlab
Fundamentals
Operations upon Pixels
Enhancement of Images
Morphological Image Processing and Object
Recognition Outline Image Processing MPIDS-Network Dynamics Group José Luis Casadiego Bastidas ________________________________________________________________________________
José Casadiego - MPIDS - Introduction to Matlab: Image Processing - 17.04.12 Representation of an Image Fundamentals ________________________________________________________________________________
José Casadiego - MPIDS - Introduction to Matlab: Image Processing - 17.04.12 2-D function, = Spatial Coordinates = Intensity 0 255 Reading an Image Fundamentals >> Img = imread('filename') Output: An array named Img Grayscale Image Color Image ________________________________________________________________________________
José Casadiego - MPIDS - Introduction to Matlab: Image Processing - 17.04.12 Img(n,m) Img(n,m,ch) n,m = pixel's
coord. Ch= 1 - Red
2 - Green
3 - Blue Single channel ________________________________________________________________________________
José Casadiego - MPIDS - Introduction to Matlab: Image Processing - 17.04.12 Fundamentals >> Img = imread('canaima.jpg') >> Img(:, :, 1) >> Img(:, :, 2) >> Img(:, :, 3) = Supported file types Fundamentals ________________________________________________________________________________
José Casadiego - MPIDS - Introduction to Matlab: Image Processing - 17.04.12 TIFF, JPEG, GIF, BMP and PNG Displaying Images >> imshow(Img) Output: A new window displaying Img Displaying K images... >> imshow(Img1), figure, imshow(Img2), figure,..., imshow(ImgK) Writing Images Fundamentals ________________________________________________________________________________
José Casadiego - MPIDS - Introduction to Matlab: Image Processing - 17.04.12 >> imwrite(Img, 'filename.ext') Output: Saves the array Img as filename with
extension ext*. *TIFF, JPEG, PNG and BMP Image Types Binary, Intensity, RGB and Indexed Binary Image Fundamentals ________________________________________________________________________________
José Casadiego - MPIDS - Introduction to Matlab: Image Processing - 17.04.12 Intensity Image RGB Image Logical (0's and 1's) uint8 (0 - 255)
uint16 (0 - 65535)
uint32 (0 - 4294967295)
double (10^308) - [0:1] 3 x Intensity Arrays (RGB)
uint8 (0 - 255)
uint16 (0 - 65535)
uint32 (0 - 4294967295)
double (10^308) - [0:1] Converting between types Fundamentals ________________________________________________________________________________
José Casadiego - MPIDS - Introduction to Matlab: Image Processing - 17.04.12 Name Converts to Input im2uint8 uint8 logical, uint16, uint32 and double im2uint16 uint16 logical, uint8, uint32 and double mat2gray double[0:1] double im2double double logical, uint8, uint16 and double im2bw logical uint8, uint16, uint32 and double Example #1 Fundamentals ________________________________________________________________________________
José Casadiego - MPIDS - Introduction to Matlab: Image Processing - 17.04.12 Extract the red channel of an Image, display it and write it as a binary image >> Img = imread('board.tif');
>> redImg = Img;
>> redImg(:,:,2)=0; %Green Ch. set to 0
>> redImg(:,:,3)=0; %Blue Ch. set to 0
>> imshow(redImg);
>> binImg = im2bw(redImg, 0.2); %Second Inp. Threshold
>> imwrite(binImg,'binary.jpg'); What if we write the syntax ">> imshow(Img(:,:,1)) "? Why would we deal with the pixel value? Operations upon Pixels ________________________________________________________________________________
José Casadiego - MPIDS - Introduction to Matlab: Image Processing - 17.04.12 Not all images necessarily contain strictly visual information. Advantages... Contrast Adjustment Blending Filtering Object recognition Arithmetic Operations on Images Operations upon Pixels ________________________________________________________________________________
José Casadiego - MPIDS - Introduction to Matlab: Image Processing - 17.04.12 Contrast Adjustment >> imadd(Img, c); %c = positive constant Blending Images >> imadd(Img, Img2); Contrast Adjustment Operations upon Pixels ________________________________________________________________________________
José Casadiego - MPIDS - Introduction to Matlab: Image Processing - 17.04.12 >> Img = imread('canaima.jpg');
>> ImgCont = imadd(Img, 90);
>> imshow(ImgCont); Blending Images Operations upon Pixels ________________________________________________________________________________
José Casadiego - MPIDS - Introduction to Matlab: Image Processing - 17.04.12 >> Img = imread('roraima.jpg');
>> Img2 = imread('redcanaima.jpg')
>> ImgBlend = imadd(Img, Img2);
>> imshow(ImgBlend); + = Operations upon Pixels ________________________________________________________________________________
José Casadiego - MPIDS - Introduction to Matlab: Image Processing - 17.04.12 Contrast Adjustment >> Img = imread('canaima.jpg');
>> ImgCont = imsubtract(Img, 90);
>> imshow(ImgCont); Other useful arithmetic operations Operations upon Pixels ________________________________________________________________________________
José Casadiego - MPIDS - Introduction to Matlab: Image Processing - 17.04.12 impultiply() and imdivide() Inverting Colors >> Img = imread('colorwheel.png');
>> ImgComp = imcomplement(Img);
>> imshow(ImgComp); Operations upon Pixels ________________________________________________________________________________
José Casadiego - MPIDS - Introduction to Matlab: Image Processing - 17.04.12 L-in H-in H-out L-out L-in H-in H-out L-out L-in H-in H-out L-out >> imadjust(img);
>> imadjust(img,[l-in; h-in],[l-out; h-out], gamma) Point Based Operations on Images gamma<1 gamma=1 gamma>1 Operations upon Pixels ________________________________________________________________________________
José Casadiego - MPIDS - Introduction to Matlab: Image Processing - 17.04.12 >> img = imread('pout.tif');
>> img2 = imadjust(I);
>>imshow(img), figure, imshow(img2) Logarithmic and Exponential Transformations >> img2 = c*log(1+im2double(img))
>> img2 = c*(exp(im2double(img))-1) Pixel Distributions: Histograms Operations upon Pixels ________________________________________________________________________________
José Casadiego - MPIDS - Introduction to Matlab: Image Processing - 17.04.12 >> img = imread('puppy.jpg');
>> imshow(img), figure, imhist(img); Histograms are useful for picking threshold values.

For complex images:

>> graythresh(img); Why should we perform enhancement? Enhancement of Images ________________________________________________________________________________
José Casadiego - MPIDS - Introduction to Matlab: Image Processing - 17.04.12 In order to see the visual information that the image contains with greater clarity Spatial Filtering W5 W4 W3 W6 W7 W8 W9 W1 W2 Mask Image Linear Spatial Filtering Enhancement of Images ________________________________________________________________________________
José Casadiego - MPIDS - Introduction to Matlab: Image Processing - 17.04.12 >> Img = imread('puppy.jpg');
>> k = ones(3); %3x3 matrix of 1's
>> ImgFiltered=imfilter(Img, k);
>> imshow(Img), figure, imshow(ImgFiltered); Linear Spatial Filtering: Predefined Filters Enhancement of Images ________________________________________________________________________________
José Casadiego - MPIDS - Introduction to Matlab: Image Processing - 17.04.12 >> k1 = fspecial('average');
>> k2 = fspecial('gaussian');
>> k3 = fspecial('disk'); >> Img1=imfilter(Img, k1);
>> Img2=imfilter(Img, k2);
>> Img3=imfilter(Img, k3); k1 k2 k3 Filtering for Noise Removal Enhancement of Images ________________________________________________________________________________
José Casadiego - MPIDS - Introduction to Matlab: Image Processing - 17.04.12 >> k = fspecial('gaussian');
>> imfilter(Img, k); >> medfilt2(Img); Gaussian Noise Salt & Pepper Noise What is it useful for? Morphological Image Processing ________________________________________________________________________________
José Casadiego - MPIDS - Introduction to Matlab: Image Processing - 17.04.12 For extracting image components that are useful to describe shapes, such as boundaries and skeletons. Binary Images Foreground - 1's
Background - 0's Erosion Morphological Image Processing ________________________________________________________________________________
José Casadiego - MPIDS - Introduction to Matlab: Image Processing - 17.04.12 Dilation Morphological Image Processing ________________________________________________________________________________
José Casadiego - MPIDS - Introduction to Matlab: Image Processing - 17.04.12 >> imerode(img, se); >> imdilate(img, se); >> se = strel('square',5); >> se = strel('line',10,45); Computing the Boundaries Object Recognition ________________________________________________________________________________
José Casadiego - MPIDS - Introduction to Matlab: Image Processing - 17.04.12 What is a Digital Image? Image Processing in Matlab ________________________________________________________________________________
José Casadiego - MPIDS - Introduction to Matlab: Image Processing - 17.04.12 Pixel Numeric representation of a two-dimensional image What is Image Processing? Image Processing in Matlab ________________________________________________________________________________
José Casadiego - MPIDS - Introduction to Matlab: Image Processing - 17.04.12 Why should we use Matlab for Image Processing? Matlab's Image Processing Toolbox has a large repertoire of functions designed for this puporse!!!
Full transcript