如何在涂料应用的填充操作的工作? [英] How does the fill operation work in paint applications?

查看:119
本文介绍了如何在涂料应用的填充操作的工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所有的绘图程序,独立于它们是如何简单或复杂的是,配备了填充工具。这基本上取代的封闭区域与另一种颜色的颜色。我知道,有不同的API来做到这一点,但我感兴趣的算法研究。什么是一个高效的算法来实现这个工具?

All paint programs, independent of how simple or complex they are, come with a fill tool. This basically replaces the color of a closed region with another color. I know that there are different APIs to do this, but I am interested in the algorithm. What would be an efficient algorithm to implement this tool?

一对夫妇的事情,我能想到的快速如下:

A couple of things I can think of quickly are:

  1. 在转换图像转换成二进制的地图,其中的彩色像素被替换为 1 和所有其他颜色 0
  2. 找到各地要更改,使得所有像素内的1,所有的相邻像素是0点的封闭区。
  1. Convert image into a binary map, where pixels in the color to be replaced are 1 and all other colors are 0.
  2. Find a closed region around the point you want to change such that all the pixels inside are 1 and all the neighbouring pixels are 0.

样品图像

推荐答案

许多实现都是因为一个递归征服和除法算法。如果你做一个快速谷歌的洪水填充算法,你会发现很多资源,包括的话题

Many implementations are done as a recursive conquer and divide algorithm. If you do a quick google for "flood fill algorithm" you will find plenty of resources including the excellent wikipedia page on the topic.

这篇关于如何在涂料应用的填充操作的工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