Advertisement
Guest User

matcode

a guest
Apr 4th, 2017
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 1.76 KB | None | 0 0
  1. [centers, radii] = imfindcircles(cF_EDGE,[R_MIN R_MAX]);
  2.  
  3. % We have saved all the centers and radii of the circles detected
  4.  
  5. n_circles = length(radii);
  6.  
  7. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  8. % If n_circles = 0, we have to do something (Later)
  9.  
  10. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  11.  
  12.  
  13. % Now we will mark these circles in the copied_Frame
  14.  
  15. % As we want to process the circles one by one we will add new changes to
  16. % already changed version
  17.  
  18. cF_ACM = copyFrame; % Copying again
  19.  
  20. for n_c = 1:n_circles % For all detected circles
  21.    
  22.     % Color detection by analyzing RGB components
  23.    
  24.     color_CRC;
  25.    
  26.     n_points = 0;
  27.    
  28.     cX = uint8(centers(n_c,1));
  29.     cY = uint8(centers(n_c,2));
  30.    
  31. %     for npx = (cX - RNG_PXL:cX + RNG_PXL)
  32. %         for npy = (cY - RNG_PXL:cY + RNG_PXL)
  33. %             R_component = R_component + copyFrame(npx,npy,1);
  34. %             G_component = G_component + copyFrame(npx,npy,2);
  35. %             B_component = B_component + copyFrame(npx,npy,3);
  36. %            
  37. %             n_points = n_points + 1;
  38. %            
  39. %         end
  40. %     end
  41.    
  42.     % Normalizing / Averaging
  43.    
  44.     R_component = extraCop(cY,cX,1) %= R_component/n_points;
  45.     G_component = extraCop(cY,cX,2) %= G_component/n_points;
  46.     B_component = extraCop(cY,cX,3) %= B_component/n_points;
  47.    
  48.    
  49.     % Too dark
  50.    
  51.     if (R_component <= DRK_RNG && G_component <= DRK_RNG && B_component <= DRK_RNG)
  52.         color_CRC = 'Balck';
  53.     % Red color
  54.     elseif (R_component/G_component > RED_RAT && R_component/B_component > RED_RAT)
  55.         color_CRC = 'Red';
  56.     % By default White color
  57.     else
  58.         color_CRC = 'White';
  59.     end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement