コード例 #1
0
void clsThermalDetector::ThermalDetectorMain(IplImage **pImgSrc,int*iErrCode,GlobalHelper &g_GH)
{
	pImgSource = *pImgSrc;

	if(!pImgSource)
	{
		//g_GH.DebugOut("ThermalDetector: Source Image NULL",FALSE);
		*iErrCode = 1;
		return;
	}



	iNC = pImgSource->width;
	iNR = pImgSource->height;
	
	pImgDest = g_GH.cvCreateImageProxy(cvSize(pImgSource->width,pImgSource->height),pImgSource->depth,3);
	if(!pImgDest)
	{
		//g_GH.DebugOut("NightVision: CreateImage failed",FALSE);
		*iErrCode = 1;
		return;
	}
	Invert(g_GH);
	g_GH.cvCvtColorProxy(pImgSource,pImgDest,CV_BGR2HSV);
	Histogram(g_GH);
	HeatMap(g_GH);
	g_GH.cvCvtColorProxy(pImgDest,pImgSource,CV_HSV2BGR);

	//*pImgSrc = pImgDest;
	g_GH.cvReleaseImageProxy(&pImgDest);

}
const QImage& ImageTransformer::
equalize()
{
    Histogram();

    int min;
    for(min=0;min<_HistogramedData.size()&&_HistogramedData[min] == 0;++min);

    int max;
    for(max=_HistogramedData.size()-1;max>=0&&_HistogramedData[max] == 0;--max);

    int width = _DataHandled.width();
    int height = _DataHandled.height();
    int pixnum = width*height;

    for(int i=1;i<_HistogramedData.size();++i)
    {
        _HistogramedData[i]+=_HistogramedData[i-1];
    }

    int dif = max - min;

    for(int i=0;i<width;++i)
    {
        for(int j=0;j<height;++j)
        {
            int tmpR =(_HistogramedData[QColor(_DataHandled.pixel(i,j)).red()]*1.0 / pixnum) * dif + min;
            int tmpG =(_HistogramedData[QColor(_DataHandled.pixel(i,j)).green()]*1.0 / pixnum) * dif + min;
            int tmpB =(_HistogramedData[QColor(_DataHandled.pixel(i,j)).blue()]*1.0 / pixnum) * dif + min;
            _DataHandled.setPixel(i,j,QColor(tmpR,tmpG,tmpB).rgb());
        }
    }

    return _DataHandled;
}
コード例 #3
0
ファイル: histogram.cpp プロジェクト: nikky4D/xform_recipes
vector<Histogram> histograms(Image<float> &input, int nbins, int skip) {
    Image<float> h_hist(nbins+2,3); // 2 floats for mini and max at beginning
    hl_histogram_color_float(input, nbins, skip, h_hist);
    vector<Histogram> ret;

    Histogram h = Histogram(h_hist.data(),nbins);
    ret.insert(ret.end(),h);

    h = Histogram(h_hist.data()+h_hist.width(),nbins);
    ret.insert(ret.end(),h);

    h = Histogram(h_hist.data()+2*h_hist.width(),nbins);
    ret.insert(ret.end(),h);

    return ret;
}
コード例 #4
0
ファイル: histogram.cpp プロジェクト: nikky4D/xform_recipes
vector<Histogram> histograms_of_laplacian(Image<uint32_t> &input, Image<uint32_t> &ds2, int nbins, int skip) {
    Image<float> h_hist(nbins+2,3); // 2 floats for mini and max at beginning
    hl_histogram_of_laplacian_coefficients(input, ds2, nbins, h_hist);
    vector<Histogram> ret;

    Histogram h = Histogram(h_hist.data(),nbins);
    ret.insert(ret.end(),h);

    h = Histogram(h_hist.data()+h_hist.width(),nbins);
    ret.insert(ret.end(),h);

    h = Histogram(h_hist.data()+2*h_hist.width(),nbins);
    ret.insert(ret.end(),h);

    return ret;
}
コード例 #5
0
ファイル: Histogram.cpp プロジェクト: rinoshinme/Styrene
	ImageGray HistEq(const ImageGray& image)
	{
		std::vector<int> hist = Histogram(image);
		int histSum = 0;
		for (int i = 0; i < 256; ++i)
			histSum += hist[i];

		int accumulateSum = 0;
		std::vector<GrayValue> map(256);
		for (int i = 0; i < 256; ++i)
		{
			accumulateSum += hist[i];
			map[i] = static_cast<GrayValue>(accumulateSum * 255.0 / histSum);
		}

		// create new image and map color
		int width = image.GetWidth();
		int height = image.GetHeight();
		GrayValue* data = new GrayValue[width * height];
		for (int x = 0; x < width; ++x)
		{
			for (int y = 0; y < height; ++y)
			{
				data[y * width + x] = map[image.GetValue(x, y)];
			}
		}
		ImageGray gray(width, height, data);
		delete[] data;
		return gray;
	}
