2008年10月24日 星期五

CH3

這禮拜開始因為要考試又要交作業,所以差點沒時間看影像處理,不過總算抓到時間看了
CH3
Basic of Image Display

The factors that will affect the display:
1.ambuent lighting(漫射光)
2.the monitor type and settings(儀器種類以及設定)
3.the graphics card(顯示卡)
4.monitor resolution(儀器解析度)

*The same Image may be different when viewed on a dull(較不鮮明) CRT monitor(陰極射線管) compared with a bright LCD monitor.
*The resolution can affect the display of an image.
*A higher resolution may result in the image taking up less physical area on the screen, but this may be counteracted by a loss in the color depth.(高解析度可以獲得較細微之影像,但可能降低色彩深度<=不確定翻的對不對)
CRT: http://zh.wikipedia.org/w/index.php?title=CRT&variant=zh-tw
LCD:
http://zh.wikipedia.org/w/index.php?title=LCD&variant=zh-tw

>> c=imread('cameraman.tif');
>> image(c)

因為image 算是MATLAB裡面很基本的指令,所以不一定能呈現出原來的圖像。
Image 是以電腦中隱藏的color map去找顏色(名稱為jet)
事實上還有其他內定的color map(下圖為MATLAB的help裡面找的)
因此當使用imshow語法來顯示跟上面相同之圖像,則輸入
>> imshow(c,jet) 即可
利用image語法呈現出原影像色彩
使用以下語法
truesize:
可利用此語法設定顯示大小,使用truesize([256,256]),則設定成水平256以及垂直256像素,當沒設定數字時,則會顯示預設大小。


axis off:
去除圖像周圍之座標軸

colormap(gray(247)):
調整color map的色彩亮度(灰階值)
也可以在裡面標示gray以外的color map去設定(參考上面貼的第二張圖)
上面所使用的圖來說,當用colormap(gray())設定的數值越大,則亮度越暗,數值越小,亮度越亮。(在此就不多弄圖了,語法請參照課本p43,並自行跑圖)

*當使用會產生三維陣列之圖片時,Image則會忽略color map

Imshow
=>使用的格式為’uint8’
=>整數值為0~255
使用以下語法

>> c=imread('caribou.tif');
>> cd=double(c);
>> imshow(c)
figure
imshow(cd)
Figure1為uint8格式的影像
Figure2為double格式的影像(但imshow只能讀取uint8的內容,故顯示出來為空白的)


由於cd的格式是double,故顯示的數值範圍為0~1
>>figure
>>imshow(cd/255)
>>figure
>>imshow(cd/512)
因為數值是0~1(數值越高越亮,故除較大數值則會較暗)
>>figure
>>imshow(cd/128)
數值的範圍變為0~2,所以判定1~2的數值所顯示的亮度均為白色的

*uint8轉換成double的方法:
(1) cd=double(c);
(2)cd=im2double(c);
*double轉換成uint8
(1)c2=uint8(255*cd);
(2)c3=im2uint8(cd);

BINARY IMAGES
(1)Binary image will have only two values:0 and 1
(2)MATLAB doesn’t have binary data type , but it does have logical flag (uint8 values 0 and 1 can be interpreted as logical data)

>> c1=c>120;
>> imshow(c1)

Bit Planes:
(1)Grayscale images can be transformed into a sequence of binary images by breaking them up into their bit-planes.
8bit=2^8=256
取圖像中各c0~c7的值
將C0~C7的圖顯示出來:
>>ca(:,:,1)=mod(cd,2); %C0
ca(:,:,2)=mod(floor(cd/2),2); %C1
ca(:,:,3)=mod(floor(cd/4),2); %C2
ca(:,:,4)=mod(floor(cd/8),2); %C3
ca(:,:,5)=mod(floor(cd/16),2); %C4
ca(:,:,6)=mod(floor(cd/32),2); %C5
ca(:,:,7)=mod(floor(cd/64),2); %C6
ca(:,:,8)=mod(floor(cd/128),2); %C7

>> figure,for i=1:8 ,subplot(2,4,i),imshow(ca(:,:,i)),end

顯示8張圖



SPATIAL RESOLUTION(空間解析)
使用imresize語法
Imsize(x,1/2)
=>陣列(像素)減少
當其陣列值為256x256時
x1=Imsize(x,1/2); =>為128x128
當使用x3=imresize(Imsize(x,1/2),2);
則依然為256x256(但圖像會變模糊)
(圖參照課本P51~52 (圖太多了@@))

Quantization and Dithering(量化跟混色)
Quantization:
The number of grayscales used to represent the image
Uniform Quantization:
To represent an image with only n grayscale, we divide the range of grayscales into n equal (or near equal) ranges and map the ranges to the values 0 to n-1.
使用語法grayslice
>>ww=grayslice(x,4); %4到表為劃分成區塊(當數字越大,最後呈現的與原圖越接近)
>>imshow(ww,gray(4))
取得的圖因劃分的範圍太大,所以就沒那麼清晰

DITHERING:
Refer to the process of reducing the number of colors in an image.


(這段看不太懂,外加還沒看完,後來看完補上!!)

心得與問題:
(1)這禮拜真的很忙,一下子要考試,一下交作業,最後好不容易找到時間弄完這個,CH3前面大致上還看的懂,不過後面看的比較吃力些(目前大約還有P56~62沒看完,看完會補上)。

問題:
(1)在空間解析SPATIAL RESOLUTION上有點問題Imsize(x,1/2)與原來的X做比較的話,其陣列的大小明顯有差,但是不清楚縮小時所用的方法,原本以為X1(1,1)的值是X(2,1)+X(1,2),但是其結果不符合(X1(1,1)=109 X(2,1)+X(1,2)=109.5),想說利用週圍的值稍作計算應該可以算出來,但目前為止還沒找到可以解釋X1數值是如何取得的。

沒有留言:

張貼留言