在MATLAB中间聊,imshow(A)
默認(rèn)顯示的是0~255
彩库,imshow(A,[])
顯示的是min(A)~max(A)
秩伞。
文檔中對(duì)于imshow(A,[])的解釋
IMSHOW(I,[LOW HIGH]) displays the grayscale image I, specifying the display range for I in [LOW HIGH]. The value LOW (and any value less than LOW) displays as black, the value HIGH (and any value greater than HIGH) displays as white. Values in between are displayed as intermediate shades of gray, using the default number of gray levels. <font color="red">If you use an empty matrix ([]) for [LOW HIGH], IMSHOW uses <font color="green">[min(I(:)) max(I(:))]</font>; that is, the minimum value in I is displayed as black, and the maximum value is displayed as white.</font>
所以摄悯,imshow(A,[])在MATLAB中的原理就是
b=uint((a-min(a(:)))./(max(a(:))-min(a(:)))*255);
這樣做的直接意義就是使得顯示的圖像的臨近像素點(diǎn)的梯度變大峡竣,即各像素點(diǎn)間區(qū)分度變大秸谢,這樣就能更加明顯地區(qū)分出差異效果凛澎。
例如,圖片A的灰度值都在20以下,但確實(shí)又有灰度變化,如果你直接imshow估蹄,那么看起來幾乎都是黑的塑煎。而采用imshow(A,[])
后會(huì)從最小到最大拉伸顯示。
如圖1所示顯示是對(duì)Lena圖進(jìn)行聚類之后的結(jié)果臭蚁,上面的是沒有拉升顯示的最铁,下面的進(jìn)行了拉升顯示的】宥遥可以明顯看出拉升顯示后的圖像的亮度和對(duì)比度較原圖有明顯變化冷尉。
在Python中如何翻譯imshow(A, [])呢?
I_stretch = ((I-I.min())/(I.max()-I.min())*255).astype(uint8)
可以看出系枪,這其實(shí)就是一個(gè)歸一化的操作雀哨。
作者水平有限,暫時(shí)就寫到這里私爷。更深入的思考雾棺,留待下一次更新。
附
該文章于2017年6月24日于CSDN上首次發(fā)表衬浑,2017年12月24日搬家至此捌浩!