1. colormap
要完全了解這個指令, 必須要從什麼是 an indexed color image 開始。課本 p. 13 Section 1.8 Types of Digital Images 介紹了 4 種數位影像的基本類型。
a. Binary.
b. Grayscale.
c. True color or red-green-blue.
d. Indexed.
Most color images have only a small subset of the more than 16 million possible colors. For convenience of storage and file handling, the image has an associated color map, or color palette, which is simply a list of all the colors used in that image. Each pixel has a value that does not give its color (as for a red-green-blue [RGB] image), but an index to the color in the map.
colormap(gray(n)):
2. 為什麼數值大小相同, 儲存的資料型態不同, imshow 這個指令的輸出就會不同呢?
這是因為 MATLAB 針對不同的資料型態, 對數位影像有不同的詮釋方式。
例如:
針對儲存為 uint8 的灰階(grayscale)影像, MATLAB 認為 0 為純黑色, 255 為純白色, 0 ~ 255 的整數值表示的就是灰階影像的不同明暗強度。
針對儲存為 double 的灰階(grayscale)影像, MATLAB 認為 0 為純黑色, 1 為純白色, 0 ~ 1 間的實數數值所表示的就是灰階影像的不同明暗強度。
因此, FIGURE 3.1 (b) 由於儲存為 double, 所有值都大於 1, 因此, 都被 MATLAB 轉換成純白色了。
(p. 44)
This is because for a matrix of type double, the imshow function expects the values to between 0 and 1, where 0 is displayed as black and 1 is displayed as white....
3. BINARY IMAGES
MATLAB does not have a binary data type as such, but it does have a logical flag, where uint8 values 0 and 1 can be interpreted as logical data.
4. UNIQUE Set unique
B = UNIQUE(A) for the array A returns the same values as in A but with no repetitions. B will also be sorted. A can be a cell array of strings.
UNIQUE(A) 其實就是將 A 陣列中, 重複出現的值去掉, 只保留一個 unique 的值, 然後在依大小排序。
UNIQUE(A,'rows') for the matrix A returns the unique rows of A.
一個 row, 一個 row 分開處理, 做 unique 的動作。
5. 同學學習筆記 (2008w7) 分享, 請今天缺席的同學盡速上網互評。下週我們同樣在第一節課完成互評分享, 請同學記得繳交作業分享網址。
沒有留言:
張貼留言