【发布时间】:2010-06-30 22:53:05
【问题描述】:
我有一个问题: 给定一个包含 0 或 1 的数组 nxm,我需要将 0 值分组 成矩形。一开始,我用的是一个简单的四叉树,但是 树的同一级别中的不同节点具有相同的值。我是 不完全确定 R-tree 是否适用于我的问题或其他数据 结构,因为我只会在预计算步骤中使用这个结构 就是这样。
p.s.:我正在处理 2D 图像
【问题讨论】:
标签: image compression packing quadtree
我有一个问题: 给定一个包含 0 或 1 的数组 nxm,我需要将 0 值分组 成矩形。一开始,我用的是一个简单的四叉树,但是 树的同一级别中的不同节点具有相同的值。我是 不完全确定 R-tree 是否适用于我的问题或其他数据 结构,因为我只会在预计算步骤中使用这个结构 就是这样。
p.s.:我正在处理 2D 图像
【问题讨论】:
标签: image compression packing quadtree
我会选择递归解决方案。类似于
的东西iszeroes returns 1 if matrix has only zeroes
def search_for_zeroes(matrix, colormatrix)
! conquer - part, matrix is essentially only a cell
if size(matrix) .eq. 1 then
search_for_zeroes = iszeroes(matrix)
if iszeroes(colormatrix(matrix)then
colormatrix(matrix) = black)
end if
end if
! divide - part, looks if four cells are all zero and colors them black
if search_for_zeroes(upper_left) and search_for_zeroes(upper_right)
and search_for_zeroes(lower_left) and search_for_zeroes(lower_right) then
search_for_zeroes = true
colormatrix(matrix) = black
end if
我自己没有编写代码,只是伪代码。我今天下班时会改变它,但这也应该有效。 干杯
【讨论】: