1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-30 15:53:03 +04:00

Merge branch 4.x

This commit is contained in:
Alexander Smorkalov
2025-03-04 16:42:12 +03:00
42 changed files with 3445 additions and 816 deletions
+14 -2
View File
@@ -2344,21 +2344,33 @@ void filterSpecklesImpl(cv::Mat& img, int newVal, int maxSpeckleSize, int maxDif
using namespace cv;
int width = img.cols, height = img.rows, npixels = width*height;
size_t bufSize = npixels*(int)(sizeof(Point2s) + sizeof(int) + sizeof(uchar));
// space allocation for:
// labels : npixels * sizeof(int)
// wbuf : npixels * sizeof(Point2s)
// rtype : (npixels + 1) * sizeof(uchar)
size_t bufSize = npixels * sizeof(int) // for labels
+ npixels * sizeof(Point2s) // for wavefront buffer (wbuf)
+ (npixels + 1) * sizeof(uchar); // for region type (rtype)
if( !_buf.isContinuous() || _buf.empty() || _buf.cols*_buf.rows*_buf.elemSize() < bufSize )
_buf.reserveBuffer(bufSize);
uchar* buf = _buf.ptr();
int i, j, dstep = (int)(img.step/sizeof(T));
// store labels and their corresponding region types
int* labels = (int*)buf;
buf += npixels*sizeof(labels[0]);
// store wavefront
Point2s* wbuf = (Point2s*)buf;
buf += npixels*sizeof(wbuf[0]);
// store region type
uchar* rtype = (uchar*)buf;
buf += (npixels + 1) * sizeof(rtype[0]);
int curlabel = 0;
// clear out label assignments
// clear out label and rtype buffers
memset(labels, 0, npixels*sizeof(labels[0]));
memset(rtype, 0, (npixels + 1)*sizeof(rtype[0]));
for( i = 0; i < height; i++ )
{