Advertisement
Guest User

Untitled

a guest
May 25th, 2015
276
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. function [ s ] = filtracja( image, mask )
  2.  
  3. org = image(:,:,1);
  4. f = mask;
  5. [xx, yy] = size(org);
  6. a = [org(1,1), org(1,:), org(1,yy); org(:,1), org(:,:), org(:,yy); org(xx,1), org(xx,:), org(xx,yy)];
  7. a = double(a);
  8. [x,y] = size(a);
  9. s = zeros(x,y);
  10.  
  11. if numel(mask) == 9
  12. for i=2:x-1
  13. for j=2:y-1
  14. s(i,j)=f(1,1)*a(i-1,j-1)+f(2,1)*a(i,j-1)+f(3,1)*a(i+1,j-1)+f(1,2)*a(i-1,j)+f(2,2)*a(i,j)+f(3,2)*a(i+1,j)+f(1,3)*a(i-1,j+1)+f(2,3)*a(i,j+1)+f(3,3)*a(i+1,j+1);
  15. end
  16. end
  17.  
  18. elseif numel(mask) == 4
  19. for i=2:x
  20. for j=2:y
  21. s(i,j)=f(1,1)*a(i-1,j-1)+f(2,1)*a(i,j-1)+f(1,2)*a(i-1,j)+f(2,2)*a(i,j);
  22. end
  23. end
  24. end
  25. s = s(2:x-1,2:y-1);
  26. s = fix(s);
  27. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement