Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Resizing an image and applying a Gaussian blur

Hello, This seems a bit trivial, but I'm not sure as to why execution isn't working how I'm expecting it to. I want to resize an image and then apply the Gaussian blur to that image, but only one is being done; whichever comes last.

Am I losing the data from the first operation as it goes to the second?

And how could I also do this is parallel with multiple GPUs if I wanted to use streams? If that's at all possible.

All help is appreciated Thank you!

Resizing an image and applying a Gaussian blur

Hello, This seems a bit trivial, but I'm not sure as to why execution isn't working how I'm expecting it to. I want to resize an image and then apply the Gaussian blur to that image, but only one is being done; whichever comes last.

Am I losing the data from the first operation as it goes to the second?

And how could I also do this is parallel with multiple GPUs if I wanted to use streams? If that's at all possible.

All help is appreciated Thank you!

Edit: My code is also attached.C:\fakepath\resizefilter.png

click to hide/show revision 3
None

updated 2018-03-27 23:07:13 -0600

berak gravatar image

Resizing an image and applying a Gaussian blur

Hello, This seems a bit trivial, but I'm not sure as to why execution isn't working how I'm expecting it to. I want to resize an image and then apply the Gaussian blur to that image, but only one is being done; whichever comes last.

Am I losing the data from the first operation as it goes to the second?

And how could I also do this is parallel with multiple GPUs if I wanted to use streams? If that's at all possible.

All help is appreciated Thank you!

Edit: My code is also attached.C:\fakepath\resizefilter.png

Resizing an image and applying a Gaussian blur

Hello, This seems a bit trivial, but I'm not sure as to why execution isn't working how I'm expecting it to. I want to resize an image and then apply the Gaussian blur to that image, but only one is being done; whichever comes last.

Am I losing the data from the first operation as it goes to the second?

And how could I also do this is parallel with multiple GPUs if I wanted to use streams? If that's at all possible.

All help is appreciated Thank you!

void resizeWithGauss(std::string inputFile, std::string outputFile) { Mat inputHost = imread(inputFile, CV_LOAD_IMAGE_COLOR); cuda::GpuMat inputDevice(inputHost); cuda::GpuMat outputDevice; const int ksize = 21; const int type = CV_64F; Timer timer; timer.Start(); cuda::resize(inputDevice, outputDevice, Size(), 2.0, 2.0, CV_INTER_CUBIC); cv::Ptr<cuda::filter> gauss = cv::cuda::createGaussianFilter(inputDevice.type(), outputDevice.type(), Size(ksize, ksize), 6.0, 6.0); gauss->apply(inputDevice, outputDevice); timer.Stop(); printf("OpenCV GPU code ran in: %f msecs. \n", timer.ElapsedTime()); Mat outputHost; outputDevice.download(outputHost); imwrite(outputFile, outputHost); inputHost.release(); outputDevice.release(); }

Resizing an image and applying a Gaussian blur

Hello, This seems a bit trivial, but I'm not sure as to why execution isn't working how I'm expecting it to. I want to resize an image and then apply the Gaussian blur to that image, but only one is being done; whichever comes last.

Am I losing the data from the first operation as it goes to the second?

And how could I also do this is parallel with multiple GPUs if I wanted to use streams? If that's at all possible.

All help is appreciated Thank you!

void resizeWithGauss(std::string inputFile, std::string outputFile)
{
    outFile){
Mat inputHost = imread(inputFile, CV_LOAD_IMAGE_COLOR);
 cuda::GpuMat inputDevice(inputHost);
 cuda::GpuMat outputDevice;
 const int ksize = 21;
 const int type = CV_64F;
 Timer timer;
 timer.Start();
 cuda::resize(inputDevice, outputDevice, Size(), 2.0, 2.0, CV_INTER_CUBIC);
    cv::Ptr<cuda::filter> cv::Ptr<cuda::Filter> gauss = cv::cuda::createGaussianFilter(inputDevice.type(), outputDevice.type(), Size(ksize, ksize), 6.0, 6.0);
 gauss->apply(inputDevice, outputDevice);
 timer.Stop();
 printf("OpenCV GPU code ran in: %f msecs. \n", timer.ElapsedTime());
 Mat outputHost;
 outputDevice.download(outputHost);
 imwrite(outputFile, outputHost);
 inputHost.release();
    outputDevice.release();
}

outputDevice.release();}