OCV 4.5; C++; Visual Studio 2017; MFC; Windows 10

I am having a timing problem that does not seem right and I believe that I must be doing something wrong.

I can go through a Mat image of color type HSV size 1920 X 1080 pixel by pixel using the standard code below in about 10ms

```
cv::Mat HSVImg(mMyImage.size(), mMyImage.type());
cv::cvtColor(mMyImage, HSVImg, CV_BGR2HSV);
for (int row = 0; row < HSVImg.size().height; row++)
{
for (int col = 0; col < HSVImg.size().width; col++)
{
cv::Vec3b value = HSVImg.at<cv::Vec3b>(row, col);
// Do some math calculations and then assign the new value with
HSVImg.at<cv::Vec3b>(row, col) = value;
}
}
}
```

However, on a Mat of this type

```
cv::Mat mMaskImg(mMyImage.size(), CV_64F, Scalar(1));
```

with values only from 0 to 1 it takes 130ms to go through the pixels with this standard code

```
for (int i = 0; i < mMaskImg.rows; i++)
{
for (int j = 0; j < mMaskImg.cols; j++)
{
// Do some math and then assing the value with
mMaskImg.at<double>(i, j) = temp_s; // temp_s is a double with a value between 0 and 1
}
}
```

I have timed the lines containing the math and they are not the problem. The at() assignment is the problem.

I have tried to make the mMaskImage a CV_32F and use only floats in the math but when I try to assign the new value with

```
mMaskImg.at<float>(i, j) = temp_s;
```

it will crash each time no matter what I have tried.

My main problem is the speed. I tried the float only because I was wondering if dealing with 1920 X 1080 Mat of 32 bit floats would be faster than a Mat of 64bit doubles.

Regardless, can anyone explain why the `mMaskImg.at<double>(i, j)`

is running 13 times slower than the `HSVImg.at<cv::Vec3b>(row, col)`

?

PS the less than - float - greater than and less than - double - greater than are not coming out in the quoted lines or even here but you know what they should be

Thanks