Advertisement
z-nexx

Blur kernel generator

Nov 3rd, 2020 (edited)
4,360
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Octave 0.60 KB | None | 0 0
  1. %NOTE: the package octave-image (in debian and AUR) is needed
  2. pkg load image
  3.  
  4. width = 23; %anything above 16 here is big and might cause slow rendering
  5. height = 23;
  6. sigma = 2*pi; %sigma is the standard deviation (i.e. the "width" or sharpness of the blur)
  7.  
  8. h = fspecial('gaussian', [width height], sigma)(:); %generates the gaussian matrix
  9. [scale, index] = max(h);
  10. h = h / scale; %scales the matrix so that the max element = 1
  11. h([index]) = []; %removes the max element (the center one)
  12.  
  13. fprintf('blur-kern = "%d,%d,', width, height)
  14. for n=1:size(h,1)
  15.     fprintf('%.8f,', h(n))
  16. end
  17. fprintf('";\n')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement