how can i display a gray scale image instead of mapping 0,255 , between 0 , 127 ?

3 ビュー (過去 30 日間)
Akshit
Akshit 2015 年 1 月 23 日
回答済み: Image Analyst 2015 年 1 月 23 日
how can i display a gray scale image instead of mapping 0,255 , between 0 , 127 ?

回答 (3 件)

Chad Greene
Chad Greene 2015 年 1 月 23 日
caxis([0 127])
  1 件のコメント
Akshit
Akshit 2015 年 1 月 23 日
thankd , i did ,but got this error. Error in caxis ????? arg = 0;

サインインしてコメントする。


Shoaibur Rahman
Shoaibur Rahman 2015 年 1 月 23 日
NewImage = 127*mat2gray(Image)

Image Analyst
Image Analyst 2015 年 1 月 23 日
This is an ambiguous question. What is the initial range of your image? Do you want to change that? Or just change how it's displayed? One way is
imshow(grayImage, [0, 127]); % Values more than 127 will get clipped to 127.
or
imshow(uint8(127 * mat2gray(grayImage)));
The last line of code will scale the image range [min, max] to [0,1]. Then it multiplies by 127 and converts to uint8 so it will display properly in the [0,255] range. I believe Shoibur's code will display as all white because newImage will be a double and imshow expects doubles to be in the range 0-1 and anything above 1 will get clipped. So that's why I converted to uint8, which uses a [0,255] display range by default.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by