简体   繁体   English

在python或ImageMagick中对热图进行后处理

[英]Post-processing the heatmap in python or ImageMagick

How could I make this heatmap look more clear without the blurred effect. 没有模糊效果,如何使此热图看起来更清晰 How could I sharpen it Python (or ImageMagick)? 我该如何提高Python(或ImageMagick)的清晰度? also, how could I get a pixel-grid on the background? 另外, 如何在背景上显示像素网格

在此处输入图片说明

Here is what I used to get the current image: 这是我用来获取当前图像的内容:

maxsize = (1030, 2056)
for i in range(1,334,1):
    img = Image.open('C:Desktop/Img/image'+'_'+ str(i)+'.png')
    img = img.resize(maxsize, Image.BICUBIC)
    img.save('C:/Desktop/Res/img'+'_'+ str(i)+'.png', dpi = (7040,7040))

I also tried in ImageMagick (but that did not help much, atleast looking visually): 我也在ImageMagick中尝试过(但效果不佳,至少在视觉上看起来是这样):

magick img_244.png -sharpen 0x3 out.png

Thank you very much in advance, 预先非常感谢您,

In ImageMagick (and also OpenCV/python) you can use kmeans to process your image. 在ImageMagick(以及OpenCV / python)中,您可以使用kmeans处理图像。 I have a bash unix shell script for ImageMagick that does that. 我有一个用于ImageMagick的bash unix shell脚本来执行此操作。

kmeans -n 7 -m 5 g4Zwf.png result7.png

where n is the number of colors and m is the maximum number of iterations. 其中,n是颜色数,m是最大迭代数。

在此处输入图片说明

Then you can use my script, grid, to draw lines (or use ImageMagick directly) to draw lines. 然后,您可以使用我的脚本网格来绘制线条(或直接使用ImageMagick)来绘制线条。 Using my script, grid with 100 pixel spacing gives: 使用我的脚本,间距为100像素的网格给出:

grid -s 100,100 -c white result7.png result7g100.png

在此处输入图片说明

My scripts are at http://www.fmwconcepts.com/imagemagick/index.html 我的脚本位于http://www.fmwconcepts.com/imagemagick/index.html

For OpenCV/Python, see http://docs.opencv.org/3.0-beta/doc/py_tutorials/py_ml/py_kmeans/py_kmeans_opencv/py_kmeans_opencv.html and How to write lines and grid on image in Python? 对于OpenCV / Python,请参见http://docs.opencv.org/3.0-beta/doc/py_tutorials/py_ml/py_kmeans/py_kmeans_opencv/py_kmeans_opencv.html如何在Python中的图像上绘制线条和网格?

OpenCV/Python also has expectation maximization that may perform better on your color processing than kmeans. OpenCV / Python还具有期望最大化,在色彩处理方面可能比kmeans更好。 See https://en.wikipedia.org/wiki/Expectation–maximization_algorithm and Maximum likelihood pixel classification in python opencv 参见https://en.wikipedia.org/wiki/Expectation–maximization_algorithmpython opencv中的最大似然像素分类

What module did you import as is Image ? 您将Image导入为哪个模块? What you need is a nearest neighbor interpolation, not bicubic interpolation . 您需要的是最近邻插值,而不是双三次插值 Probably something like 大概像

img = img.resize(maxsize, Image.INTER_NEAREST)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM