Image from a double precision matrix
3 ビュー (過去 30 日間)
古いコメントを表示
Dear all
I am trying to implement a phase map of set of 4 images with following steps.
i1_8B=imread('C:\image1.bmp');
i1=double(i1_8B);
i2_8B=imread('C:\image2.bmp');
i2=double(i2_8B);
i3_8B=imread('C:\image3.bmp');
i3=double(i3_8B);
i4_8B=imread('C:\image4.bmp');
i4=double(i4_8B);
PSImage=atan2(i4-i2,i1-i3);
image(PSImage);
colormap(gray);
imwrite(PSImage,'phase.bmp');
The code works well, but when i read image again after saving, the dimentions are 342×433×3(matrix)instead of 342×433. I know that colormap command gives m×n×3 matrix for image when it is read. How can i remove this extra ×3 dimension??? I still want the same image with 342×433.
0 件のコメント
回答 (1 件)
Friedrich
2011 年 8 月 10 日
Hi,
when deletung the 3rd dimension it gets a grayscale image. To do this you can use the rgb2gray function, e.g
imwrite(rgb2gray(PSImage),'phase.bmp');
4 件のコメント
Friedrich
2011 年 8 月 10 日
The formula was for the above example. In general you have to shift the values to [0,1] interval and than multiply it with 255. In general the formula should look like this
gray_image = uint8( ( (X - min(min(X)))/(abs(min(min(X))) + max(max(X)) ) ) * 255 )
参考
カテゴリ
Help Center および File Exchange で Modify Image Colors についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!