0

I have an numpy array which I save to a image using savefig(). Then I read it in my code and the image is multiplied bigger than my original aray as dpi while saving is 100.

Is it possible to use dpi to make the image size larger and get it in a numpy array without saving and loading it again?

Joe Kington
  • 275,208
  • 71
  • 604
  • 463
shobhit
  • 89
  • 2
  • 8
  • 1
    Your question is not clear. Do you want to resize an image ? – Juh_ Jun 13 '12 at 12:48
  • For whatever it's worth, this is a matplotlib question, not a numpy question. What are you asking? The DPI of the plot has nothing to do with the size of the array... Likewise, the size of the array has absolutely nothing to with the size of the saved image. What are you trying to do? – Joe Kington Jun 13 '12 at 17:58
  • So size of my array is say 25x25. When I save it using savefig, bsed on the dpi, my image is saved at a certain resolution. Now when I load this image back again using opencv LoadImage(), I get image of size 500x500. What I want to do is eliminate the saving and loading again part. So I figured if I can scale the original array somehow to use dpi information, that should do it. – shobhit Jun 14 '12 at 17:18

1 Answers1

0

Sounds like you want to take an array of size (a, b) and scale it by an arbitrary factor s so that the resulting array has shape (a*s, b*s)?

There are several ways of doing this as far as I am aware, but perhaps the best resource is the cookbook page on rebinning: http://www.scipy.org/Cookbook/Rebinning

HTH

pelson
  • 21,252
  • 4
  • 92
  • 99