Saturday, February 25, 2012

MATLAB Graph: Bit-Mapped Images

Previously, what I learned is to "plot some data", those data are more like X, Y axis data, which is more organized. However, Images, like pictures taken with camera, are more randomly for each pixel to connects.

In Matlab, once a graphics file format image is displayed, it becomes a Handle Graphics image object. Matlab supports:
BMP (Microsoft Windows Bitmap), HDF (Hierarchical Data Format), JPEG (Joint Photographic Experts Group), PCX (Paintbrush), PNG (Portable Network Graphics), TIFF (Tagged Image File Format), XWD (X Window Dump)

+++++
Images in Matlab

MATLAB stores most images as two-dimensional arrays (i.e., matrices), in which each element of the matrix corresponds to a single pixel in the displayed image.
MATLAB supports reading the most commonly used bit depths (bits per pixel) of any of the supported graphics file formats. When the data is in memory, it can be stored as uint8, uint16, or double.
Saving the bit depths in uint8 or uint16 will save a lot of memory space.

+++++
Image Types
In MATLAB, an image consists of a data matrix and possibly a colormap matrix. There are three image types used:

  • indexed image
    • An indexed image consists of a data matrix, X, and a colormap matrix map. Map is an m-by-3 array of class double containing floating-point values in the range [0, 1].
    • Each row of map specifies the red, green, and blue components of a single color.
    • Use "image" to display it
  • intensity (or grayscale) image
    • An intensity image is a data matrix, I, whose values represent intensities within some range.
    • MATLAB stores an intensity image as a single matrix, with each element of the matrix corresponding to one image pixel.
    • MATLAB handles intensity images as indexed images. 
    • Use "imagesc" to display it
  • RGB (or truecolor) image
    • It is stored in MATLAB as an m-by-n-by-3 data array that defines red, green, and blue color components for each individual pixel.
    • Graphics file formats store RGB images as 24-bit images, where the red, green, and blue components are 8 bits each.
    • Use "image" to display it
+++++
Reading, Writing, and Querying Graphics Image Files

  • Load or save a matrix as a MAT-file: load, save
  • Load or save graphics file format image: imread, imwrite
  • Display any image loaded into MATLAB, image, imagesc
  • Utility: imfinfo, ind2rdg
-----------------------------------------------------------------------------------------
Image Type           Display Commands                       Uses Colormap Colors
Indexed                 image(X), colormap(map)              Yes
Intensity                imagesc(I, [0, 1]); colormap(gray)  Yes
RGB(truecolor)     image(RGB)                                    No
-----------------------------------------------------------------------------------------

+++++

The Image Object and Its Properties

Image objects are children of axes objects, as are line, patch, surface, and text objects.
The commands image and imagesc create image objects.

The most important properties of the image object with respect to appearance are CData, CDataMapping, XData, YData, and EraseMode.

CData: The CData property of an image object contains the data array
CDataMapping: The CDataMapping property controls whether an image is indexed or intensity.
XData, YData: The XData and YData properties control the coordinate system of the image. For an m-by-n image, the default XData is [1 n] and the default YData is [1 m].
EraseMode: The EraseMode property controls how MATLAB updates the image on the screen if the image object's CData property changes. The default setting of EraseMode is 'normal'. With this setting, if you change the CData of the image object using the set command, MATLAB erases the image on the screen before redrawing the image using the new CData array.

No comments:

Post a Comment