Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Octave 1.55 KB | None | 0 0
  1. %function burningsDetection
  2. function bue
  3.  
  4. preband5 = imread("preB05.tiff"); %band5 (NIR)
  5. preband7 = imread("preB07.tiff"); %band7 (SWIR)
  6. postband5 = imread("postB05.tiff"); %band5
  7. postband7 = imread("postB07.tiff"); %band7
  8.  
  9. pNIR_pre = double(preband5);
  10. pSWIR_pre = double(preband7);
  11. SWVI_pre = (pNIR_pre - pSWIR_pre)./(pNIR_pre + pSWIR_pre);
  12.  
  13. pNIR_post = single(postband5);
  14. pSWIR_post = single(postband7);
  15. SWVI_post = (pNIR_post- pSWIR_post)./(pNIR_post + pSWIR_post);
  16.  
  17. [n1, m1] = size(SWVI_pre); % n1 - stroki
  18. [n2, m2] = size(SWVI_post); % m1 - stolbcy
  19. if n1 ~= n2 || m1 ~= m2
  20.   PP = checkIfEqual(SWVI_pre, n1, m1 SWVI_post, n2, m2);
  21.  
  22.   SWVI_pre = PP{1};
  23.   SWVI_post = PP{2};
  24. endif
  25.  
  26. DSWVI = SWVI_pre - SWVI_post;
  27.   figure,
  28.   imagesc(DSWVIC)
  29.   %colorbar
  30.   %colormap(jet)
  31.  
  32. print -dpng -r300 SWVI_pre_1346.png
  33.  
  34. %fire_calculate
  35. end
  36.  
  37.  
  38.  
  39. function PP = checkIfEqual(pre, n1, m1 post, n2, m2)
  40.  
  41.   h = abs(n1-n2)
  42.   w = abs(m1-m2)
  43.  
  44.   if n1 < n2
  45.     post = post(1:n2-h, :);
  46.     flag = 1;
  47.   elseif n1 > n2
  48.     pre = pre(1:n1-h, :);
  49.     flag = 2;
  50.   endif
  51.  
  52.   if m1 < m2
  53.     post = post(:, m2:m2+w-1);
  54.     flag = 3;
  55.   elseif m1 > m2
  56.     pre = pre(:, m1:m1+w-1);
  57.     flag = 4;
  58.   endif
  59.  
  60.   PP = {pre; post};
  61.  
  62. endfunction
  63.  
  64.  
  65. function fire_calculate
  66.  
  67. Square = 76100;
  68. pict = imread("kalmykia_fire.png");
  69.  
  70. [n, m] = size(pict);
  71. all = n*m;
  72. white = length(find(pict==255));
  73. black = length(find(pict==0));
  74. no_white = all - black - white;
  75.  
  76. fract = no_white/white;
  77. Percent = fract*100;
  78. Territory = Square*fract;
  79. disp(Territory);
  80.  
  81. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement