Matlab Image Processing Toolbox

Matlab Image Processing Toolbox

MATLAB IMAGE PROCESSING TOOLBOX Gulsah Tumuklu Ozyer Introduction MatLab : Matrix Laboratory A high-level language for matrix calculations, numerical analysis, & scientific computing Programming Can type on command line, or use a program file (m-file)

Semicolon at end of line is optional (suppresses printing) Control flow (if, for, while, switch,etc) similar to C Differences from C: no variable declarations, no pointers MATLABs Workspace who,whos - current variables in workspace save - save workspace variables to *.mat file load - load variables from *.mat file clear all - clear workspace variables Matlab Basics

Everything is a matrix a variable is a 1x1 matrix Initializing a matrix: Example: my_matrix = [1 2 3; 4 5 6; 7 8 9]; Accessing a matrix (row, column): my_matrix(1,2) has the value 2 my_matrix = 1 2 3 4 5 6 7 8 9 Colon operator generates a range

Example: 1:10 = [1 2 3 4 5 6 7 8 9 10] mytest(1, 2:4) is equivalent to mytest(1,[2 3 4]) mytest(3, :) refers to all elements of row 3 Basic Operations on Matrices All the operators in MATLAB defined on matrices : +, -, *, /, ^, sqrt, sin, cos etc. Element wise operators defined with preceding dot : .*, ./, .^ . size(A) - size vector sum(A) - columns sums vector

sum(sum(A)) - all the elements sum Logical Conditions == , < , > , (not equal)~= , (not)~ find(condition) - Returns indexes of As elements that satisfies the condition. Logical Conditions(cont.) Example: >> A = [1 2; 3 4], I = find(A<4)

A= 1 3 I= 1 2 3 2 4 Flow Control

MATLAB has five flow control constructs: if statements switch for statements loops

while loops break statements Scripts and Functions There are two kinds of M-files:

Scripts, which do not accept input arguments or return output arguments. They operate on data in the workspace. Functions, which can accept input arguments and return output arguments. Internal variables are local to the function. Visualization and

Graphics plot(x,y), plot(x,sin(x)) - plot 1-D function figure , figure(k) - open a new figure hold on, hold off - refreshing mesh(x_ax,y_ax,z_mat) - view surface contour(z_mat) - view z as top. map subplot(3,1,2) - locate several plots in figure axis([xmin xmax ymin ymax]) - change axes title(figure title) - add title to figure

The Image Processing Toolbox The Image Processing Toolbox is a collection of functions that extend the capability of the MATLAB numeric computing environment. The toolbox supports a wide range of image processing operations, including: Geometric operations Neighborhood and block operations Linear filtering and filter design Transforms Image analysis and enhancement

Binary image operations MATLAB Image Types Indexed images Intensity images Binary images RGB images : : : :

m-by-3 color map [0,1] or uint8 {0,1} m-by-n-by-3 Read and Write Images I = imread(colors.jpg'); imshow(I); Indexed Image: [x,map] = imread(color.png'); imwrite(I, newim.jpg)

Image Display image - create and display image object imagesc - scale and display as image imshow - display image colorbar - display colorbar getimage- get image data from axes truesize - adjust display size of image zoom - zoom in and zoom out of 2D plot Image Conversion

gray2ind - intensity image to index image im2bw - image to binary im2double - image to double precision im2uint8 - image to 8-bit unsigned integers im2uint16 - image to 16-bit unsigned integers ind2gray - indexed image to intensity image mat2gray - matrix to intensity image rgb2gray - RGB image to grayscale rgb2ind - RGB image to indexed image Geometric Operations Image resizing: imresize(I,[x y],method).

Method is bilinear, bicubic or nearest neighbours. Image rotation: imrotate(I,angle,method) method is same as before. Zero padding in the rotated image. Image cropping: J=imcrop; Neighbourhood Processing To speed up neighbourhood processing transform every neighbourhood to column vector and perform vector operations. The borders are usually padded with zeros for

the computations of the edges neighborhoods. Linear filtering can be done with convolution - conv2(Img, h) or correlation - filter2(Img, h). Nonlinear filtering: nlfilter(I,[sx sy],func) where func is a function that recieves the windows and returns scalars. 17 Transforms Fourier and inverse Fourier transform:

F=fftshift(fft2(f)); F is a complex matrix Freal=real(F);Fimag=imag(F);Fabs=abs(F);Fphs=angle(F); imshow(Freal) f=ifft2(F); DCT and compression I=imread(cameraman.tif); I=im2double(I); T=dctmtx(8); B=blkproc(I,[8 8], P1*x*P2,T,T); mask=[1 1 1 0 0 ]; B2=blkproc(B,[8 8],P1*x,mask); I2=blkproc(B2,[8 8],P1*x*P2,T,T);

It is also possible to use dct2 and idct2. 18 Analyzing and Enhancing Images pixval returns the value of a pointed pixel and the distance between two pointed pixels. impixel returns the data value for a selected set of pixels. The set can be pointed by the mouse or by coordinates. imcontour plots the contours of the image. imhist(I,n) plots the histogram of I with n bins.

19 Edge detection: edge(I,sobel); edge(I,canny); Or by fspecial(sobel) and conv2. Image Enhancement: Histogram stretching: imadjust(I,[low high],[bottom top]);

Gamma correction: imadjust(I,[],[],gamma_coef); Histogram Equalization histeq(I) 20 Noise removal To add noise to an image: imnoise(I,type,coef); type can be salt n pepper, speckle, gaussian for S&P, multiplicative and additive noise.

Averaging or gaussian filtering: F=filter2(fspecial(average,3),J); Median filtering: F=medfilt(J,[3 3]); 21 Morphological Operations Dilation : imdilate() Erosion: imerode() Closing: imclose() Opening: imopen() 22

Color The available colorspaces: RGB, NTSC (US televisions), YCbCr (Digital video), HSV. Transformations between the spaces: rgb2ntsc, hsv2rgb, 23 Questions?

Recently Viewed Presentations

  • SCORM Sequencing and Navigation

    SCORM Sequencing and Navigation

    Arial Black 新細明體 標楷體 Times New Roman Wingdings Arial Comic Sans MS 12006006A 從資訊能力指標 看高中資訊課程大綱 大綱 能力指標的意義與用途 評估能力的急迫性 資訊能力指標的應用方向 美英等先進國家 中小學資訊能力指標分析 美國國家資訊能力指標 美國國家資訊 ...
  • Welcome to Regents Earth Science Practicum Neatly fill

    Welcome to Regents Earth Science Practicum Neatly fill

    Welcome to Regents Earth Science Practicum Neatly fill in the heading on the cover page. Do Not open the booklet until you are instructed to do so!!
  • The Seven Elements of Art Presented in PowerPoint by ...

    The Seven Elements of Art Presented in PowerPoint by ...

    INTRO CLASSES : 8/21 NEW SEATS YOU WILL NEED: Half sheet of paper- Numbered 1-6 Pencil Everything else on the floor Please List the 6 parts of a CREDIT LINE- in order The Elements of Art AN ELEMENT IS A...
  • New Beginnings University of East London

    New Beginnings University of East London

    New Beginnings. Is … Twelve week intensive study skills course, designed to build on existing skills, knowledge and experience. Is not … GCSE level two English equivalent. Academic subject content rich. Applicable to non-UEL courses
  • Writing Lab - University of West Florida

    Writing Lab - University of West Florida

    Words that have similar sounds are called homophones. Examples of homophones include the following: their, they're, and there. ... This lesson is part of the UWF Writing Lab Grammar Mini-Lesson Series. Lessons adapted from . Real Good Grammar, Too.
  • PowerPoint-Präsentation - inIPF

    PowerPoint-Präsentation - inIPF

    Mosaic attenuation is the presence of regions of differing attenuation appearing as patchy areas of black and white lung on HRCT. These correspond to affected and non-affected lung areas, respectively.
  • Review of qualitative Research AND PRINCIPLES of Qualitative

    Review of qualitative Research AND PRINCIPLES of Qualitative

    * Types of Qualitative Research Grounded theory Ethnography Phenomenology Field research * Strengths and Weaknesses Strengths Depth of understanding Flexibility Weaknesses Subjectivity Suggestive, not definitive Limited generalizability Mixed methodology is possible * Qualitative Research Terms ...
  • Agriculture - AP Human Geography - Home

    Agriculture - AP Human Geography - Home

    Location of agricultural hearths. Vegetative planting. Reproduction through cloning, cutting and splitting roots. Originated in Southeast Asia to China, Japan, India, S.W. Asia, Africa, and Mediterranean