Beispiel #1
0
TYPE * genRandomImage(int xsize, int ysize, int zsize){
	int i,j,k;
	int row,col,slide;

	TYPE *image;	

	image=(TYPE *)malloc(sizeof(TYPE)*xsize*ysize*zsize);

	srand(time(NULL));
	//srand(1);
	for(k=0;k<zsize;k++){
		for(i=0;i<xsize;i++){
			for(j=0;j<ysize;j++){

				image[k*(xsize*ysize) + i*ysize + j]= generateGaussianNoise(); // N(0,1) random
				//image[k*(xsize*ysize) + i*ysize + j]= (TYPE)( 2.0*((TYPE)rand())/((TYPE)RAND_MAX) - 1.0 ); // uniform [0,1] random
				//image[k*(xsize*ysize) + i*ysize + j]= (TYPE)(((TYPE)rand())/((TYPE)RAND_MAX)); // uniform [0,1] random
				//image[k*(xsize*ysize) + i*ysize + j]= (TYPE)(rand()%2); // {0,1} random
				//image[k*(xsize*ysize) + i*ysize + j]= (TYPE)((i*j+k)%2); // non random
				//printf("image[%d]=%f\n",k*(xsize*ysize) + i*ysize + j,image[k*(xsize*ysize) + i*ysize + j]);
			}
		}
	}
	return image;
}
Beispiel #2
0
void FillMatrix(double *A,int n)
{
  double temp;
  
  srand(time(NULL)); 
  for (int i=0; i<n; i++)
      {
      for (int j=i; j<n; j++)
          {
          temp=generateGaussianNoise(0.2);
          A[i*n+j]=temp;
          A[j*n+i]=temp;
          }
      }
}
Beispiel #3
0
int generateGaussianInt(const int &variance, const int &avg){
	return (int)(variance*generateGaussianNoise())+avg;
}
Beispiel #4
0
double generatePositiveGaussianNoise(const double &variance, const double &avg){
	return (variance*abs(generateGaussianNoise()))+avg;
}
Beispiel #5
0
double generateGaussianNoise(const double &variance, const double &avg)
{
	return (variance*generateGaussianNoise())+avg;
}