matejak / imreg_dft

Image registration using discrete Fourier transform.
Other
245 stars 68 forks source link

Memory issue #29

Open overfrequency opened 7 years ago

overfrequency commented 7 years ago

I have an array of images of size 1010x1010. I would like to register all of the images in this array onto the first image. When I run the following code my 8GB of memory gets full:

import numpy as np
import imreg_dft as ird

def register(im1,im2):
  result = ird.similarity(im1, im2, numiter=1)
  assert "timg" in result
  return result['timg']

im1 = img_array[:,:,0] # first image in the array

for i in xrange(1, num_images):
 img_array[:, :, i] = register(im1, img_array[:,:,i])

Do you have any idea what could be the problem? Thanks!

Edit: Images are float and the pixel values are not necessarily within 0-255 range.

matejak commented 7 years ago

The problem with imreg_dft is that it is not particularly memory efficient. The memory problem may be mitigated in the future. However, if you don't use the fftw package to do the Fourier transform, I suggest that you install it and see whether the memory usage decreases. On a side note, try to use the ird command-line tool - you feed it one pair of images at time and you are unlikely to worry about memory issues. It supports .mat format, so you can use your float-number images.