Exemple #1
0
 inline UL& get_spiral( UL x )
 {
     UL all = 0;
     UL be = 0;
     if( x > size_max() ) std::cout << "INFINITE LOOP WARNING" << std::endl;
     while( true )
     {
         UL db = ( all%2 ? size_x() : size_y() ) - 1 - be*2;
         //std::cout << x << " " << db << std::endl;
         if( x < db )
         {
             switch( all )
             {
             case 0 : return (*this)[be][be + x];
             case 1 : return (*this)[be+x][size_y()-be-1];
             case 2 : return (*this)[size_x()-be-1][size_y()-be-1-x];
             case 3 : return (*this)[size_x()-be-1-x][be];
             }
         }
         else
         {
             x-=db;
             if(++all == 4)
             {
                 all = 0;
                 ++be;
             }
         }
     }
 }
Exemple #2
0
 inline UL& get_rev_diag( UL x )
 {
     if( x <size_max()/2 )
     {
         PUL ind = tri_ind(x , size_x() , size_y() );
         return get_x_y( ind.first , size_y() - ind.second - 1 );
     }
     else
     {
         UL xm = size_max() - x -1;
         PUL ind = tri_ind(xm , size_x() , size_y() );
         return get_x_y( size_x() - ind.first - 1 , ind.second );
     }
 }
Exemple #3
0
    inline void csere( UL f , UL s , T fun )
    {
        ++count;

        UL& firref = (this->*fun)(f);
        UL& secref = (this->*fun)(s);

        std::swap( firref, secref );

        for( UL i = 0 ; i < size_x() ; ++i )
        {
            for( UL j = 0 ; j < size_y() ; ++j )
            {
                if( &this->get_x_y(i,j) == &firref )
                {
                    ss << i << " " << j << " ";
                }
                if( &this->get_x_y(i,j) == &secref )
                {
                    ss << i << " " << j << " ";
                }
            }
        }
        ss << std::endl;
    }
Exemple #4
0
void
region::set_offset( int ox, int oy )
{
	if ( empty() )
	{
		myL = ox;
		myB = oy;
		myR = ox - 1;
		myT = oy - 1;
	}
	else
	{
		if ( infinite_x() )
		{
			myL = ox;
		}
		else
		{
			value_type s = size_x();
			myL = ox;
			myR = ox + s - 1;
		}

		if ( infinite_y() )
		{
			myB = oy;
		}
		else
		{
			value_type s = size_y();
			myB = oy;
			myT = oy + s - 1;
		}
	}
}
Exemple #5
0
	bool logical_world::is_xedge(int x) const
	{
		if(x >= 0 && x < size_x()) {
			return false;
		}
		return true;
	}
Exemple #6
0
    inline UL& get_double_spiral( UL x )
    {

        UL all = 0;
        UL be = 0;
        if( size_max() % 2 )
        {
            if( size_max()/2 == x ) return get_x_y( size_x()/2 , size_y()/2 );
        }
        bool v = x < size_max()/2;
        if( !v ) x = size_max() - x - 1;

        PUL p;
        while( true )
        {
            UL db = ( all%2 ? size_x() : size_y() ) - 1 - be*2 + !!be;

            if( x <= db )
            {
                switch( all )
                {
                case 0 : p = PUL{be,(be? be-1:0) + x}; break;
                case 1 : p = PUL{be-1+x,size_y()-be}; break;
                case 2 : p = PUL{size_x()-be-1,size_y()-be-x}; break;
                case 3 : p = PUL{size_x()-be-x,be-1}; break;
                }
                break;
            }
            else
            {
                x-=db;
                if(++all == 4)
                {
                    all = 0;
                }
                if( all%2 )
                {
                    ++be;
                }
            }
        }
        if( v ) return get_x_y(p);
        else return get_x_y( size_x() - 1 - p.first , size_y() - 1 - p.second );
    }
Exemple #7
0
/// Error-checking pixel access.  Aborts if x,y, or band are out of bounds.
asf::parameter_float_image::band_t &asf::parameter_float_image::at_careful(int x,int y,int band) const
{
	if (!pixels().inbounds(x,y)) {
		char buf[1024];
		sprintf(buf,"at_careful pixel access: pixel (%d,%d) is not in-bounds on a %d x %d pixel image",
			x,y,size_x(),size_y());
		die(buf);
	}
	if (band<0) die("at_careful pixel access: Bogus negative band number");
	if (band>=bands()) die("at_careful pixel access: Bogus too-big band number");
	return data[x*xd+y*yd+band];
}
Exemple #8
0
/**
 * @brief Calculate maximum motion across all the frames
 */
void OpticalFlowModule::update_max_motion()
{
	if (_max_motion > 0.0f) {
		return;
	}

	for (auto it = _forward_optical_flow_list.begin(); it != _forward_optical_flow_list.end(); ++it) {
		const float *flow_data = it->raw();
		for (uint i = 0; i < it->size_x() * it->size_y(); i++) {
			float len = flow_data[2 * i] * flow_data[2 * i] + flow_data[2 * i + 1] * flow_data[2 * i + 1];
			_max_motion = std::max(_max_motion, len);
		}
	}

	for (auto it = _backward_optical_flow_list.begin(); it != _backward_optical_flow_list.end(); ++it) {
		const float *flow_data = it->raw();
		for (uint i = 0; i < it->size_x() * it->size_y(); i++) {
			float len = flow_data[2 * i] * flow_data[2 * i] + flow_data[2 * i + 1] * flow_data[2 * i + 1];
			_max_motion = std::max(_max_motion, len);
		}
	}

	_max_motion = std::sqrt(_max_motion);
}
Exemple #9
0
 inline UL& get_y( UL y )
 {
     return (*this)[y%size_x()][y/size_x()];
 }
Exemple #10
0
 inline UL size_max() const { return size_x() * size_y(); }