gitinore *.txt files
[wrf-fire-matlab.git] / cycling / expand_perim.m
blobd3db4381b3ae7ba8c203c7525da8356815ce3082
1 function ep = expand_perim(red,perim,n)
2 %function expands the perimeter around a fire
3 %red = subest_domain(w)
4 %perim - perim struct from perim2gran function
5 %n how much blurring, standard deviation in the imgaussfilt function
6 %find lon,lat within the perimeter
7 lon = linspace(red.min_lon,red.max_lon,length(perim.lat));
8 lat = linspace(red.min_lat,red.max_lat,length(perim.lat));
9 [fxlong,fxlat]=meshgrid(lon,lat);
10 in = inpolygon(fxlong,fxlat,perim.lon,perim.lat);
11 %figure,scatter(fxlong(in),fxlat(in))
13 %blur the mask to expand it
14 blur = imgaussfilt(double(in),n);
15 blur = logical(blur);
16 blur2 = imgaussfilt(double(in),n-1/2);
17 blur2 = logical(blur2);
18 %figure,scatter(red.fxlong(new_in),red.fxlat(new_in))
19 [new_in,new_on] = inpolygon(fxlong,fxlat,fxlong(blur),fxlat(blur));
21 diff = logical(blur-blur2);
22 figure,scatter(fxlong(diff),fxlat(diff));
23 %figure,scatter(red.fxlong(new_on),red.fxlat(new_on));
24 hold on,scatter(perim.lon,perim.lat)
25 title('Expanded Perim and Original')
27 ep = perim;
28 ep.lon = fxlong(diff);
29 ep.lat = fxlat(diff);
33 end %function