MATLAB four image types

Source: Internet
Author: User

1. index images

The index image includes a data matrix X and a color image matrix map. Map is a data array containing three columns and several rows. The values of each element are double-precision floating point data between [0, 1. Each row of the map matrix represents the values of red, green, and blue. In Matlab, the index image is a "direct ing" from the pixel value to the color ing Table value ". The pixel color is indexed by the data matrix X as the index pointing to the matrix map. For example, value 1 points to the first row in the matrix map, value 2 points to the second row, and so on.

(Complement: Number of integers contained in the X matrix. MAP has several rows, because the number of the X matrix is 7) the number of rows corresponding to the map matrix (Row 7 ))

The color ing table usually exists with the index image. When you call the imread function, Matlab automatically loads the color ing table and the image at the same time, you can select the required color ing table in MATLAB, instead of using the default color ing table. We can use the property cdatamapping to select other color ing tables, including custom color ing tables.
If the image data matrix is a double-precision data type, value 1 points to the first row in the matrix map, and value 2 points to the second row;

If the image matrix is an 8-bit unsigned integer type or a 16-bit unsigned integer type, the value 0 points to the first row in the matrix map, and so on.


Example: display an index image:
[X, MAP] = imread ('canoe. tif ');
Image (X );
Colormap (MAP );

2. Grayscale Images

In Matlab, a grayscale image is like a data matrix I, and the data in I represents the gray value of the image within a certain range. MATLAB stores the grayscale image as a data matrix. The elements in the matrix represent the pixels in the image. The elements in the matrix can be double-precision floating point type, 8-bit or 16-bit unsigned integer type. In most cases, grayscale images are rarely stored together with the color ing table. However, when a grayscale image is displayed, Matlab still uses the predefined default grayscale color ing table in the background.


Example: Use the imagesc and colormap functions to display a grayscale image.
I = imread ('Moon. tif ');
Imagesc (I, [256]);

Colormap (Gray); % grayscale image displayed after the original image is scaled in or out of gray scale.

3. RGB Images

RGB is a true color image. It is stored as a data matrix of N * m * 3 in MATLAB. The elements in the array define the red, green, and blue color values of each pixel in the image. It should be noted that RGB Images are not mapped to the windows color ing table. The pixel colors are determined by the combination of red, green, and blue gray values stored at the pixel position. The Graphic File Format stores RGB Images as 24-bit images. Red, green, and blue represent 8 digits respectively, which can have more than 10 million colors.


4. Binary Images

Same as grayscale images, binary images only require one data matrix, and each pixel only takes two gray values 0 and 1

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.