开发者

Superpose images via shell

I have two figures, one is a data plot resulting from some calculations and made with matplotlib and the other is a world map figure taken from google maps. I would like to reduce the matplotlib figure to some percentage value and superpose it over the map picture at certain position and get a final "mixed" picture. I know it can be done with graphical problems and so, but I would like to do it automatically on the shell for th开发者_Go百科ousands of different cases, I wonder if you could propose some methodology / ideas for this.


Just in case you wanted to do it directly using matplotlib when you're plotting your data (imagemagick is great otherwise):

import Image
import matplotlib.pyplot as plt
import numpy as np

dpi = 100.0

im = Image.open('Dymaxion_map_unfolded.png')
width, height = im.size
fig = plt.figure(figsize=(width / dpi, height / dpi))
fig.figimage(np.array(im) / 255.0)

# Make an axis in the upper left corner that takes up 20% of the height and 30%
# of the width of the figure
ax = fig.add_axes([0, 0.7, 0.2, 0.3])
ax.plot(range(10))

plt.show()

Superpose images via shell


ImageMagick can do the job, exactly the composite command. For the usage, check this url for the examples: http://www.imagemagick.org/Usage/annotating/#overlay


This sounds like something ImageMagick would be well suited for, esp. the -layers switch.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