meanShiftFiltering_GPU output parameters changed to CV_8UC4. This is a start for moving from 3 channel to C4 images within GPU module.

This commit is contained in:
Kirill Kornyakov
2010-09-03 14:32:12 +00:00
parent 2154a0ce63
commit ec7e937481
5 changed files with 137 additions and 103 deletions

View File

@@ -163,7 +163,8 @@ namespace imgproc
{
texture<uchar4, 2> tex_meanshift;
extern "C" __global__ void meanshift_kernel( unsigned char* out, int out_step, int cols, int rows, int sp, int sr, int maxIter, float eps )
extern "C" __global__ void meanshift_kernel( unsigned char* out, int out_step, int cols, int rows,
int sp, int sr, int maxIter, float eps )
{
int x0 = blockIdx.x * blockDim.x + threadIdx.x;
int y0 = blockIdx.y * blockDim.y + threadIdx.y;
@@ -224,10 +225,8 @@ namespace imgproc
break;
}
int base = (blockIdx.y * blockDim.y + threadIdx.y) * out_step + (blockIdx.x * blockDim.x + threadIdx.x) * 3 * sizeof(uchar);
out[base+0] = c.x;
out[base+1] = c.y;
out[base+2] = c.z;
int base = (blockIdx.y * blockDim.y + threadIdx.y) * out_step + (blockIdx.x * blockDim.x + threadIdx.x) * 4 * sizeof(uchar);
*(uchar4*)(out + base) = c;
}
}
}
@@ -236,7 +235,7 @@ namespace cv { namespace gpu { namespace impl
{
extern "C" void meanShiftFiltering_gpu(const DevMem2D& src, DevMem2D dst, int sp, int sr, int maxIter, float eps)
{
dim3 grid(1, 1, 1);
dim3 grid(1, 1, 1);
dim3 threads(32, 16, 1);
grid.x = divUp(src.cols, threads.x);
grid.y = divUp(src.rows, threads.y);

View File

@@ -119,18 +119,18 @@ void cv::gpu::meanShiftFiltering_GPU(const GpuMat& src, GpuMat& dst, int sp, int
if( src.depth() != CV_8U || src.channels() != 4 )
CV_Error( CV_StsUnsupportedFormat, "Only 8-bit, 4-channel images are supported" );
dst.create( src.size(), CV_8UC3 );
dst.create( src.size(), CV_8UC4 );
float eps;
if( !(criteria.type & TermCriteria::MAX_ITER) )
criteria.maxCount = 5;
int maxIter = std::min(std::max(criteria.maxCount, 1), 100);
float eps;
if( !(criteria.type & TermCriteria::EPS) )
eps = 1.f;
eps = (float)std::max(criteria.epsilon, 0.0);
impl::meanShiftFiltering_gpu(src, dst, sp, sr, maxIter, eps);
}