图像点处理:对每个深度图像像素点进行判断,将其与周围八点像素灰度值进行比较,如果某个点的灰度值跟周围八点存在比较大的差异,则该点可能为伪边缘,进行去除操作。
以下是我写的代码,请各位帮忙看看我理解的对嘛
如果深度图像当前的像素只为0是空洞,那么八邻域内像素值有大于0的,那说明是当前的位置的边缘就是伪边缘,然后令当前位置的边缘值为0,这样是不是就是去除了伪边缘?
%depth_edge 提取的深度图边缘,depth读取的深度图
[w,h]=size(depth_edge);
% 当前像素点值为0 ,若周围8邻域内有像素值大于0的,那当前像素点的边缘值为0
for ii = 2:w-1
for jj = 2:h-1
if depth(ii,jj) == 0
neighbors = [...
depth(ii-1,jj-1), depth(ii-1,jj), depth(ii-1,jj+1),...
depth(ii, jj-1), depth(ii, jj+1),...
depth(ii+1,jj-1), depth(ii+1,jj), depth(ii+1,jj+1)...
];
if ~isempty(find(neighbors) > 0)
depth_edge(ii,jj) = 0;
end
end
end
end