+ All Categories

MATLAB

Date post: 31-Dec-2015
Category:
Upload: irene-horton
View: 57 times
Download: 1 times
Share this document with a friend
Description:
MATLAB. Image Processing Toolbox. Presented By. Muhammad ikram ul haq BCS-F07-M032 5 th Semester. Introduction. Collection of functions (MATLAB files) that supports a wide range of image processing operations - PowerPoint PPT Presentation
Popular Tags:
39
MATLAB Image Processing Toolbox
Transcript
Page 1: MATLAB

MATLAB

Image Processing Toolbox

Page 2: MATLAB

Muhammad ikram ul haq

BCS-F07-M032

5th Semester

Page 3: MATLAB

Introduction

Collection of functions (MATLAB files) that supports a wide range of image processing operations

Documentationwww.mathworks.com

Page 4: MATLAB

Read an Image

Read in an image Validates the graphic format

(bmp, hdf, jpeg, pcx, png, tiff, xwd)

Store it in an arrayclear, close allI = imread(‘pout.tif`);[X, map] = imread(‘pout.tif’);

Page 5: MATLAB

Display an Image

imshow(I)

Page 6: MATLAB

Check the Image in Memory

< Name, Size, Bytes, Class >whos

Name Size Bytes Class ans 291x240 69840 uint8 arrayGrand total is 69840 elements using 69840 bytes

uint8 [0, 255]

uint16 [0, 65535]

double [0, 1]

Page 7: MATLAB

Histogram Equalization

Histogram: distribution of intensities

figure, imhist(I)

Equalize Image (contrast)I2 = histeq(I);

figure, imshow(I2)

figure, imhist(I2)

Page 8: MATLAB

Histogram Equalization (cont.)

Page 9: MATLAB

Histogram Equalization (cont.)

Page 10: MATLAB

Write the Image

Validates the extension Writes the image to disk

imwrite(I2, ’pout2.png’);imwrite(I2, ‘pout2.png’, ‘BitDepth’, 4);

Page 11: MATLAB

Morphological Opening

Remove objects that cannot completely contain a structuring element

Estimate background illuminationclear, close allI = imread(‘rice.tif’);imshow(I)background = imopen(I, strel(‘disk’, 15));imshow(background)

Page 12: MATLAB

Morphological Opening (cont.)

Page 13: MATLAB

Subtract Images

Create a more uniform backgroundI2 = imsubtract(I, background);figure, imshow(I2)

Page 14: MATLAB

Adjust the Image Contrast

stretchlim computes [low hight] to be mapped into [bottom top]

I3 = imadjust(I2, stretchlim(I2), [0 1]);figure, imshow(I3)

Page 15: MATLAB

Apply Thresholdingto the Image

Create a binary thresholded image1. Compute a threshold to convert the

intensity image to binary2. Perform thresholding creating a logical

matrix (binary image)level = graythresh(I3);bw = im2bw(I3, level);figure, imshow(bw)

Page 16: MATLAB

Apply Thresholdingto the Image (cont.)

Page 17: MATLAB

Storage Classes

double (64-bit), uint8 (8-bit), and uint16 (16-bit)

Converting (rescale or offset)doubleim2double (automatic rescale and offsetting)RGB2 = im2uint8(RGB1);im2uint16imapprox (reduce number of colors: indexed images)

Page 18: MATLAB

Image Types

IndexData matrix (uint8, uint16, double)Colormap matrix (m x 3 array of double [0

1])

Intensity (black = 0, white = ) Binary (0, 1)

B = logical(uint8(round(A))); (logical flag on)

B = +A; (logical flag off)

RGB (m x n x 3 of truecolor)

Page 19: MATLAB

Converting Image Types

dither gray2ind grayslice im2bw ind2gray

ind2rgb mat2gray rgb2gray rgb2ind

Page 20: MATLAB

Multiframe Image Arrays

Same size, #planes, colormap Store separate images into one

multiframe arrayA = cat(4, A1, A2, A3, A4, A5)

Extract frames from a multiframe array

FRM3 = MULTI(:, :, :, 3)

Display a frameimshow(MULTI(:, :, :, 7))

Page 21: MATLAB

Image Arithmetic

imabsdiff imadd imcomplement imdivide

imlincomb immultiply imsubtract

Page 22: MATLAB

Adding Images

I = imread(‘rice.tif’);J = imread(‘cameraman.tif’);K = imadd(I, J);imshow(K)

Brighten an image results saturationRGB = imread(‘flowers.tif’);RGB2 = imadd(RGB, 50);subplot(1, 2, 1); imshow(RGB);subplot(1, 2, 2); imshow(RGB2);

Page 23: MATLAB

Adding Images (cont.)

Page 24: MATLAB

Adding Images (cont.)

Page 25: MATLAB

Subtracting Images

Background of a scenerice = imread(‘rice.tif’);background = imopen(rice, strel(‘disk’,

15));rice2 = imsubtract(rice, background);imshow(rice), figure, imshow(rice2);

Negative valuesimabsdiff

Page 26: MATLAB

Subtracting Images (cont.)

Page 27: MATLAB

Multiplying Images

Scaling: multiply by a constant(brightens >1, darkens <1)

Preserves relative contrastI = imread(‘moon.tif’);J = immultiply(I, 1.2);imshow(I);figure, imshow(J)

Page 28: MATLAB

Multiplying Images (cont.)

Page 29: MATLAB

Dividing Images (Ratioing)

I = imread(‘rice.tif’);background = imopen(I, strel(‘disk’, 15));Ip = imdivide(I, background);imshow(Ip, [])

Linear combination only truncates the final result

K = imlincomb(.5, I, .5, I2);

Page 30: MATLAB

Dividing Images (cont.)

Page 31: MATLAB

Coordinate Systems

Pixel Coordinates Discrete unit

(integer) (r, c) = (1, 1)

Spatial Coordinates Continuous unit (x, y) = (0.5, 0.5)123

Page 32: MATLAB

Non-default Spatial Coordinate System

A = magic(5);x = [19.5 23.5];y = [8.0 12.0];image(A, ‘xData’, x, ‘yData’, y), axis

image, colormap(jet(25))

Page 33: MATLAB

Spatial Transformations

Map pixel locations in an input image to new locations in an output image Resizing Rotation Cropping

Page 34: MATLAB

Resizing Images

Change the size of an imageI = imread(‘ic.tif’); J = imresize(I, 1.25);K = imresize(I, [100 150]);figure, imshow(J)figure, imshow(K)

Page 35: MATLAB

Resizing Images (cont.)

Page 36: MATLAB

Rotating Images

Rotate an image by an angle in degrees

I = imread(‘ic.tif’); J = imrotate(I, 35, ‘bilinear’);imshow(I)figure, imshow(J)

Page 37: MATLAB

Rotating Images (cont.)

Page 38: MATLAB

Cropping Images

Extract a rectangular portion of an image

imshow ic.tifI = imcrop;

Page 39: MATLAB

Ending


Recommended