Skip to content

Commit

Permalink
Check the image size wrt. the Gaussian kernel size and throw an excep…
Browse files Browse the repository at this point in the history
…tion if the image dimension is too small.
  • Loading branch information
s-trinh committed Jan 5, 2025
1 parent b38f92e commit a82c454
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions modules/core/src/image/vpImageFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,13 @@ void vpImageFilter::gaussianBlur<double, double>(const vpImage<double> &I, vpIma
void vpImageFilter::gaussianBlur(const vpImage<vpRGBa> &I, vpImage<vpRGBa> &GI, unsigned int size, double sigma, bool normalize,
const vpImage<bool> *p_mask)
{
if (size-1 > I.getWidth() || size-1 > I.getHeight()) {
std::ostringstream oss;

Check warning on line 324 in modules/core/src/image/vpImageFilter.cpp

View check run for this annotation

Codecov / codecov/patch

modules/core/src/image/vpImageFilter.cpp#L324

Added line #L324 was not covered by tests
oss << "Image size (" << I.getWidth() << "x" << I.getHeight() << ") is too small for the Gaussian kernel ("
<< "size=" << size << "), min size is " << (size-1);
throw vpException(vpException::dimensionError, oss.str());
}

Check warning on line 328 in modules/core/src/image/vpImageFilter.cpp

View check run for this annotation

Codecov / codecov/patch

modules/core/src/image/vpImageFilter.cpp#L327-L328

Added lines #L327 - L328 were not covered by tests

double *fg = new double[(size + 1) / 2];
vpImageFilter::getGaussianKernel(fg, size, sigma, normalize);
vpImage<vpRGBa> GIx;
Expand Down

0 comments on commit a82c454

Please sign in to comment.