问题描述
我正在使用CUDA进行图像处理,我对像素处理有疑问。
应用 mxm
卷积过滤器时,通常对图像的边界像素执行什么操作? / strong>
在 3 x 3
卷积内核中,忽略 1
像素边界的图像更容易处理,特别是当代码改进与共享内存。实际上,在这种情况下,不需要检查给定像素是否具有所有可用的邻居(即,coord
(0,0)
的像素没有离开,上部,上部邻居)。但是,删除原始图像的 1
像素边界可能会产生部分结果。
与此相反,我想要处理图片中的像素,全部,也可以使用共享内存改进,例如,载入 16 x 16
像素,但计算内部 14 x 14
。在这种情况下,忽略边界像素会产生更清晰的代码。
在这种情况下通常做什么?
$ b
有没有人通常使用我忽略边界像素的方法?
当然,答案取决于问题的类型,即,逐像素地添加两个图像没有这个问题。
先感谢。
处理边框效果的常见方法是用原始图像填充额外的行&基于您的过滤器大小的列。填充值的一些常见选择是:
- 常数(例如零)
- 复制
- 在边界处反射图像(例如column [-1] = column [1],column [-2] = column [2] ])
- 封装图片值(例如column [-1] = column [width-1],column [-2] = column [width-2])
I'm working on image processing with CUDA and i've a doubt about pixel processing.
What is often done with the boundary pixels of an image when applying a m x m
convolution filter?
In a 3 x 3
convolution kernel, ignoring the 1
pixel boundary of the image is easier to deal with, especially when the code is improved with shared memory. Indeed, in this case, one does not need to check if a given pixel has all the neigbourhood available (i.e. pixel at coord (0, 0)
has not left, left-upper, upper neighbours). However, removing the 1
pixel boundary of the original image could generate partial results.
Opposite to that, I'd like to process all the pixels within the image, also when using shared memory improvements, i.e., for example, loading 16 x 16
pixels, but computing the inner 14 x 14
. Also in this case, ignoring the boundary pixels generates a clearer code.
What is usually done in this case?
Does anyone usually use my approach ignoring the boundary pixels?
Of course, I'm aware the answer depends on the type of problem, i.e. adding two images pixel-wise has not this problem.
Thanks in advance.
A common approach to dealing with border effects is to pad the original image with extra rows & columns based on your filter size. Some common choices for the padded values are:
- A constant (e.g. zero)
- Replicate the first and last row / column as many times as needed
- Reflect the image at the borders (e.g. column[-1] = column[1], column[-2] = column[2])
- Wrap the image values (e.g. column[-1] = column[width-1], column[-2] = column[width-2])
这篇关于处理CUDA中的边界条件/光晕区域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!