Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. function [acumulator,outputimage] = irhough(Im,pattern,fnd)
  2. [h,w] = size(Im);
  3. [hp,wp] = size(pattern);
  4. acumulator = zeros(h,w);
  5. outputimage(:,:,1)=uint8(Im);
  6. outputimage(:,:,2)=uint8(Im);
  7. outputimage(:,:,3)=uint8(Im);
  8.  
  9. %czesc zasadnicza tutaj
  10. for x = 1:w-wp+1
  11. for y = 1:h-hp+1
  12. p_sum=sum(abs(Im(y:y+hp-1,x:x+wp-1)-pattern),'all');
  13. acumulator(y,x)=p_sum;
  14. end
  15. end
  16.  
  17. %to tylko rysowanie
  18. acumulator=acumulator(1:h-hp+1,1:w-wp+1);
  19. acumulatortmp = acumulator;
  20. for i = 1:fnd
  21. [hmin,wmin] = find(acumulatortmp == min(acumulatortmp(:)));
  22.  
  23. outputimage(hmin:hmin+hp-1,wmin,2)=0;
  24. outputimage(hmin:hmin+hp-1,wmin+wp-1,2)=0;
  25. outputimage(hmin,wmin:wmin+wp-1,2)=0;
  26. outputimage(hmin+hp-1,wmin:wmin+wp-1,2)=0;
  27.  
  28. outputimage(hmin:hmin+hp-1,wmin,3)=0;
  29. outputimage(hmin:hmin+hp-1,wmin+wp-1,3)=0;
  30. outputimage(hmin,wmin:wmin+wp-1,3)=0;
  31. outputimage(hmin+hp-1,wmin:wmin+wp-1,3)=0;
  32.  
  33. acumulatortmp(hmin-(hp/2):hmin+(hp/2),wmin-(wp/2):wmin+(wp/2))=max(acumulatortmp(:));
  34. end
  35. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement