Spatial and temporal on depth image
Hi,
I would like to do Spatial and temporal on a depth image. spatial average can be achieved by convolution (cv::filter2D), for temporal average you would need to accumulate() N images, and divide by N but I don't know how to use OpenCV to do that.
What I tried for spatial filter is
cv::Mat dst;
int kernel_size = 2;
cv::Mat kernel = cv::Mat::ones(kernel_size, kernel_size, CV_32F) / (float)(kernel_size * kernel_size);
// Apply filter
filter2D(depth_image_ocv, dst, -1, kernel, cv::Point(-1, -1), 0, cv::BORDER_DEFAULT);
but the result is horrible as shown in the image.
cv::imshow("Filtered Depth", dst);
cv::imshow("Depth", depth_image_ocv);
try an odd kernel size, 3,5,7, etc. think of it, summing over neighbours needs a "center" pixel
you also could try a simple
boxFilter()
Thanks I will try it. Have another problem. Also the above code that does temporarily filtering isn't working. In each frame the filtered image is getting ghosty and it does that untill it fades to black –
@Ahmed You need to ask a separate question.