Ejemplo n.º 1
0
ACwithoutEdges::ACwithoutEdges(const unsigned char* img_data1, int img_width1, int img_height1) :
    ActiveContour(img_data1, img_width1, img_height1,
                  true, 0.65, 0.65, 0.0, 0.0,
                  true, 5, 2.0, 30, 3),
    lambda_out(1), lambda_in(1)
{
    initialize_sums();
    calculate_means();
}
Ejemplo n.º 2
0
void ACwithoutEdges::initialize_for_each_frame()
{
    ActiveContour::initialize_for_each_frame();

    initialize_sums();
    calculate_means();

    return;
}
Ejemplo n.º 3
0
ACwithoutEdges::ACwithoutEdges(const unsigned char* img_data1, int img_width1, int img_height1,
                               const char* phi_init1,
                               bool hasCycle2_1, int kernel_length1, double sigma1, int Na1, int Ns1,
                               int lambda_out1, int lambda_in1) :
    ActiveContour(img_data1, img_width1, img_height1,
                  phi_init1,
                  hasCycle2_1, kernel_length1, sigma1, Na1, Ns1),
    lambda_out(lambda_out1), lambda_in(lambda_in1)
{
    initialize_sums();
    calculate_means();
}
RegionBasedActiveContourYUV::RegionBasedActiveContourYUV(const ofeli::Matrix<const unsigned char>& img_rgb1) :
    ActiveContour(img_rgb1.get_width(), img_rgb1.get_height(),
                  true, 0.65, 0.65, 0.0, 0.0,
                  true, 5, 2.0, 30, 3),
    img_rgb(img_rgb1),
    lambda_out(1), lambda_in(1), alpha(1), beta(10), gamma(10)
{
    if( !isValid_matrix(img_rgb1) )
    {
        std::cerr << std::endl <<
        "img_rgb1 is not valid."
        << std::endl;
    }

    initialize_sums();
    calculate_means();
}
void RegionBasedActiveContourYUV::initialize_for_each_frame()
{
    unsigned int it = get_iteration();

    ActiveContour::initialize_for_each_frame();

    // condition for video tracking :
    // If the active contour moves enough ( > 120 ), variables sums, n_in, n_out
    // are too different and are recalculated.
    // If the active contour does not evolve ( < 5 because a last cycle 2 is performed )
    // in the case of uniform images (or during the object initialization),
    // variables are (re)calculated for convergence.
    // Otherwise, variables are not calculated.
    if( it > 120 || it < 5 )
    {
        initialize_sums();
    }
    calculate_means();
}
RegionBasedActiveContourYUV::RegionBasedActiveContourYUV(const ofeli::Matrix<const unsigned char>& img_rgb1,
                                     bool hasEllipse1, double shape_width_ratio1, double shape_height_ratio1, double center_x_ratio1, double center_y_ratio1,
                                     bool hasCycle2_1, unsigned int kernel_length1, double sigma1, unsigned int Na1, unsigned int Ns1,
                                     int lambda_out1, int lambda_in1, int alpha1, int beta1, int gamma1) :
    ActiveContour(img_rgb1.get_width(), img_rgb1.get_height(),
                  hasEllipse1, shape_width_ratio1, shape_height_ratio1, center_x_ratio1, center_y_ratio1,
                  hasCycle2_1, kernel_length1, sigma1, Na1, Ns1),
    img_rgb(img_rgb1),
    lambda_out(check_value(lambda_out1)), lambda_in(check_value(lambda_in1)), alpha(check_value(alpha1)), beta(check_value(beta1)), gamma(check_value(gamma1))
{
    if( !isValid_matrix(img_rgb1) )
    {
        std::cerr << std::endl <<
        "img_rgb1 is not valid."
        << std::endl;
    }

    initialize_sums();
    calculate_means();
}
RegionBasedActiveContourYUV::RegionBasedActiveContourYUV(const ofeli::Matrix<const unsigned char>& img_rgb1,
                                     const ofeli::Matrix<const signed char>& phi_init1,
                                     bool hasCycle2_1, unsigned int kernel_length1, double sigma1, unsigned int Na1, unsigned int Ns1,
                                     int lambda_out1, int lambda_in1, int alpha1, int beta1, int gamma1) :
    ActiveContour(phi_init1,
                  hasCycle2_1, kernel_length1, sigma1, Na1, Ns1),
    img_rgb(img_rgb1),
    lambda_out(check_value(lambda_out1)), lambda_in(check_value(lambda_in1)), alpha(check_value(alpha1)), beta(check_value(beta1)), gamma(check_value(gamma1))
{
    if( !isValid_matrix(img_rgb1) )
    {
        std::cerr << std::endl <<
        "img_rgb1 is not valid."
        << std::endl;
    }
    if( !isValid_matrix(phi_init1) )
    {
        std::cerr << std::endl <<
        "phi_init1 is not valid."
        << std::endl;
    }

    if( phi_init1.get_width() != img_rgb1.get_width() )
    {
        std::cerr << std::endl <<
        "Precondition, phi_init1 must have the same width of the input image img_rgb1."
        << std::endl;
    }
    if( phi_init1.get_height() != img_rgb1.get_height() )
    {
        std::cerr << std::endl <<
        "Precondition, phi_init1 must have the same height of the input image img_rgb1."
        << std::endl;
    }

    initialize_sums();
    calculate_means();
}