Experiment (3) Basic Image Manipulation 1

Experiment (3) Basic Image Manipulation 1

5th year ; 1st semester image processing lab Experiment (3) Basic Image Manipulation 1. Objective: - Explore the different image types supported by MATLAB. - Learn how to read images into MATLAB. - Explore image conversion. - Learn how to display images. - Learn how to write images to disk. 2. Equipment: pc and MATLAB software. 3. Background: - Image formats supported by MATLAB Format description extension TIFF Tagged image file format .tiff .tif JPEG Joint photographic expert group .jpg .jpeg GIF Graphic interchange format .gif BMP Windows bitmap .bmp PNG Portable network graphics .png - An image is usually interpreted as being one of: intensity, binary, indexed or RGB. An intensity image’s values represent brightnesses. A binary image’s pixels have just two possible values. Indexed image’s pixel values are treated as the index of a look-up table from which the “true” value is read. RGB images have three channels, representing intensities in ranges of wavelengths corresponding to red, green and blue illumination (other wavelength ranges and more of them are possible). - MATLAB supports the following data types. Type Interpretation Range uint8 Unsigned 8-bit integer [0, 255] uint16 Unsigned 16-bit integer [0, 65535] int8 signed 8-bit integer [-128, 127] int16 signed 16-bit integer [-32768, 32767] single Single precision floating point number [-1038, 1038] double double precision floating point number [-10308, 10308] logical Values are 0 or 1 1 bit per element - Functions are provided for converting between image types, in which case the data is scaled to fit the new data type’s range. These are defined to be: A. L. Reem shakir 1 5th year ; 1st semester image processing lab 4. Procedure: - Create a script file (m-file) and type the following code: clear;clc; I = imread('coins.png'); %Load the image coins.png (intensity image) [I_ind,I_map] = gray2ind(I,256); %there is no direct conversion from intensity to I_rgb = ind2rgb(I_ind,I_map); RGB, so we must first convert from intensity to indexed, and then from indexed to RGB. [X,map] = imread('trees.tif'); %Load the image trees.tif (indexed image) X_rgb = ind2rgb(X,map); %Convert the indexed image X with color map map to an RGB image, X_rgb. X_gray = ind2gray(X,map); %Convert the indexed image X with color map map to an intensity image. imshow(I),impixelinfo %to display the coins.png image that is currently loaded in the variable I. imshow(X,map),impixelinfo %Display the indexed image trees.tif. The image data are stored in variable X and the color map in map. close all %Close any open figures %Execute the following statements to create a subplot with two images, displayed two images, both of which were intensity images. A = imread('pout.tif'); B = imread('cameraman.tif'); figure subplot(1,2,1), imshow(A) subplot(1,2,2), imshow(B) %the case where an intensity image and an indexed image are both displayed in one figure, using the subplot function, we must use the subimage function. figure %The subimage function converts the image subplot(1,2,1),subimage(I),axis off to an equivalent RGB image and then subplot(1,2,2),subimage(X,map),axis off displays that image. figure %Display the truecolor images using the subplot(1,2,1), imshow(I_rgb) imshow function. subplot(1,2,2), imshow(X_rgb) imwrite(X_rgb, 'rgb_trees.jpg'); %Use imwrite to save two of the modified imwrite(X_gray, 'gray_trees.png'); images 5. Discussion: 1. What type of image is coins.png? 2. Why do we use the semicolon (;) operator after the imread statement? 3. What happens if we omit it? 4. How many dimensions does the variable X_rgb have and what are their sizes? 5. What class type is X_gray? 6. In the case where an intensity image and an indexed image are both displayed in one figure, using the subplot function, why must use the subimage function. A. L. Reem shakir 2 .

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    2 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us