Amn Kh Amn Kh - 23 days ago 5
Python Question

How to convert a concatenated image to the its original one, Python

Suppose

im
is an image with the size of 100*100*3. The following code gives the corresponding concatenated image:

im = np.concatenate((
im[:,:,0].reshape((100*100,)),
im[:,:,1].resh‌​ape((100*100,)),
im[:‌​,:,2].reshape((100*1‌​00,))
),
axis=0
)


Now we have a row array with a size of 1*30000.

The question is that how we can get back from the concatenated image to the original one?

Answer
im = im.reshape(300,100)
s = np.zeros((100,100,3))
s[:,:,0] = im[:100,:]
s[:,:,1] = im[100:200,:]
s[:,:,2] = im[200:,:]
Comments