如何在matlab中将3x3矩阵转换为RGB图像

时间:2014-01-26 02:28:59

标签: image matlab image-processing rgb

假设我有以下代码:

clc
clear
band1 = imread('C:\Users\sepideh\Desktop\DrAkhundzadeh\Bands\band1.tif');
band2 = imread('C:\Users\sepideh\Desktop\DrAkhundzadeh\Bands\band2.tif');
band3 = imread('C:\Users\sepideh\Desktop\DrAkhundzadeh\Bands\band3.tif');
band4 = imread('C:\Users\sepideh\Desktop\DrAkhundzadeh\Bands\band4.tif');
band5 = imread('C:\Users\sepideh\Desktop\DrAkhundzadeh\Bands\band5.tif');
band7 = imread('C:\Users\sepideh\Desktop\DrAkhundzadeh\Bands\band7.tif');
Vegetation = band4-band3;
Oxide = band3-band1;
Hydroxyl = band5-band7;
%Normalize
NormalizedVegetation = ( Vegetation - min(min(Vegetation)))*255/(max(max(Vegetation)) - min(min(Vegetation)));
NormalizedOxide = ( Oxide - min(min(Oxide)))*255/(max(max(Oxide)) - min(min(Oxide)));
NormalizedHydroxyl = ( Hydroxyl - min(min(Hydroxyl)))*255/(max(max(Hydroxyl)) - min(min(Hydroxyl)));
FalseColor(:,:,1) = NormalizedVegetation;
FalseColor(:,:,2) = NormalizedOxide;
FalseColor(:,:,3) = NormalizedHydroxyl;
RGBIMAG = uint8(FalseColor);
imshow(RGBIMAG);  

我的问题在于:

RGBIMAG = uint8(FalseColor);  

会导致所有图像变暗。如何告诉matlab 3维矩阵的每个级别都是RGB图像的不同波段而不改变其元素。

1 个答案:

答案 0 :(得分:0)

要转换为uint8,您必须使用:

RGBIMAG = im2uint8(FalseColor);

该函数接收ur double数组(值btw 0-1)并将它们转换为范围为(0,255)的RGB值。