【发布时间】:2016-02-16 08:00:55
【问题描述】:
我需要对图像的某个区域执行泛光填充。但是我实际上并不需要生成的图像,我只需要知道包含所有将被洪水填充更改的像素的最小矩形。
是否有一种泛洪填充算法的变体可以比完全泛洪填充更便宜地计算这个矩形?
输入输出示例(只需要红色矩形):
Sample input image. The red dot is the start pixel. The area to be filled is the cyan Z-tetromino that contains the dot http://www.finnw.me.uk/ffinput.pngSample output. Only the position/width/height of the red rectangle is significant http://www.finnw.me.uk/ffoutput.png
编辑: 带有岛屿的示例 #2:
Example input with islands http://www.finnw.me.uk/ffinput2.png
Example output http://www.finnw.me.uk/ffoutput2.png
示例 #3:
Example of false island http://www.finnw.me.uk/ffinput3.png
编辑
抱歉,图像因硬盘故障而丢失。当我第一次发布此内容时,SO 没有托管图片,因此我将它们保存在自己的服务器上。
【问题讨论】:
-
我发现这样的问题非常有趣。我们可以通过观察立即确定边界矩形是什么,但我们很难确定一个算法。
标签: algorithm image-processing flood-fill