「创造」有效地图像
我先告诉你问题,然后告诉你我的解决方案。
问题:我有一个大约 900x900 像素的空白白色 PNG 图像。我想复制大小为 30x30 像素的圆圈,它们本质上是具有不同颜色的圆圈。有 8 个不同的圆圈,并根据我在其他地方创建的数据值放置在图像上。
解决方案:我使用过 ImageMagicK,它应该适合通用图像编辑等。我创建了一个空白图像,
Image.outimage("900x900","white");
我使用“读取”功能上传所有其他小型 30x30 像素图像。
我上传数据并提取值。
我使用合成命令将小“圆形”图像放置在空白图像上。
outimage.composite("some file.png",pixelx,pixely,InCompositeOp);
这一切都运行良好,图像也按照我想要的方式显示。
然而它的速度慢得令人痛苦。制作一张图像需要 20 秒,而我有 1000 张图像。当然必须有更好的方法来做到这一点。我见过其他研究人员模拟更复杂、更快的图像。我很可能采取了错误的方法。也许我应该“画”圆圈而不是“粘贴”它们或其他什么。我很困惑。任何意见都会受到赞赏。
I'll first tell you the problem and then I'll tell you my solution.
Problem: I have a blank white PNG image approximately 900x900 pixels. I want to copy circles 30x30 pixels in size, which are essentially circles with a different colour. There are 8 different circles, and placed on the image depending on data values which I've created elsewhere.
Solution: I've used ImageMagicK, it's suppose to be good for general purpose image editing etc. I created a blank image
Image.outimage("900x900","white");
I upload all other small 30x30 pixel images with 'read' function.
I upload the data and extract vales.
I place the small 'circle' images on the blank one using the composite command.
outimage.composite("some file.png",pixelx,pixely,InCompositeOp);
This all works fine and the images come up the way I want them too.
However its painfully SLOW. It takes 20 seconds to do one image, and I have 1000 of them. Surely there must be a better way to do this. I've seen other researchers simulate images way more complex and way faster. It's quite possible I took the wrong approach. Maybe I sould be 'drawing' circles instead of 'pasting' them or something. I'm quite baffled. Any input is appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我怀疑您只需要一些能够在位图上绘制圆圈并将该位图保存为 png 的库。
例如我的 Graphin 库:http://code.google.com/p/graphin/
或者一些这样的。使用 Graphin,您还可以在另一个 PNG 的表面上绘制一个 PNG,就像您的情况一样。
I suspect that you just need some library that is capable of drawing circles on bitmap and saving that bitmap as png.
For example my Graphin library: http://code.google.com/p/graphin/
Or some such. With Graphin you can also draw one PNG on surface of another as in your case.
您没有提供有关您正在使用的平台的任何信息(仅“C++”),因此如果您正在寻找独立于平台的解决方案,CImg 库可能值得一试。
http://cimg.sourceforge.net/
顺便说一下,您是否尝试使用 ImageMagick C++ 绘制圆圈API Magick++ 而不是“组合”它们?我不敢相信它这么慢。
You did not give any information about the platform you are using (only "C++"), so if you are looking for a platform independent solution, the CImg library might be worth a try.
http://cimg.sourceforge.net/
By the way, did you try drawing the circles using the ImageMagick C++ API Magick++ instead of "composing" them? I cannot believe that it is that slow.