1 / 39

MATLAB

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

Download Presentation

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. MATLAB Image Processing Toolbox

  2. Presented By Muhammad ikram ul haq BCS-F07-M032 5th Semester

  3. Introduction • Collection of functions (MATLAB files) that supports a wide range of image processing operations • Documentation • www.mathworks.com

  4. Read an Image • Read in an image • Validates the graphic format (bmp, hdf, jpeg, pcx, png, tiff, xwd) • Store it in an array clear, close all I = imread(‘pout.tif`); [X, map] = imread(‘pout.tif’);

  5. Display an Image imshow(I)

  6. Check the Image in Memory • < Name, Size, Bytes, Class > whos Name Size Bytes Class ans 291x240 69840 uint8 array Grand total is 69840 elements using 69840 bytes

  7. Histogram Equalization • Histogram: distribution of intensities figure, imhist(I) • Equalize Image (contrast) I2 = histeq(I); figure, imshow(I2) figure, imhist(I2)

  8. Histogram Equalization (cont.)

  9. Histogram Equalization (cont.)

  10. Write the Image • Validates the extension • Writes the image to disk imwrite(I2, ’pout2.png’); imwrite(I2, ‘pout2.png’, ‘BitDepth’, 4);

  11. Morphological Opening • Remove objects that cannot completely contain a structuring element • Estimate background illumination clear, close all I = imread(‘rice.tif’); imshow(I) background = imopen(I, strel(‘disk’, 15)); imshow(background)

  12. Morphological Opening (cont.)

  13. Subtract Images • Create a more uniform background I2 = imsubtract(I, background); figure, imshow(I2)

  14. Adjust the Image Contrast • stretchlim computes [low hight] to be mapped into [bottom top] I3 = imadjust(I2, stretchlim(I2), [0 1]); figure, imshow(I3)

  15. Apply Thresholdingto the Image • Create a binary thresholded image • 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)

  16. Apply Thresholdingto the Image (cont.)

  17. Storage Classes • double (64-bit), uint8 (8-bit), and uint16 (16-bit) • Converting (rescale or offset) double im2double (automatic rescale and offsetting) RGB2 = im2uint8(RGB1); im2uint16 imapprox (reduce number of colors: indexed images)

  18. Image Types • Index • Data 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)

  19. dither gray2ind grayslice im2bw ind2gray ind2rgb mat2gray rgb2gray rgb2ind Converting Image Types

  20. Multiframe Image Arrays • Same size, #planes, colormap • Store separate images into one multiframe array A = cat(4, A1, A2, A3, A4, A5) • Extract frames from a multiframe array FRM3 = MULTI(:, :, :, 3) • Display a frame imshow(MULTI(:, :, :, 7))

  21. imabsdiff imadd imcomplement imdivide imlincomb immultiply imsubtract Image Arithmetic

  22. Adding Images I = imread(‘rice.tif’); J = imread(‘cameraman.tif’); K = imadd(I, J); imshow(K) • Brighten an image results saturation RGB = imread(‘flowers.tif’); RGB2 = imadd(RGB, 50); subplot(1, 2, 1); imshow(RGB); subplot(1, 2, 2); imshow(RGB2);

  23. Adding Images (cont.)

  24. Adding Images (cont.)

  25. Subtracting Images • Background of a scene rice = imread(‘rice.tif’); background = imopen(rice, strel(‘disk’, 15)); rice2 = imsubtract(rice, background); imshow(rice), figure, imshow(rice2); • Negative values imabsdiff

  26. Subtracting Images (cont.)

  27. Multiplying Images • Scaling: multiply by a constant • (brightens >1, darkens <1) • Preserves relative contrast I = imread(‘moon.tif’); J = immultiply(I, 1.2); imshow(I); figure, imshow(J)

  28. Multiplying Images (cont.)

  29. 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);

  30. Dividing Images (cont.)

  31. Pixel Coordinates Discrete unit (integer) (r, c)  = (1, 1) Spatial Coordinates Continuous unit (x, y) = (0.5, 0.5) Coordinate Systems 123

  32. 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))

  33. Spatial Transformations • Map pixel locations in an input image to new locations in an output image • Resizing • Rotation • Cropping

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

  35. Resizing Images (cont.)

  36. Rotating Images • Rotate an image by an angle in degrees I = imread(‘ic.tif’); J = imrotate(I, 35, ‘bilinear’); imshow(I) figure, imshow(J)

  37. Rotating Images (cont.)

  38. Cropping Images • Extract a rectangular portion of an image imshow ic.tif I = imcrop;

  39. Ending Question

More Related