コード例 #6
0
bool LocalErrorHistogramManager::loadFromFile(const std::string& filename) {
    std::ifstream file(filename, std::ios::in | std::ios::binary);
    if (!file.is_open()) {
        return false;
    }

    file.read(reinterpret_cast<char*>(&_numInnerNodes), sizeof(int));
    file.read(reinterpret_cast<char*>(&_numBins), sizeof(int));
    file.read(reinterpret_cast<char*>(&_minBin), sizeof(float));
    file.read(reinterpret_cast<char*>(&_maxBin), sizeof(float));

    int nFloats = _numInnerNodes * _numBins;
    float* histogramData = new float[nFloats];

    file.read(reinterpret_cast<char*>(histogramData), sizeof(float) * nFloats);
    _spatialHistograms = std::vector<Histogram>(_numInnerNodes);
    for (int i = 0; i < _numInnerNodes; ++i) {
        int offset = i*_numBins;
        float* data = new float[_numBins];
        memcpy(data, &histogramData[offset], sizeof(float) * _numBins);
        _spatialHistograms[i] = Histogram(_minBin, _maxBin, _numBins, data);
    }

    file.read(reinterpret_cast<char*>(histogramData), sizeof(float) * nFloats);
    _temporalHistograms = std::vector<Histogram>(_numInnerNodes);
    for (int i = 0; i < _numInnerNodes; ++i) {
        int offset = i*_numBins;
        float* data = new float[_numBins];
        memcpy(data, &histogramData[offset], sizeof(float) * _numBins);
        _temporalHistograms[i] = Histogram(_minBin, _maxBin, _numBins, data);
    }

    delete[] histogramData;
    // No need to deallocate histogram data, since histograms take ownership.
    file.close();
    return true;
}
コード例 #7
0
ファイル: ProbTable.cpp プロジェクト: Chenxofhit/fast-mRMR
/**
 * Generates a table with all the marginal probabilities for each value for all features.
 *
 * This table is kept in memory so the marginal probability is computed only one time.
 */
