Demo entry 6355686

image analysis

   

Submitted by SJ on Apr 14, 2017 at 06:17
Language: Matlab. Code size: 2.2 kB.

%% input image and enhance image
Image1 = multibandread('paris.lan', [512, 512, 7], 'uint8=>uint8',128,'bil', 'ieee-le',...
    {'Band', 'Direct', [4, 3, 2]});
figure
imshow(Image1)
title('Paris.lan')

decorrImage1 = decorrstretch(Image1, 'Tol', 0.01);
figure
imshow(decorrImage1)
title('Paris.lan with Decorrelation Stretch, 0.01')

%% show <Band red> and <Band NIR>
red = im2single(Image1(:,:,2));
figure
subplot(1,2,1)
imshow(red)
title('Band red')

NIR = im2single(Image1(:,:,1));
subplot(1,2,2)
imshow(NIR)
title('Band NIR')

%% calculate NDVI and show binarized NDVI with threshold 0.3
NDVI = (NIR - red) ./ (NIR + red);
figure
subplot(1,2,1)
imshow(NDVI,[-1,1])
title('NDVI')

threshold = 0.3;
binaryNDVI = (NDVI > threshold);
% figure
subplot(1,2,2)
imshow(binaryNDVI);
title(['NDVI threshold = ', num2str(threshold)])

%% show NDVI NIR-red spectral scatter plot
figure
subplot(1,2,1)
plot(red, NIR,'+b')
hold on
plot(red(binaryNDVI(:)), NIR(binaryNDVI(:)),'+g')
subplot(1,2,2)
imshow(binaryNDVI)
title('NDVI, threshold = 0.3')

%% calculate RVI and show binarized RVI with threshold 0.99
RVI = NIR ./ red;
figure
subplot(1,2,1)
imshow(RVI)
title('RVI')

thresholdRVI = 0.99;
binaryRVI = (RVI > thresholdRVI);
% figure
subplot(1,2,2)
imshow(binaryRVI)
title(['RVI threshold = ', num2str(thresholdRVI)])

%% calculate DVI and show binarized DVI with threshold 0.15
DVI = NIR - red;
figure
subplot(1,2,1)
imshow(DVI)
title('DVI')

thresholdDVI = 0.15;
binaryDVI = (DVI > thresholdDVI);
% figure
subplot(1,2,2)
imshow(binaryDVI)
title(['DVI threshold = ', num2str(thresholdDVI)])

%% calculate SAVI and show binarized SAVI with threshold 0.3
%% compare L = 0.1/0.5/0.9 in SAVI with threshold 0.3
L = [0.1, 0.5, 0.9];
thresholdSAVI = 0.3;
SAVI = (1 + L(3)) * (NIR - red) ./ (NIR + red + L(3));
figure
imshow(SAVI)
title(['SAVI L = ',num2str(L(3))])
for i=1:3
    SAVI = (1 + L(i)) * (NIR - red) ./ (NIR + red + L(i));
    eval(['binarySAVI_',num2str(i),'=','(SAVI > thresholdSAVI);'])
    figure
    eval(['imshow(binarySAVI_',num2str(i),');'])
    title(['SAVI L = ', num2str(L(i)), ' threshold = ', num2str(thresholdSAVI)])
end

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).