Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

cv::merge execution time with CV_32S

Hello,

I used following code snippet to merge a few single channel images into a multichannel Mat:

vector<cv::Mat> images(numcomps);
for (int i = 0; i < numcomps; i++)
    images[i] = cv::Mat(h, w, CV_32SC1, (image->comps + comps[i])->data);
cv::merge(images, imageMat);

On my machine this code execution time is about 500 ms (!!!), regardless of the number of elements in vector<cv::Mat> images (i.e. even if numcomps == 1). What can be the reasons behind such an overhead?

If I rewrite code as follows it reduces execution time to 2 ms:

Mat result(h, w, CV_MAKETYPE(CV_32S, numcomps));
vector<cv::Mat> images(numcomps);
for (int i = 0; i < numcomps; i++)
{
    int from_to[] = { 0,i };
    images[i] = cv::Mat(h, w, CV_32SC1, (image->comps + comps[i])->data);
    cv::mixChannels(&images[i], 1, &result, 1, from_to, 1);
}
imageMat = result;

I'm using OpenCV 3.1.0 built with CUDA 7.5 (Ubuntu 14.04, Intel® Core™ i3-4170 CPU @ 3.70GHz × 4, GeForce GTX 960/PCIe/SSE2 ).

Cheers, Kate

cv::merge execution time with on CV_32S

Hello,

I used following code snippet to merge a few single channel images into a multichannel Mat:

vector<cv::Mat> images(numcomps);
for (int i = 0; i < numcomps; i++)
    images[i] = cv::Mat(h, w, CV_32SC1, (image->comps + comps[i])->data);
cv::merge(images, imageMat);

On my machine this code execution time is about 500 ms (!!!), regardless of the number of elements in vector<cv::Mat> images (i.e. even if numcomps == 1). What can be the reasons behind such an overhead?

If I rewrite code as follows it reduces execution time to 2 ms:

Mat result(h, w, CV_MAKETYPE(CV_32S, numcomps));
vector<cv::Mat> images(numcomps);
for (int i = 0; i < numcomps; i++)
{
    int from_to[] = { 0,i };
    images[i] = cv::Mat(h, w, CV_32SC1, (image->comps + comps[i])->data);
    cv::mixChannels(&images[i], 1, &result, 1, from_to, 1);
}
imageMat = result;

I'm using OpenCV 3.1.0 built with CUDA 7.5 (Ubuntu 14.04, Intel® Core™ i3-4170 CPU @ 3.70GHz × 4, GeForce GTX 960/PCIe/SSE2 ).

Cheers, Kate

cv::merge execution time on CV_32S

Hello,

I used following code snippet to merge a few single channel images into a multichannel Mat:

vector<cv::Mat> images(numcomps);
for (int i = 0; i < numcomps; i++)
    images[i] = cv::Mat(h, w, CV_32SC1, (image->comps + comps[i])->data);
cv::merge(images, imageMat);

On my machine this code execution time is about 500 ms (!!!), regardless of the number of elements in vector<cv::Mat> images (i.e. even if numcomps == 1). What can be the reasons behind such an overhead?

If I rewrite code as follows it reduces execution time to 2 ms:

Mat cv::Mat result(h, w, CV_MAKETYPE(CV_32S, numcomps));
vector<cv::Mat> images(numcomps);
for (int i = 0; i < numcomps; i++)
{
    int from_to[] = { 0,i };
    images[i] = cv::Mat(h, w, CV_32SC1, (image->comps + comps[i])->data);
    cv::mixChannels(&images[i], 1, &result, 1, from_to, 1);
}
imageMat = result;

I'm using OpenCV 3.1.0 built with CUDA 7.5 (Ubuntu 14.04, Intel® Core™ i3-4170 CPU @ 3.70GHz × 4, GeForce GTX 960/PCIe/SSE2 ).

Cheers, Kate

cv::merge execution time on CV_32S

Hello,

I used following code snippet to merge a few single channel images into a multichannel Mat:

vector<cv::Mat> images(numcomps);
for (int i = 0; i < numcomps; i++)
    images[i] = cv::Mat(h, w, CV_32SC1, (image->comps + comps[i])->data);
cv::merge(images, imageMat);

On my machine this code execution time is about 500 ms (!!!), regardless of the number of elements in vector<cv::Mat> images (i.e. even if numcomps == 1). What can be the reasons behind such an overhead?

If I rewrite code as follows it reduces execution time to 2 ms:

cv::Mat result(h, w, CV_MAKETYPE(CV_32S, numcomps));
vector<cv::Mat> images(numcomps);
for (int i = 0; i < numcomps; i++)
{
    int from_to[] = { 0,i };
    images[i] = cv::Mat(h, w, CV_32SC1, (image->comps + comps[i])->data);
    cv::mixChannels(&images[i], 1, &result, 1, from_to, 1);
}
imageMat = result;

I'm using OpenCV 3.1.0 built with CUDA 7.5 (Ubuntu 14.04, Intel® Core™ i3-4170 CPU @ 3.70GHz × 4, GeForce GTX 960/PCIe/SSE2 ).

Cheers, Kate