Advertisement
Guest User

Untitled

a guest
May 12th, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Octave 0.68 KB | None | 0 0
  1. image = imread('nemo.jpg');
  2. buff = zeros(size(image)); %bufor obrazka po przetwrzaniu
  3.  
  4. mask = ...
  5. [ -1, -1, -1
  6.   -1, 8, -1
  7.   -1, -1, -1 ]
  8.  
  9. n = size(mask)(1)  % rozmiar boku maski  
  10. offset = floor(n/2);
  11.  
  12. for x=1+offset:size(image,1)-offset
  13.     for y=1+offset:size(image,2)-offset
  14.         buff(x,y,1) = sum(sum( mask .* double( image(x-offset:x+offset, y-offset:y+offset, 1) ) ));
  15.         buff(x,y,2) = sum(sum( mask .* double( image(x-offset:x+offset, y-offset:y+offset, 2) ) ));
  16.         buff(x,y,3) = sum(sum( mask .* double( image(x-offset:x+offset, y-offset:y+offset, 3) ) ));
  17.     end
  18. end
  19.  
  20. %wyswietlanie
  21. subplot(1,2,1)
  22. imshow(image);
  23. subplot(1,2,2);
  24. imshow(uint8(buff));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement