Beispiel #1
0
	void Depth::saveImage(const string &filename, double amp) const{
		Mat outmat(getHeight(), getWidth(), CV_8UC3);
		uchar* pData = outmat.data;

		updateStatics();
		double mind = 0;
		double maxd = max_depth;
		if(amp < 0){
			mind = min_depth;
			CHECK_NE(min_depth, max_depth);
			amp = 255.0 / (maxd - mind);
		}
		for (int y = 0; y < getHeight(); y++) {
			for (int x = 0; x < getWidth(); x++) {
				const int idx = x + y * getWidth();
				double curdepth = (data[idx] - mind) * amp;
				if(curdepth > 255)
					curdepth = 255;
				if (curdepth >= 0)
					for(int i=0; i<3; ++i)
						pData[3*idx+i] = (uchar)curdepth;
				else{
					pData[3*idx] = 0;
					pData[3*idx+1] = 0;
					pData[3*idx+2] = 255;
				}
			}
		}
		imwrite(filename, outmat);
	}
Beispiel #2
0
Datei: am.c Projekt: BigEd/wp34s
int main() {
	//outmat("AM8", am8, 64);
	outmat("A11", am11, 100);
	//outmat("A12", am12, 100);
	//outmat("A13", am13, 100);
	return 0;
}
void trans_snd_rcv(double *buff,  double *trans, int Block_order,
                   double *work,  int my_ID, int Num_procs)
{
   int iphase;
   int block_size;
   int send_to, recv_from;
   double *bblock;    /* pointer to current location in buff */
   double *tblock;    /* pointer to current location in trans */
   MPI_Status status;

   block_size = Block_order * Block_order;

/*******************************************************************
**  Do the tranpose in Num_procs phases.  
**
**  In the first phase, do the diagonal block.  Then move out 
**  from the diagonal copying the local matrix into a communication 
**  buffer (while doing the local transpose) and send to processor 
**  (diag+phase)%Num_procs.
*******************************************************************/
   bblock = buff  + my_ID*block_size;
   tblock = trans + my_ID*block_size;

   transpose(bblock, Block_order, tblock, Block_order, 
             Block_order, Block_order);

   for (iphase=1; iphase<Num_procs; iphase++){

      send_to = TO(my_ID, iphase, Num_procs);
      bblock  = buff + send_to * block_size;

      transpose(bblock, Block_order, work, Block_order, 
             Block_order, Block_order);
	 
#ifdef DEBUG 
   printf("\n transposed block for phase %d on node %d is \n",
               iphase,my_ID);
   outmat(work, Block_order, Block_order);
   fflush(stdout);
#endif
  
      MPI_Send (work, block_size, MPI_DOUBLE, send_to,
                iphase, MPI_COMM_WORLD);

      recv_from = FROM(my_ID, iphase, Num_procs);
	 
      tblock  = trans + recv_from * block_size;
 
#ifdef DEBUG
   printf("\n phase %d on node %d, recv_from = %d and send_to = %d\n",
                             iphase, my_ID, recv_from, send_to);
   printf("\n %x %d %d %d %x \n", tblock, block_size, recv_from, 
                             iphase, &status );
   fflush(stdout);
#endif

         MPI_Recv (tblock, block_size, MPI_DOUBLE, recv_from,
              iphase, MPI_COMM_WORLD, &status);  

   }
}