Ikkster
Ikkster

Reputation: 3

How do you delete an entire column of values from an ndarray obtained from misc.imread()?

I am reading a png image and it is in RGBA format and i would like to remove the 'A' part. The shape of my image is (694, 1077, 4) but I would like it to be (694, 1077, 3). I'd like to remove the last column in the array so I only have RGB values.

Upvotes: 0

Views: 121

Answers (3)

Benjamin
Benjamin

Reputation: 11860

You can use the mode='RGB' parameter (see docs), which should omit the alpha band.

Upvotes: 0

jhuang
jhuang

Reputation: 806

Simply do this:

im_without_A = im[:, :, :3]

Upvotes: 1

Yarnspinner
Yarnspinner

Reputation: 892

nd = np.random.randn(60).reshape(3,4,5)
print nd
print nd[:,:,:nd.shape[2]-1].shape #(3L, 4L, 4L)

This will take out the last column.

Upvotes: 0

Related Questions