vendredi 24 novembre 2017

how to use srand() to create image with random dots?

Hi I'm new with C++ I have wrote this code over here I want to make an image 480X640 size with random gausian dots(I have uploaded an image to be more specific) the problem is i get only one gausian dot not as i wanted num_gaus :

void CreateRandGaussian(unsigned char image[][NUMBER_OF_COLUMNS], double sigmaX, double sigmaY,int num_gaus)   
{  
  double a,b,c;  
  unsigned char d;  
  srand(time(NULL));  
  for(int i=0;i<num_gaus;i++) 
  {  
    int centerX=rand()%640;  
    int centerY=rand()%480;  

Rest of the code is to build the gausian form, nothing important

here what I get from my code :
enter image description here
here what i should get : enter image description here




Aucun commentaire:

Enregistrer un commentaire