void ProbTable::calculate() {
	Histogram histogram = Histogram(rawData);
	int i = 0;
	int j = 0;
	t_prob value = 0;
	t_histogram hist_data;
	for (i = 0; i < featuresSize; ++i) {
		table[i] = (t_prob*) malloc(valuesRange[i] * sizeof(t_prob));
		hist_data = histogram.getHistogram(i);
		for (j = 0; j < valuesRange[i]; ++j) {
			value = (t_prob) hist_data[j] / (t_prob) datasize;
			table[i][j] = value;
		}
	}
}
コード例 #8
0
ファイル: edda_vtk_reader.cpp プロジェクト: Junpeng-Wang/edda
AbstractDistrArray *genHistoArray(vtkPointData *vtk_point_data)
{
  char arrayName[1024];
  sprintf(arrayName, "Variable_0");
  vtkSmartPointer<vtkDataArray> array = vtk_point_data->GetArray(arrayName);
  int c = array->GetNumberOfComponents();
  int n = array->GetNumberOfTuples();

  double* histData = (double*)malloc(sizeof(double)*c);
  shared_ary<Histogram> histAry(new Histogram[n], n);
  for (int nn = 0; nn < n; nn++){
          array->GetTuple(nn, histData);
          histAry[nn] = Histogram(histData);
  }
  free(histData);
  return new DistrArray<Histogram>(histAry);
}
コード例 #9
0
bool LocalErrorHistogramManager::buildHistograms(int numBins) {
    LINFO("Build histograms with " << numBins << " bins each");
    _numBins = numBins;

    _file = &(_tsp->file());
    if (!_file->is_open()) {
        return false;
    }
    _minBin = 0.0; // Should be calculated from tsp file
    _maxBin = 1.0; // Should be calculated from tsp file as (maxValue - minValue)

    unsigned int numOtLevels = _tsp->numOTLevels();
    unsigned int numOtLeaves = pow(8, numOtLevels - 1);
    unsigned int numBstLeaves = pow(2, _tsp->numBSTLevels() - 1);

    _numInnerNodes = _tsp->numTotalNodes() - numOtLeaves * numBstLeaves;

    _spatialHistograms = std::vector<Histogram>(_numInnerNodes);
    _temporalHistograms = std::vector<Histogram>(_numInnerNodes);
    for (unsigned int i = 0; i < _numInnerNodes; i++) {
        _spatialHistograms[i] = Histogram(_minBin, _maxBin, numBins);
        _temporalHistograms[i] = Histogram(_minBin, _maxBin, numBins);
    }

    // All TSP Leaves
    int numOtNodes = _tsp->numOTNodes();
    int otOffset = (pow(8, numOtLevels - 1) - 1) / 7;

    int numBstNodes = _tsp->numBSTNodes();
    int bstOffset = numBstNodes / 2;

    int numberOfLeaves = numOtLeaves * numBstLeaves;

    LINFO("Building spatial histograms");
    ProgressBar pb1(numberOfLeaves);
    int processedLeaves = 0;
    pb1.print(processedLeaves);
    bool success = true;
    for (int bst = bstOffset; bst < numBstNodes; bst++) {
        for (int ot = otOffset; ot < numOtNodes; ot++) {
            success &= buildFromOctreeChild(bst, ot);
            if (!success) LERROR("Failed in buildFromOctreeChild");
            if (!success) return false;
            pb1.print(processedLeaves++);
        }
    }
    //pb1.stop();


    LINFO("Building temporal histograms");
    ProgressBar pb2(numberOfLeaves);
    processedLeaves = 0;
    pb2.print(processedLeaves);
    for (int ot = otOffset; ot < numOtNodes; ot++) {
        for (int bst = bstOffset; bst < numBstNodes; bst++) {
            success &= buildFromBstChild(bst, ot);
            if (!success) LERROR("Failed in buildFromBstChild");
            if (!success) return false;
            pb2.print(processedLeaves++);
        }
    }
    //pb2.stop();

    return success;
}
コード例 #10
0
ファイル: tryrand1.cpp プロジェクト: RuiVarela/Smokin
void test1(int n)
{
   Normal nn;
   Uniform uniform;
   cout <<
     "Print 20 N(0,1) random numbers - should be the same as in sample output" <<
     endl;
   {
      Format F; F.FormatType(Format::DEC_FIGS); F.Precision(12); F.Width(15);
      for (int i=0; i<20; i++) cout << F << nn.Next() << endl;
   }
   cout << endl;

   cout << "Print histograms of data from a variety distributions" << endl;
   cout << "Histograms should be close to those in sample output" << endl;
   cout << "s. mean and s. var should be close to p. mean and s. mean" << endl << endl;

   { Constant c(5.0);                         Histogram(&c, n); }
   { Uniform u;                               Histogram(&u, n); }
   { SumRandom sr=uniform(3)-1.5;             Histogram(&sr, n); }
   { SumRandom sr=uniform-uniform;            Histogram(&sr, n); }
   { Normal normal;                           Histogram(&normal, n); }
   { Cauchy cauchy;                           Histogram(&cauchy, n); }
   { AsymGenX normal10(NORMAL10, 10.0);       Histogram(&normal10, n); }
   cout << "Mean and variance should be 10.0 and 4.0" << endl;
   { AsymGenX uniform2(UNIF,0.5);             Histogram(&uniform2, n); }
   cout << "Mean and variance should be 0.5 and 0.083333" << endl;
   { SymGenX triang(TRIANG);                  Histogram(&triang, n); }
   cout << "Mean and variance should be 0 and 0.16667" << endl;
   { Poisson p(0.25);                         Histogram(&p, n); }
   { Poisson p(10.0);                         Histogram(&p, n); }
   { Poisson p(16.0);                         Histogram(&p, n); }
   { Binomial b(18,0.3);                      Histogram(&b, n); }
   { Binomial b(19,0.3);                      Histogram(&b, n); }
   { Binomial b(20,0.3);                      Histogram(&b, n); }
   { Binomial b(58,0.3);                      Histogram(&b, n); }
   { Binomial b(59,0.3);                      Histogram(&b, n); }
   { Binomial b(60,0.3);                      Histogram(&b, n); }
   { Binomial b(18,0.05);                     Histogram(&b, n); }
   { Binomial b(19,0.05);                     Histogram(&b, n); }
   { Binomial b(20,0.05);                     Histogram(&b, n); }
   { Binomial b(98,0.01);                     Histogram(&b, n); }
   { Binomial b(99,0.01);                     Histogram(&b, n); }
   { Binomial b(100,0.01);                    Histogram(&b, n); }
   { Binomial b(18,0.95);                     Histogram(&b, n); }
   { Binomial b(19,0.95);                     Histogram(&b, n); }
   { Binomial b(20,0.95);                     Histogram(&b, n); }
   { Binomial b(98,0.99);                     Histogram(&b, n); }
   { Binomial b(99,0.99);                     Histogram(&b, n); }
   { Binomial b(100,0.99);                    Histogram(&b, n); }
   { NegativeBinomial nb(100,6.0);            Histogram(&nb, n); }
   { NegativeBinomial nb(11,9.0);             Histogram(&nb, n); }
   { NegativeBinomial nb(11,1.9);             Histogram(&nb, n); }
   { NegativeBinomial nb(11,0.10);            Histogram(&nb, n); }
   { NegativeBinomial nb(1.5,1.9);            Histogram(&nb, n); }
   { NegativeBinomial nb(1.0,1.9);            Histogram(&nb, n); }
   { NegativeBinomial nb(0.3,19);             Histogram(&nb, n); }
   { NegativeBinomial nb(0.3,1.9);            Histogram(&nb, n); }
   { NegativeBinomial nb(0.3,0.05);           Histogram(&nb, n); }
   { NegativeBinomial nb(100.8,0.18);         Histogram(&nb, n); }
   { ChiSq c(1,2.0);                          Histogram(&c, n); }
   { ChiSq c(2,2.0);                          Histogram(&c, n); }
   { ChiSq c(3,2.0);                          Histogram(&c, n); }
   { ChiSq c(4,2.0);                          Histogram(&c, n); }
   { ChiSq c(1    );                          Histogram(&c, n); }
   { ChiSq c(2    );                          Histogram(&c, n); }
   { ChiSq c(3    );                          Histogram(&c, n); }
   { ChiSq c(4    );                          Histogram(&c, n); }
   { Gamma g1(1.0);                           Histogram(&g1, n); }
   { Gamma g2(0.5);                           Histogram(&g2, n); }
   { Gamma g3(1.01);                          Histogram(&g3, n); }
   { Gamma g4(2.0);                           Histogram(&g4, n); }
   { Pareto p1(0.5);                          Histogram(&p1, n); }
   { Pareto p2(1.5);                          Histogram(&p2, n); }
   { Pareto p3(2.5);                          Histogram(&p3, n); }
   { Pareto p4(4.5);                          Histogram(&p4, n); }
   Real probs[]={.1,.3,.05,.11,.05,.04,.05,.05,.1,.15};
   Real val[]={2,3,4,6,8,12,16,24,32,48};
   { DiscreteGen discrete(10,probs);          Histogram(&discrete, n); }
   { DiscreteGen discrete(10,probs,val);      Histogram(&discrete, n); }
}
コード例 #11
0
void RenderEngine3D::Draw( int width, int height ){
    if(pmesh == 0 || tdata == 0) return;

    proj.Set( proj.GetHFOV(), width, height, proj.GetHither(), proj.GetYon() );

    if( need_view_update ){
        UpdateView();
    }

    if( cluster->isRunning() ){
        colormap->resize(pdata->GetVoxelCount());
        for(int i = 0; i < pdata->GetVoxelCount(); i++){
            colormap->at(i) = cat_cmap->GetColor( cluster->GetClusterID(i) ).UIntColor();
        }
        parallel_coordinates->Reset();
    }

    glViewport( 0,0,width,height );

    glMatrixMode( GL_PROJECTION );
    glLoadIdentity();
    glMultMatrixf( proj.GetMatrix().data );

    glMatrixMode( GL_MODELVIEW );
    glLoadIdentity();
    glMultMatrixf( pView->GetView().data );

    if( useClipX){ glEnable( GL_CLIP_PLANE0 ); glClipPlane( GL_CLIP_PLANE0, clpX ); }
    if( useClipY){ glEnable( GL_CLIP_PLANE1 ); glClipPlane( GL_CLIP_PLANE1, clpY ); }
    if( useClipZ){ glEnable( GL_CLIP_PLANE2 ); glClipPlane( GL_CLIP_PLANE2, clpZ ); }

    glMultMatrixf( tform.data );


    glLineWidth(1.0f);


    if(draw_mode == 0){
        glEnable(GL_DEPTH_TEST);
            glPointSize(3.0f);
            if( pdata == 0 ){
                pmesh->Draw( SCI::Vex4(1.0f, 0.95f, 1.0f, 1.0f ) );
            }
            else{
                pmesh->Draw( *colormap );
            }
            //glPointSize(4.0f);
            //pmesh->Draw( SCI::Vex4(0,0,0,1) );
        glDisable(GL_DEPTH_TEST);
    }

    /*
    if(draw_mode == 4){
        glLineWidth(4.0f);
        glDisable(GL_DEPTH_TEST);
        glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
        glEnable( GL_BLEND );
            edge_mesh->Draw( edge_mesh_ro, *pmesh, *colormap );
        glDisable( GL_BLEND );
    }
    */




    if( draw_mode == 2 ){
        glDisable(GL_DEPTH_TEST);
        glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
        glEnable( GL_BLEND );
            iso_tris->Draw( iso_tris_ro, *iso_points, *iso_color );
        glDisable( GL_BLEND );
    }

    if( draw_mode == 3 ){
        glDisable(GL_DEPTH_TEST);
        glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
        glEnable( GL_BLEND );
            df_tris->Draw( df_tris_ro, *df_points, *df_color );
        glDisable( GL_BLEND );
    }

    glDisable(GL_DEPTH_TEST);
    glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
    glEnable( GL_BLEND );
        RecalculateSil();
        tdata->tri_mesh.Draw( tri_mesh_ro, *pmesh, sil_color );
        for(int i = 0; i < addl_sil_mesh.size(); i++){
            addl_solid[i]->tri_mesh.Draw( *(addl_mesh_ro[i]), *(addl_points[i]), *(addl_sil_color[i]) );
        }
    glDisable( GL_BLEND );



    /*
    if( view_fibers ){
        glEnable( GL_DEPTH_TEST );

        glColorMask( GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE );
            glDepthRange(0.10f,1.0f);
                tdata->tri_mesh.Draw( tri_mesh_ro, *pmesh, SCI::Vex4(0,0,0,0) );
            glDepthRange(0.0f,1.0f);
        glColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE );

        glLineWidth( 3.0f );
        glColor3f(0,0,0);
        glBegin(GL_LINES);
        if(fdata){
            for(int i = 0; i < (int)tdata->tri_mesh.size(); i++){
                Data::Mesh::Triangle t = tdata->tri_mesh.at(i);
                int j = t.v0;
                SCI::Vex3 p0 = pmesh->points[j];
                SCI::Vex3 d  = fdata->fibs[j];
                SCI::Vex3 p1 = p0 + d * fiber_length;

                glVertex3fv( p0.data );
                glVertex3fv( p1.data );
            }
        }
        glEnd();

    }
    */


    glDisable( GL_CLIP_PLANE0 );
    glDisable( GL_CLIP_PLANE1 );
    glDisable( GL_CLIP_PLANE2 );


    /*
    glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
    glEnable(GL_DEPTH_TEST);
    glLineWidth(5.0f);
    float max_dim = pmesh->bb.GetMaximumDimensionSize()/2.0f*1.05f;
    SCI::Vex3 cen = pmesh->bb.GetCenter();
    for(int pass = 0; pass <= 1; pass++){
        for(int i = 0; i < 3; i++){
            if( pln[i] == 0 ) continue;
            if(pass == 0) glEnable( GL_BLEND );
            if(pass == 1) glDisable( GL_BLEND );
            if(pass == 0) glBegin(GL_QUADS);
            if(pass == 1) glBegin(GL_LINE_LOOP);
            glColor4f(pln_color[i]->x,pln_color[i]->y,pln_color[i]->z,0.4f);
            if( pln[i]->x != 0 ){
                glVertex3f(-pln[i]->w,cen.y-max_dim,cen.z-max_dim);
                glVertex3f(-pln[i]->w,cen.y-max_dim,cen.z+max_dim);
                glVertex3f(-pln[i]->w,cen.y+max_dim,cen.z+max_dim);
                glVertex3f(-pln[i]->w,cen.y+max_dim,cen.z-max_dim);
            }
            if( pln[i]->y != 0 ){
                glVertex3f(cen.x-max_dim,-pln[i]->w,cen.z-max_dim);
                glVertex3f(cen.x-max_dim,-pln[i]->w,cen.z+max_dim);
                glVertex3f(cen.x+max_dim,-pln[i]->w,cen.z+max_dim);
                glVertex3f(cen.x+max_dim,-pln[i]->w,cen.z-max_dim);
            }
            if( pln[i]->z != 0 ){
                glVertex3f(cen.x-max_dim,cen.y-max_dim,-pln[i]->w);
                glVertex3f(cen.x-max_dim,cen.y+max_dim,-pln[i]->w);
                glVertex3f(cen.x+max_dim,cen.y+max_dim,-pln[i]->w);
                glVertex3f(cen.x+max_dim,cen.y-max_dim,-pln[i]->w);
            }
            glEnd();
        }
    }
    glDisable(GL_DEPTH_TEST);
    glDisable( GL_BLEND );
    */

    glLineWidth(1.0f);

    // Now othrographic mode drawing
    glMatrixMode( GL_PROJECTION );
    glLoadIdentity();

    glMatrixMode( GL_MODELVIEW );
    glLoadIdentity();

    if(color_mode != 3){
        seq_cmap->Draw( 0.8f, 0.875f, 0.15f, 0.9f, (float)width/(float)height, font );
    }

    if(color_mode == 3){

        float vmin =  FLT_MAX;
        float vmax = -FLT_MAX;
        for(int i = 0; i < cluster->GetClusterCount(); i++){
            std::vector<float> clstr = cluster->GetCluster(i);
            for(int j = 0; j < (int)clstr.size(); j++){
                vmin = SCI::Min(vmin,clstr[j]);
                vmax = SCI::Max(vmax,clstr[j]);
            }
        }
        vmax = (vmax-vmin)*1.1f+vmin;

        std::vector<Histogram> histograms;

        for(int i = 0; i < cluster->GetClusterCount(); i++){
            std::vector<float> clstr = cluster->GetCluster(i);
            histograms.push_back( Histogram() );
            histograms.back().Reinitialize( 10, vmin, vmax );
            histograms.back().SetColor( cat_cmap->GetColor( i ).xyz() );
            //histograms.back().ClearBins();
            for(int j = 0; j < (int)clstr.size(); j++){
                histograms.back().AddValue( clstr[j] );
            }

        }

        std::sort( histograms.begin(), histograms.end() );

        for(int i = 0; i < (int)histograms.size(); i++){
            float u0 = 0.8f;
            float u1 = 1.0f;
            float v0 = 2.0f * (float)(i+0)/(float)histograms.size() - 1.0f;
            float v1 = 2.0f * (float)(i+1)/(float)histograms.size() - 1.0f;

            if(cluster_histogram){
                histograms[i].Draw( u0, v0, u1, v1, pdata->GetDim(), ((i==0)?font:0), (float)width/(float)height );
            }
            else{
                histograms[i].DrawValues( u0, v0, u1, v1 );
            }

        }
    }

}
コード例 #12
0
ファイル: histogram.cpp プロジェクト: nikky4D/xform_recipes
Histogram histogram_of_gradients(Image<float> &input, int nbins, int skip) {
    Image<float> h_hist(nbins+2);
    hl_histogram_of_gradients(input, nbins, h_hist);
    return Histogram(h_hist);
}
コード例 #13
0
ファイル: histogram.cpp プロジェクト: nikky4D/xform_recipes
// Compute histogram from a single channel float image
Histogram histogram(Image<float> &input, int nbins, int skip) {
    Image<float> h_hist(nbins+2); // 2 floats for mini and max at beginning
    hl_histogram(input, nbins,skip, h_hist);
    Histogram h = Histogram(h_hist);
    return h;
}
コード例 #14
0
ファイル: DdcTst.cpp プロジェクト: mfkiwl/BREC
int
main( int argc, char *argv[] )
{
    int            idx;	  
    Ddc100        *ddc;
    int            val;
    char          *end;
    short          bf[4096];

    ddc = NULL;

    idx = 1;
    while( idx < argc ){

        if( 0==strcmp(argv[idx], "-help") ){
            usage(0);
        }

        else if( 0==strcmp(argv[idx], "-h") ){
            usage(0);
        }

        else if( 0==strcmp(argv[idx], "-echo") ){
            if( (idx+1) >= argc ){ usage(-1); }
            printf("%s\n",argv[idx+1]);
        } 

        else if( 0==strcmp(argv[idx], "-open") ){
            ddc = new Ddc100();
            ddc->Open();
            ddc->StartPrus();
            ddc->SetComplexSampleRate( 5000000 );
        }		 

        else if( 0==strcmp(argv[idx], "-usleep") ){
            if( (idx+1) >= argc ){ usage(-1); }
            val = strtol(argv[idx+1],&end,0);
            us_sleep( val );
        } 

        else if( 0==strcmp(argv[idx], "-write") ){
            int rval; 
            if( (idx+1) >= argc ){ usage(-1); }
            val = strtol( argv[idx+1], &end, 0 );

            rval = ddc->SpiRW16( val );
            printf("DdcTst:w=0x%04hx r=0x%04hx (%hd)\n",val,rval,rval);
        }
    
        else if( 0==strcmp(argv[idx], "-samp") ){
            ddc->Get2kSamples( bf );
            Show2kIQ(bf,'x');
        }

        else if( 0==strcmp(argv[idx], "-csv") ){
            Show2kIQ(bf,'D');
        }

        else if( 0==strcmp(argv[idx], "-flush") ){
            ddc->FlushSamples();
        }

        else if( 0==strcmp(argv[idx], "-pru") ){
            ddc->Show( "DdcTst: pru state" );
        }

        else if( 0==strcmp(argv[idx], "-iqp") ){
            IqpTest( ddc );
        }

        else if( 0==strcmp(argv[idx], "-iqp2") ){
            IqpTest2( ddc );
        }

        else if( 0==strcmp(argv[idx], "-quad") ){
            QuadTest(ddc);
        }

        else if( 0==strcmp(argv[idx], "-filter-scan-wide") ){
            FilterScanTest(ddc,1);
        }

        else if( 0==strcmp(argv[idx], "-filter-scan-narrow") ){
            FilterScanTest(ddc,0);
        }
 
        ////////////////////////////////////////////////
        // the following tests need to be revisited ...

        else if( 0==strcmp(argv[idx], "-histo") ){
            Histogram(ddc);
        }

        else if( 0==strcmp(argv[idx], "-ntest") ){
            short bf[4096];
            short lastGood;
            int   idx, ns,goodCount;

            goodCount = 0;
            lastGood  = 0;
            ns = 0;
            while( 1 ){
                ddc->FlushSamples();
                ddc->Get2kSamples( bf );
                for(idx=0;idx<2048;idx++){
                   if( (bf[idx] > 2080) || (bf[idx]<2020) ){
                   // if( (bf[idx] > 2200) || (bf[idx]<1700) ){
                       printf("%d  %hd 0x%x (lg=%hd) gc=%d\n",
                               ns,bf[idx],bf[idx],lastGood,goodCount);
                       goodCount = 0;
                   }
                   else{
                       lastGood = bf[idx];
                       goodCount++;
                   }
                   ns++;
                }
            }
        }

        // Move to next argument for parsing
        idx++;
    }

}
コード例 #15
0
ファイル: testHistogram.cpp プロジェクト: Beep6581/hdrmerge
BOOST_FIXTURE_TEST_CASE(Histogram_ctr, HistogramFixture) {
    h = Histogram(values, values + 14);
}
コード例 #16
0
ファイル: sparse_matrix_impl.hpp プロジェクト: beckgom/smallk
inline
void SparseMatrix<T>::Compress()
{
    if (0 == size_)
        throw std::runtime_error("SparseMatrix::Compress: matrix has no data");

    // Check the columns to see if they are already sorted in nondecreasing
    // order.  If not, sort the column indices and reorder the rows and 
    // data arrays to match.

    bool sorted = true;
    if (size_ >= 2)
    {
        for (unsigned int i=0; i != (size_ - 1); ++i)
        {
            if (col_offsets_[i] > col_offsets_[i+1])
            {
                sorted = false;
                break;
            }
        }
    }        

    // Whether the column data is sorted or not, bin the column indices,
    // and compute a prefix sum of the binned data to generate the compressed
    // column representation of the column indices.

    // copy the column indices
    std::vector<unsigned int> col_temp(col_offsets_);
    std::vector<unsigned int> counts(width_);

    // size_ elements have been loaded
    Histogram(col_offsets_.begin(), col_offsets_.begin() + size_, 
              counts.begin(), counts.end());
    PrefixSum(counts.begin(), counts.end());
    std::copy(counts.begin(), counts.end(), col_offsets_.begin()+1);
    col_offsets_[0] = 0;

    if (!sorted)
    {
        unsigned int offset_a, offset_b, row_index, c;

        // need temp copies of the row and data arrays
        std::vector<unsigned int> row_temp (row_indices_);
        std::vector<T>            data_temp(data_);

        for (unsigned int k=1; k <= size_; ++k)
        {
            // offset into the unsorted arrays
            offset_a = size_ - k;

            // the row index of the nonzero element at this offset
            row_index = row_temp[offset_a];
            
            // the column index of this element
            c = col_temp[offset_a];
            assert(c <= (width_));

            // destination offset + 1
            offset_b = counts[c];
            if (0 == offset_b)
                continue;

            row_indices_[offset_b-1] = row_index;
            data_[offset_b-1]        = data_temp[offset_a];
                
            // one fewer element in the source array <= row_index
            counts[c] -= 1;
        }
    }

    // set the size
    col_offsets_[width_] = size_;

    // May still have duplicates - need to find duplicates and sum. TBD
}