Exemple #1
0
cube Utils::erode(cube body, cube kernel)
{
	int minx, miny, minz, maxx, maxy, maxz;
	Utils::bounds(body, minx, miny, minz, maxx, maxy, maxz);
	cube result = cube(body);
	int size_x = kernel.n_cols / 2;
	int size_y = kernel.n_rows / 2;
	int size_z = kernel.n_slices / 2;
	maxx -= kernel.n_cols;
	maxy -= kernel.n_rows;
	maxz -= kernel.n_slices;
	for (int i = minx; i <= maxx; i++)
	{
		for (int j = miny; j <= maxy; j++)
		{
			for (int k = minz; k <= maxz; k++)
			{
				cube subcube = body.subcube(j, i, k, size(kernel));
				subcube -= kernel;
				result(j + size_y, i + size_x, k + size_z) = subcube.min() < 0 ? 0 : 1;
			}
		}
	}
	return result;
}
Exemple #2
0
inline unique_cube<T> crop_right( const cube<T>& in, const vec3s& s )
{
    auto r = pool<T>::get_unique(s);
    vec3s b = size(in) - s;
    *r = in.subcube(b[0], b[1], b[2], b[0]+s[0]-1, b[1]+s[1]-1, b[2]+s[2]-1);
    return r;
}
Exemple #3
0
 static unique_cube<T> get_unique_crop( const cube<T>& c, const vec3s& s )
 {
     unique_cube<T> ret = get_unique(s);
     *ret = c.subcube(0,0,0,s[0]-1,s[1]-1,s[2]-1);
     return ret;
 }
Exemple #4
0
inline unique_cube<T> crop(cube<T>& c, const vec3s& s)
{
    unique_cube<T> ret = pool<T>::get_unique(s);
    *ret = c.subcube(0,0,0,s[0]-1,s[1]-1,s[2]-1);
    return ret;
}