forked from GERSL/Fmask
-
Notifications
You must be signed in to change notification settings - Fork 0
/
BufferMasks.m
66 lines (64 loc) · 1.62 KB
/
BufferMasks.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
function [cloud,shadow,snow] = BufferMasks(pcloud,cdpix,pshadow,csdpix,psnow,sdpix)
% BUFFERMASKS Dilate cloud/cloud shadow/snow with cdpix/csdpix/sdpix with
% default value of 3/3/3.
%
% Syntax
%
% [cloud,shadow,snow] =
% BufferMasks(pcloud,cdpix,pshadow,csdpix,psnow,sdpix)
%
% Description
%
% Dilate cloud/cloud shadow/snow with cdpix/csdpix/sdpix with
% default value of 3/3/3.
%
% Input arguments
% pcloud Cloud mask.
% cldpix Dilated number of pixels for cloud with default value of 3.
% pshadow Cloud shadow mask.
% sdpix Dilated number of pixels for cloud shadow value of 3.
% psnow Snow mask.
% snpix Dilated number of pixels for snow value of 3.
%
% Output arguments
%
% cloud Final dilated cloud mask.
% shadow Final dilated cloud shadow mask.
% snow Final dilated snow mask.
%
% Example
%
% [cloud,shadow,snow] =
% BufferMasks(pcloud,3,pshadow,3,psnow,3);
%
%
% Author: Shi Qiu ([email protected])
% Date: 2. November, 2017
% buffer cloud
if cdpix>0
CEs=strel('square',2*cdpix+1);
cloud=imdilate(pcloud,CEs);
clear pcloud CEs cdpix;
else
cloud=pcloud;
clear pcloud
end
% buffer cloud shadow
if csdpix>0
CSEs=strel('square',2*csdpix+1);
shadow=imdilate(pshadow,CSEs);
clear pshadow CSEs csdpix;
else
shadow=pshadow;
clear pshadow
end
% buffer snow
if sdpix>0
SEs=strel('square',2*sdpix+1);
snow=imdilate(psnow,SEs);
clear psnow SEs sdpix;
else
snow=psnow;
clear psnow
end
end