I mean something like:

Qt Code:
  1. int r;
  2. int g;
  3. int b;
  4.  
  5. //define the followin values for a range of grey defined by you
  6. int r_upper_grey = ...;
  7. int r_lower_grey = ...;
  8. int g_upper_grey = ...;
  9. int g_lower_grey = ...;
  10. int b_upper_grey = ...;
  11. int b_lower_grey = ...;
  12.  
  13. do
  14. {
  15. r= qrand() % 256;
  16. g= qrand() % 256;
  17. b= qrand() % 256;
  18.  
  19. }while ( ( r < r_upper_grey && r > r_lower_grey) &&
  20. ( g < g_upper_grey && g > g_lower_grey) &&
  21. ( b < b_upper_grey && b > b_lower_grey) );
To copy to clipboard, switch view to plain text mode 

Get the picture ? Define a range of grey to avoid and keep random the numbers
until they out of the grey zone