0
Upcoming SlideShare
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Standard text messaging rates apply

# Matlab

1,478

Published on

Published in: Technology, Art & Photos
0 Likes
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

• Be the first to like this

Views
Total Views
1,478
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
156
0
Likes
0
Embeds 0
No embeds

No notes for slide

### Transcript

• 1. MATLAB Image Processing Toolbox
• 2. Introduction &#xF077; Collection of functions (MATLAB files) that supports a wide range of image processing operations &#xF077; Documentation &#xF06C; www.mathworks.com
• 3. Read an Image &#xF077; Read in an image &#xF077; Validates the graphic format (bmp, hdf, jpeg, pcx, png, tiff, xwd) &#xF077; Store it in an array clear, close all I = imread(&#x2018;pout.tif`); [X, map] = imread(&#x2018;pout.tif&#x2019;);
• 4. Display an Image imshow(I)
• 5. Check the Image in Memory &#xF077; &lt; Name, Size, Bytes, Class &gt; whos Name Size Bytes Class ans 291x240 69840 uint8 array Grand total is 69840 elements using 69840 bytes uint8 uint16 double [0, 255] [0, 65535] [0, 1]
• 6. Histogram Equalization &#xF077; Histogram: distribution of intensities figure, imhist(I) &#xF077; Equalize Image (contrast) I2 = histeq(I); figure, imshow(I2) figure, imhist(I2)
• 7. Histogram Equalization (cont.)
• 8. Histogram Equalization (cont.)
• 9. Write the Image &#xF077; Validates the extension &#xF077; Writes the image to disk imwrite(I2, &#x2019;pout2.png&#x2019;); imwrite(I2, &#x2018;pout2.png&#x2019;, &#x2018;BitDepth&#x2019;, 4);
• 10. Morphological Opening &#xF077; Remove objects that cannot completely contain a structuring element &#xF077; Estimate background illumination clear, close all I = imread(&#x2018;rice.tif&#x2019;); imshow(I) background = imopen(I, strel(&#x2018;disk&#x2019;, 15)); imshow(background)
• 11. Morphological Opening (cont.)
• 12. Subtract Images &#xF077; Create a more uniform background I2 = imsubtract(I, background); figure, imshow(I2)
• 13. Adjust the Image Contrast &#xF077; stretchlim computes [low hight] to be mapped into [bottom top] I3 = imadjust(I2, stretchlim(I2), [0 1]); figure, imshow(I3)
• 14. Apply Thresholding to the Image &#xF077; Create a binary thresholded image 1. 2. Compute a threshold to convert the intensity image to binary Perform thresholding creating a logical matrix (binary image) level = graythresh(I3); bw = im2bw(I3, level); figure, imshow(bw)
• 15. Apply Thresholding to the Image (cont.)
• 16. Labeling Connected Components &#xF077; Determine the number of objects in the image &#xF077; Accuracy (size of objects, approximated background, connectivity parameter, touching objects) [labeled, numObjects] = bwlabel(bw, 4); numObjects {= 80} max(labeled(:))
• 17. Select and Display Pixels in a Region &#xF077; Interactive selection grain = imcrop(labeled) &#xF077; Colormap creation function RGB_label = label2rgb(labeled, @spring, &#x2018;c&#x2019;, &#x2018;shuffle&#x2019;); imshow(RGB_label); rect = [15 25 10 10]; roi = imcrop(labeled, rect)
• 18. Object Properties &#xF077; Measure object or region properties graindata = regionprops(labeled, &#x2018;basic&#x2019;) graindata(51).Area {296} graindata(51).BoundingBox {142.5 89.5 24.0 26.0} graindata(51).Centroid {155.3953 102.1791} &#xF077; Create a vector which holds just one property for each object allgrains = [graindata.Area]; whos
• 19. Statistical Properties of Objects max(allgrains) { 695 } &#xF077; Return the component label of a grain size biggrain = find(allgrains == 695) { 68 } &#xF077; Mean grain size mean(allgrains) &#xF077; Histogram (#bins) hist(allgrains, 20) { 249 }
• 20. Statistical Properties of Objects (cont.)
• 21. Storage Classes &#xF077; double (64-bit), uint8 (8-bit), and uint16 (16-bit) &#xF077; Converting (rescale or offset) double im2double (automatic rescale and offsetting) RGB2 = im2uint8(RGB1); im2uint16 imapprox (reduce number of colors: indexed images)
• 22. Image Types &#xF077; Index &#xF06C; Data matrix (uint8, uint16, double) &#xF06C; Colormap matrix (m x 3 array of double [0 1]) &#xF077; Intensity (black = 0, white = &#x221E;) &#xF077; Binary (0, 1) B = logical(uint8(round(A))); (logical flag on) B = +A; (logical flag off) &#xF077; RGB (m x n x 3 of truecolor)
• 23. Converting Image Types &#xF077; &#xF077; &#xF077; &#xF077; &#xF077; dither gray2ind grayslice im2bw ind2gray &#xF077; &#xF077; &#xF077; &#xF077; ind2rgb mat2gray rgb2gray rgb2ind
• 24. Multiframe Image Arrays &#xF077; Same size, #planes, colormap &#xF077; Store separate images into one multiframe array A = cat(4, A1, A2, A3, A4, A5) &#xF077; Extract frames from a multiframe array FRM3 = MULTI(:, :, :, 3) &#xF077; Display a frame imshow(MULTI(:, :, :, 7))
• 25. Image Arithmetic &#xF077; &#xF077; &#xF077; &#xF077; imabsdiff imadd imcomplement imdivide &#xF077; imlincomb &#xF077; immultiply &#xF077; imsubtract
• 26. Adding Images I = imread(&#x2018;rice.tif&#x2019;); J = imread(&#x2018;cameraman.tif&#x2019;); K = imadd(I, J); imshow(K) &#xF077; Brighten an image results saturation RGB = imread(&#x2018;flowers.tif&#x2019;); RGB2 = imadd(RGB, 50); subplot(1, 2, 1); imshow(RGB); subplot(1, 2, 2); imshow(RGB2);
• 29. Subtracting Images &#xF077; Background of a scene rice = imread(&#x2018;rice.tif&#x2019;); background = imopen(rice, strel(&#x2018;disk&#x2019;, 15)); rice2 = imsubtract(rice, background); imshow(rice), figure, imshow(rice2); &#xF077; Negative values imabsdiff
• 30. Subtracting Images (cont.)
• 31. Multiplying Images &#xF077; Scaling: multiply by a constant &#xF06C; (brightens &gt;1, darkens &lt;1) &#xF077; Preserves relative contrast I = imread(&#x2018;moon.tif&#x2019;); J = immultiply(I, 1.2); imshow(I); figure, imshow(J)
• 32. Multiplying Images (cont.)
• 33. Dividing Images (Ratioing) I = imread(&#x2018;rice.tif&#x2019;); background = imopen(I, strel(&#x2018;disk&#x2019;, 15)); Ip = imdivide(I, background); imshow(Ip, []) &#xF077; Linear combination only truncates the final result K = imlincomb(.5, I, .5, I2);
• 34. Dividing Images (cont.)
• 35. Coordinate Systems &#xF077; Pixel Coordinates &#xF06E; &#xF06E; &#xF06E; Discrete unit (integer) (r, c) &#xF8EE; = (1, 1) 123 &#xF077; Spatial Coordinates &#xF06E; &#xF06E; &#xF06E; Continuous unit (x, y) &#xF8EE;= (0.5, 0.5)
• 36. Non-default Spatial Coordinate System A = magic(5); x = [19.5 23.5]; y = [8.0 12.0]; image(A, &#x2018;xData&#x2019;, x, &#x2018;yData&#x2019;, y), axis image, colormap(jet(25))
• 37. Spatial Transformations &#xF077; Map pixel locations in an input image to new locations in an output image &#xF06E; &#xF06E; &#xF06E; Resizing Rotation Cropping
• 38. Resizing Images &#xF077; Change the size of an image I = imread(&#x2018;ic.tif&#x2019;); J = imresize(I, 1.25); K = imresize(I, [100 150]); figure, imshow(J) figure, imshow(K)
• 39. Resizing Images (cont.)
• 40. Rotating Images &#xF077; Rotate an image by an angle in degrees I = imread(&#x2018;ic.tif&#x2019;); J = imrotate(I, 35, &#x2018;bilinear&#x2019;); imshow(I) figure, imshow(J)
• 41. Rotating Images (cont.)
• 42. Cropping Images &#xF077; Extract a rectangular portion of an image imshow ic.tif I = imcrop;