假设我有以下代码:
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图像的不同波段而不改变其元素。
答案 0 :(得分:0)
要转换为uint8,您必须使用:
RGBIMAG = im2uint8(FalseColor);
该函数接收ur double数组(值btw 0-1)并将它们转换为范围为(0,255)的RGB值。