0

可能重复:
Flood Fill Algorithm - Objective C 版本

我想将颜色绘制到图像中的区域(不是所有区域,假设我想将颜色绘制为图像中的圆圈)它似乎是 Photoshop 上的油漆桶工具。我应该怎么做?提前致谢

在此处输入图像描述

4

1 回答 1

1

您在推断要填充的形状或洪水填充算法时遇到问题吗?我从你的问题中推断出你的大部分问题都出在算法上。

直接来自维基百科,这里是洪水填充的伪算法。

Flood-fill (node, target-color, replacement-color):
 1. If the color of node is not equal to target-color, return.
 2. Set the color of node to replacement-color.
 3. Perform Flood-fill (one step to the west of node, target-color, replacement-color).
    Perform Flood-fill (one step to the east of node, target-color, replacement-color).
    Perform Flood-fill (one step to the north of node, target-color, replacement-color).
    Perform Flood-fill (one step to the south of node, target-color, replacement-color).
 4. Return.

[资源]

在此处输入图像描述

于 2012-08-21T08:06:23.197 回答