如何从图像文件生成马赛克图片?

发布于 2024-11-07 18:41:12 字数 322 浏览 0 评论 0原文

我有一个源图像(如左图)和一组元素(如右图): Source Image和 Elements...

..我需要生成像 这样的马赛克图片这个

但直到现在我还没有接触过图像,我不知道应该从哪里开始。

我使用 C# 工作了几年,但您可以使用其他类似语言给出示例。

I have a source image like left picture and a set of elements like right picture: Source Image And Elements...

..and I need to generate a mosaic picture like this.

But until this moment I have not worked with images, аnd I do not know where I should start.

I worked several years with C#, but you can give examples in other similar languages.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

您给出的结果图像显然是 ministeck 模式 - 2011 年,他们有一个可下载的软件,似乎可以做您想要的事情想。 (ministeck 不再直接提供该服务,但 pfci.de 似乎仍然提供下载)。

因此,如果您只是想从给定的图像中生成 ministeck 的模式,请使用他们的软件。如果您正在寻找一种算法来实现不同的目标,那么这将无济于事。

编辑

好的,如果您在分析图像后,需要将其加载到如下所示的对象中:

using(Bitmap b = new Bitmap(yourFileName))
{
  MessageBox.Show(string.Format("image size {0} by {1} pixels", b.Width, b.Height));
  MessageBox.Show(string.Format("color of pixel (100,100) is {0}", b.GetPixel(100, 100).ToString()));
}

Bitmap 对象有几个 属性方法将帮助您分析图像内容。尝试这样做来开始分析您的图像,并且不要忘记随后处理您的位图或将其包装到 using 语句中,如上所示......

The result image you gave is apparently a ministeck pattern - in 2011 they had a downloadable software that seemed to do what you want. (Which is not available anymore by ministeck directly, but it seems that pfci.de still provides a download).

So, if you're just looking to generate the patterns for ministeck out of a given image, use their software. If you're after an algorithm to achieve something different, this won't help.

EDIT

Ok, if you're after analyzing your image, you need to load it into an object like this:

using(Bitmap b = new Bitmap(yourFileName))
{
  MessageBox.Show(string.Format("image size {0} by {1} pixels", b.Width, b.Height));
  MessageBox.Show(string.Format("color of pixel (100,100) is {0}", b.GetPixel(100, 100).ToString()));
}

The Bitmap object has several properties and methods that will help you to analyze the image content. Try this to get started with analyzing your image, and don't forget to either dispose your bitmap afterwards or wrap it into a using statement as shown above ...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文