# Why filter2D rounds certain results?

I have an image and filter:

I applied a few operations on it below. I checked the results for `ratioA`

, and `ratioB`

, and noticed they were the same or very close to the variables with the same names in Matlab. However, the result differs for `ratio`

:

```
Mat img = imread("lenablur.bmp");
cvtColor(img, img, cv::COLOR_BGR2GRAY);
img.convertTo(img, CV_64F);
cv::Scalar s=255;
divide(img, s, img);
cv::Mat kernel = imread("PSFgauss.bmp");
cvtColor(kernel, kernel, cv::COLOR_BGR2GRAY);
kernel.convertTo(kernel, CV_64F);
cv::Scalar kernelsum = cv::sum(kernel);
divide(kernel, kernelsum, kernel);
Mat deconv=img.clone();
Mat ratio; Mat ratioA; Mat ratioB;
filter2D(deconv, ratioA, deconv.depth(), kernel, Point(-1, -1), 0,
BORDER_REFLECT);
divide(img, ratioA, ratioB);
filter2D(ratioB, ratio, ratio.depth(), kernel, Point(-1, -1), 0,
BORDER_REFLECT);
for (int r = 90; r < 93; r++) {
for (int c = 70; c < 75; c++) {
cout << ratio.at<double>(r, c) << " ";
}
cout << endl;
}
```

the result for `ratio`

is:

```
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
```

The values for `ratioA`

and `ratioB`

were good, and they matched the values I got when using Matlab. However, for `ratio`

the values seemed to be rounded down somehow to `int`

values instead of remaining `double`

. Why did this happen, especially since the values for `ratioA`

and `ratioB`

were not rounded down in OpenCV?

EDIT: `observed`

and `img`

are supposed to be the same, `psf`

and `kernel`

are supposed to be the same. Fixed the typos

where is

`deconv`

coming from ? (you're assuming, that the result of filter2D has the same type)also, you construct a

`kernel`

, but later use a`psf`

. things don't match. please correct.also:

`observed`

? we can help you, if we can reproduce it, help us with that, please.I fixed the typos as mentioned in the

`EDIT`