diff --git a/apps/createsamples/utility.cpp b/apps/createsamples/utility.cpp index 76734a154a8f..ece9c085daad 100644 --- a/apps/createsamples/utility.cpp +++ b/apps/createsamples/utility.cpp @@ -685,8 +685,8 @@ void icvPlaceDistortedSample( Mat background, Mat img( background.size(), CV_8UC1 ); Mat maskimg( background.size(), CV_8UC1 ); - resize( data->img(roi), img, img.size(), 0, 0, INTER_LINEAR_EXACT); - resize( data->maskimg(roi), maskimg, maskimg.size(), 0, 0, INTER_LINEAR_EXACT); + resize( data->img(roi & Rect(Point(0,0), data->img.size())), img, img.size(), 0, 0, INTER_LINEAR_EXACT); + resize( data->maskimg(roi & Rect(Point(0, 0), data->maskimg.size())), maskimg, maskimg.size(), 0, 0, INTER_LINEAR_EXACT); forecolordev = theRNG().uniform( -maxintensitydev, maxintensitydev );