Guest User

Untitled

a guest
Apr 26th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scilab 1.30 KB | None | 0 0
  1. global IPD_PATH;
  2.  
  3. RGB = ReadImage(IPD_PATH + 'demos\teaset.png');
  4.  
  5. Image = RGB2Gray(RGB);
  6.  
  7. //Metoda globalna - binaryzacja z ustalonym progiem
  8. //LUT = zeros(1,256);
  9. //a = 169;
  10. //
  11. //for i=1:256
  12. //    if i<a then
  13. //        LUT(i) = 0; //false
  14. //    else
  15. //        LUT(i) = 255; //true
  16. //    end
  17. //end
  18. //
  19. //Image(:,:) = LUT(Image(:,:));
  20.  
  21. //Metoda lokalna - algorytm bernsena
  22. //Image = Image(100:300,100:300)
  23. //
  24. //[h,w] = size(Image);
  25. //Image2 = zeros(h,w);
  26. //
  27. //for i=2:(h-1)
  28. //    for j=2:(w-1)
  29. //        Wmax = max(Image(i-1:i+1,j-1:j+1))
  30. //        Wmin = max(Image(i-1:i+1,j-1:j+1))
  31. //        
  32. //        prog = double(Wmin+Wmax)/2;
  33. //        
  34. //        if Image(i,j) < prog then
  35. //            Image2(i,j) = 0;
  36. //        else
  37. //            Image2(i,j) = 255;
  38. //        end
  39. //    end
  40. //end
  41.  
  42.  
  43. //Metoda lokalna - algoryrtm White-Rohrera
  44. Image = Image(100:300,100:300)
  45.  
  46. [h,w] = size(Image);
  47. Image2 = zeros(h,w);
  48. k = 1.01;
  49.  
  50. for i=2:(h-1)
  51.     for j=2:(w-1)
  52.         srednia = mean(double(Image(i-1:i+1,j-1:j+1)))
  53.        
  54.         prog = double(srednia)/k;
  55.        
  56.         if Image(i,j) < prog then
  57.             Image2(i,j) = 0;
  58.         else
  59.             Image2(i,j) = 255;
  60.         end
  61.     end
  62. end
  63.  
  64. h = CreateHistogram(Image2);
  65.  
  66. plot(h);
  67.  
  68. figure();
  69. ShowImage(Image2, "Obraz");
Add Comment
Please, Sign In to add comment