显示图像的颜色直方图
我正在 PHP 中寻找一个函数,它将 直方图 从图像提取到 PNG 文件。此 PNG 文件将位于与实际图像不同的文件夹中,并且该函数必须处理大图像(超过 3 MB)。我确实找到了一个 函数几乎与我的请求类似,但该函数无法处理大图像,而且它没有显示了直方图,也没有显示其网站上显示的图像(它只显示了一个带有边框的空白窗口)。
我希望你们能帮助我解决这个问题。
提前致谢。
I'm searching for a function in PHP which extract the histogram from an image to an PNG file. This PNG file will be located in a different folder than the actual image and the function must handle large images (over 3 MB). I did find a function almost similar to my request but the function can not handle large images and it didn't showed the histogram nor the image as showed on their website (it showed only a blank window with a border).
I hope that you guys can help me with this.
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我们一直在我们的项目中使用这个:
http://www.histogramgenerator.com/
我们没有遇到大图像问题。它不是免费的,但我们确实觉得它是
值得我们付的钱。该课程还提供许多其他有趣的功能。
问候
We've been using this one for our projects:
http://www.histogramgenerator.com/
We did not experience issues with large images. It's not free, but we definetly feel it's
worth the money we paid for. The class also offers many additional interesting features.
Regards
它是一个像 Photoshop 那样绘制简单直方图的脚本(只是相似,因为我怀疑它使用 sigmoid 函数或类似函数缩放两个轴)。
我编写了一个
scale()
函数,您可以在其中使用最后一个布尔参数来绘制线性直方图,或使用平方根刻度来提高低值。请注意,我不会检查filename是否存在,也不检查
getimagesize()
或imagecreatefrompng()
是否失败。It is a script to draw a simple histogram like Photoshop does (only similar, because I suspect it scale both axes with a sigmoid function, or something like that).
I wrote a
scale()
function where you can use a last bool argument to do a linear histogram, or use a square root scale to boost low values.Note I'm not checking if filename exist, neither if
getimagesize()
orimagecreatefrompng()
failed.我使用 2MB (5800 x 5800) PNG 图像对此进行了测试。基本上“imagecreatefrompng()”方法消耗大量内存。
所以在调用之前,我将内存一路增加到512M,并将执行时间设置为5分钟。
在创建Image之后,恢复内存限制
参考:http://www.php.net/manual/en/function.imagecreatefrompng.php#73546
I tested this with a 2MB (5800 x 5800) PNG Image. Basicaly the "imagecreatefrompng()" method is consuming lot of memory.
So before making the call, I increased the memory al the way up to 512M and set the execution time to 5 mins
After the Image is created, restore the memory limit
Reference: http://www.php.net/manual/en/function.imagecreatefrompng.php#73546