2

Is there any reason why I should use numpy to represent pixels in an image manipulation program as opposed to just storing the values in my own array of numbers? Currently I am doing the latter but I see lots of people talking about using numpy for representing pixels as multidimensional arrays. Other than that are there any reasons why I should be using numpy as opposed to my own implementation?

user3282276
  • 3,674
  • 8
  • 32
  • 48
  • In general numpy is more efficient expecially for calculations. Since it is implemented in cython. If you just need to store the array I am not sure numpy makes such a big difference. – Gioelelm Nov 19 '14 at 07:45
  • This question is probably too broad for a good answer. There are many aspects why numpy can be superior over plain python objects - e.g. computations are usually much faster, numpy arrays take less memory and numpy comes with lots of efficient algorithms. But in the end it really depends on the problem you have to solve. – cel Nov 19 '14 at 07:50

2 Answers2

3

If you are looking at image processing in Python, you should definitely look into this:

http://scipy-lectures.github.io/advanced/image_processing/index.html

ssm
  • 5,277
  • 1
  • 24
  • 42
2

Well I think you could do that, but maybe less convenient. The reasons could be:

  1. numpy supports all the matrix manipulations and since it is optimized, could be much faster (You can also switch to OpenBLAS to make it amazingly faster). For image-processing problems, in some cases where images become larger, it could be much demanding for the speed.

  2. numpy has lots of useful function handles, such as numpy.fft for Fourier Tranformation, or numpy.conv to do the convolution. This could be critical for image processing.

  3. All the modules, or packages are nearly all based on numpy, such as scipy, graphlab and matplotlib. For example, you should use 'import matplotlib.pyplot as plt; plt.imshow()' to show images; well some other arrays could be hardly accepted as the arguments.

Jake0x32
  • 1,402
  • 2
  • 11
  • 18