Smoothing a numpy matrix
I am doing data processing on images. Each pixel is considered a data point. The image reads like this:
im=Image.open('lena.bmp') im=numpy.array(im) print im.shape
Depending on whether the image is in color or grayscale, im.shape is either (10,10,3) or (10,10,1)
After that, the image is smoothed into a feature matrix as follows:
if (10,10,3), then ---> (100,3)
if (10,10,1) then ---> (100,1)
How do I write a polymorphic function for this? My current approach:
obs=reshape(im,(im.shape[0]*im.shape[1],1, im.size/(im.shape[0]*im.shape[1])))
+3
source to share