示例#1
0
EL_API_VECTO::ParamFile::ParamFile
              (
                      const ElSTDNS string & aName,
                      bool Inferieur ,
                      int  Threshold 

              )  :
	      ParamFonc
	      (
	          Pt2d2complex(Tiff_Im(aName.c_str()).sz()),
		  Inferieur,
		  GetThresh(aName,Threshold)
              ),
              _TiffNameFile (aName)
{
}
示例#2
0
//This function binarizes the nuclei in an image and colors connected components
void computebin(cv::Mat src, cv::Mat BinImPad, cv::Mat BinIm ){
  //Get Image Dimensions
  int thresh = GetThresh(src);
  int nthreads, tid;

  #pragma omp parallel private(tid,nthreads)
  {
    tid = omp_get_thread_num();
    nthreads = omp_get_num_threads();
    int start, end;
    start = tid*(rows/nthreads);
    end   = (tid+1)*(rows/nthreads);
    if( tid == (nthreads-1) ) end = rows;
    for( int j=start; j<rows; ++j )
      for( int i=0; i<cols; ++i )
	if( src.at<unsigned char>(i,j) > thresh  ){
	  BinIm.at<unsigned char>(i,j)  = 0;
	  BIP((i+1),(j+1))	 	= 0;
	}
	else{
	  BinIm.at<unsigned char>(i,j)	= 255;
	  BIP((i+1),(j+1)) 		= UCHAR_MAX;
	}
  }

  //Set the borders of the padded image
  for( int i=0; i<(cols+2); ++i ){
    BIP(i,0)		= 0;
    BIP(i,(rows+1))	= 0;
  }
  for( int i=1; i<(rows+2); ++i ){
    BIP(0,i)		= 0;
    BIP((cols+1),i)	= 0;
  }

  if(write_files){
    std::string out_str1 = "binary_" + file_open;
    cv::imwrite(out_str1.c_str(),BinIm);
  }
  std::cout<<"The threshold is: "<<thresh<<std::endl;
}