Ask Your Question
0

Resizing an image and applying a Gaussian blur

asked 2018-03-27 22:49:18 -0600

nicksoto24 gravatar image

updated 2018-03-27 23:37:10 -0600

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 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> 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();}
edit retag flag offensive close merge delete

Comments

please add your code as text, not as an image.

berak gravatar imageberak ( 2018-03-27 23:06:14 -0600 )edit
1

i added it at as text. My apologies.

nicksoto24 gravatar imagenicksoto24 ( 2018-03-27 23:37:24 -0600 )edit
1

you're not filtering the resized image (which is in outputDevice), but the original one

berak gravatar imageberak ( 2018-03-28 01:46:53 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2018-03-28 04:39:41 -0600

updated 2018-03-28 04:41:12 -0600

So what @berak says is that you need to replace some stuff

  • cuda::GpuMat outputDevice, outputBothOperations;
  • gauss->apply(outputDevice, outputBothOperations);
  • outputBothOperations.download(outputHost);
edit flag offensive delete link more

Comments

1

awesome, that worked! Thank you very much :)

nicksoto24 gravatar imagenicksoto24 ( 2018-03-29 01:46:31 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2018-03-27 22:49:18 -0600

Seen: 1,027 times

Last updated: Mar 27 '18