I am normalizing an image and then writing to file so that i can use the normalized image but when i write into file i need to convert to uint8 otherwise the file is all blank. However when i do that the value of outimage4 and x is not same and not sure how to solve the problem. Can anyone help.
I4= (imread('x2.png')); I4= double(I4); I4 = I4 - min(min(I4)); outputImage4 =I4 ./ sqrt(sum(sum(I4.^2))); figure(1) imagesc(outputImage4); colormap('gray');
test1= ((outputImage4)./(max(max(outputImage4)))).*256; x= uint8(test1); imwrite(x,'norm1.png', 'png');

 採用された回答

Walter Roberson
Walter Roberson 2013 年 11 月 14 日

0 投票

imagesc() does (data-min)/(max-min) but your manual conversion does data/max

2 件のコメント

Matlabques
Matlabques 2013 年 11 月 14 日
So, is it possible to write to file as can be seen in figure(1) without converting it to unit8 like i did
Walter Roberson
Walter Roberson 2013 年 11 月 15 日
maxd = double(max(I4(:)));
mind = double(min(I4(:)));
x = uint8((double(I4) - mind)./(maxd-mind) .* 256);
imwrite(x,'norm1.png', 'png')

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

その他の回答 (1 件)

Image Analyst
Image Analyst 2013 年 11 月 15 日

0 投票

Simply save the data (image array) as a mat file. It will maintain the precision.

カテゴリ

ヘルプ センター および File ExchangeConvert Image Type についてさらに検索

タグ

質問済み:

2013 年 11 月 14 日

回答済み:

2013 年 11 月 15 日

Community Treasure Hunt

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

Start Hunting!

Translated by