WPF:查找图像中的所有封闭区域(C#甚至VB)

编程入门 行业动态 更新时间:2024-10-26 15:16:47
本文介绍了WPF:查找图像中的所有封闭区域(C#甚至VB)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在为有身体限制的儿童制作一本简单的着色书。 教师将能够在仅由封闭区域组成的程序中插入图片。 然后我需要分析图像并找到所有封闭区域(孩子能够着色的地方)。 我需要这样做,因为所有可以涂漆的区域会一个接一个地发光。 我想我可以通过填充来实现这一点,所以我需要在每个封闭区域内有一个点(X,Y坐标)。

I am working on a simple coloring book for children with physical limitations. Teachers will be able to insert a picture in the program composed of only closed areas. I then need to analyze the image and find all closed areas (the places the child will be able to color). I need to do this because all areas that can be painted will glow up one after the other. I think I can accomplish this with a floodfill so I need a point (X,Y coordinate) inside every closed area.

任何人都做过这样的事情? 一些提示或源代码可用吗?

Anyone ever did something like this? Some tips or source code available?

非常感谢!

推荐答案

我对WPF本身没有多少经验,但我可能会使用这样的算法:

I don't have much experience with WPF per se, but I would probably use an algorithm like this:

首先,我假设图像是严格的单色。也就是说,只有纯黑色(线条)和纯白色(可着色区域)像素。

First, I am assuming the image is strictly monochrome. That is, there are only pure black (line) and pure white (colourable area) pixels.

  • 将图像转换为真彩色
  • 检查左上角的像素。
  • 如果此像素为白色,请使用新的唯一颜色进行填充
  • 向右移动一个像素(如果超出范围,向下移动一个,一直向左移动)
  • 转到3
  • Convert the image to true-colour
  • Examine the Top-Left pixel.
  • If this pixel is white, do a flood fill with a new unique colour
  • Move one-pixel to the right (if out of bounds, move down one and all the way to the left)
  • Go to 3
  • 现在,图像中的每个区域都有不同的颜色。

    Now, every area in the image has a different colour.

    更多推荐

    WPF:查找图像中的所有封闭区域(C#甚至VB)

    本文发布于:2023-11-12 01:16:09,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1580095.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:图像   区域   WPF   VB

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!