コード例 #1
0
GCoptimization::EnergyType Expansion::start_expansion(int max_num_iterations )
{

    int curr_cycle = 1;
    EnergyType new_energy,old_energy;


    new_energy = dataEnergy()+smoothnessEnergy();


    //old_energy = new_energy+1; // this doesn't work for large float energies
    old_energy = -1;

    std::cerr<<"starting expansion iteration"<<std::endl;
    while ( old_energy < 0 || (old_energy > new_energy  && curr_cycle <= max_num_iterations))
    {
        old_energy = new_energy;
        new_energy = oneExpansionIteration();
        std::cerr<<old_energy<<"->"<<new_energy<<std::endl;
        curr_cycle++;
    }

    //printf(" Exp energy %d",new_energy);
    return(new_energy);
}
コード例 #2
0
GCoptimization::EnergyType Swap::alpha_beta_swap(LabelType alpha_label, LabelType beta_label)
{
    terminateOnError( alpha_label < 0 || alpha_label >= m_nLabels || beta_label < 0 || beta_label >= m_nLabels,
                      "Illegal Label to Expand On");
    perform_alpha_beta_swap(alpha_label,beta_label);
    return(dataEnergy()+smoothnessEnergy());
}
コード例 #3
0
ファイル: GCoptimization.cpp プロジェクト: clusty/vision
GCoptimization::EnergyType Expansion::alpha_expansion(LabelType label)
{
    terminateOnError( label < 0 || label >= m_nLabels,"Illegal Label to Expand On");

    perform_alpha_expansion(label);
    return(dataEnergy()+smoothnessEnergy());
}
コード例 #4
0
GCoptimization::EnergyType Swap::oneSwapIteration()
{
    int next,next1;

    if (m_random_label_order) scramble_label_table();


    for (next = 0;  next < m_nLabels;  next++ )
        for (next1 = m_nLabels - 1;  next1 >= 0;  next1-- )
            if ( m_labelTable[next] < m_labelTable[next1] )
            {
                perform_alpha_beta_swap(m_labelTable[next],m_labelTable[next1]);
            }

    return(dataEnergy()+smoothnessEnergy());
}
コード例 #5
0
GCoptimization::EnergyType Expansion::oneExpansionIteration()
{
    int next;

    terminateOnError( m_dataType == NONE,"You have to set up the data cost before running optimization");
    terminateOnError( m_smoothType == NONE,"You have to set up the smoothness cost before running optimization");

    if (m_random_label_order) scramble_label_table();


    for (next = 0;  next < m_nLabels;  next++ )
        perform_alpha_expansion(m_labelTable[next]);


    return(dataEnergy()+smoothnessEnergy());
}
コード例 #6
0
GCoptimization::EnergyType Swap::start_swap(int max_num_iterations )
{

    int curr_cycle = 1;
    EnergyType new_energy,old_energy;


    new_energy = dataEnergy()+smoothnessEnergy();

    //old_energy = new_energy+1; // this doesn't work for large float energies
    old_energy = -1;

    while (old_energy < 0 || (old_energy > new_energy  && curr_cycle <= max_num_iterations))
    {
        old_energy = new_energy;
        new_energy = oneSwapIteration();

        curr_cycle++;
    }
    //printf(" swap energy %d",new_energy);
    return(new_energy);
}