I have a numpy array A composed of multiple same sized images [N_images,width,height,3].
I want to apply misc.imresize()
to each and everyone of them the fastest way possible.
So I defined:
def myfunc(x):
return misc.imresize(x,(wanted_width,wanted_height))
and then I did:
vfunc=np.vectorize(my_func)
but when I try:
test=vfunc(A)
I get a not-suitable-array-shape-for-converting-into-images error. I thought it was because I did not specify the axis on which the op should be vectorized, which caused it to not broadcast the array ops the way to wanted so I tried another thing to narrow down the error:
test=np.apply_along_axis(my_func,0,A)
and got the same error. Even if I force a np.squeeze() into my_func. That really surprised me.
EDIT: I also tried with map
same error.
It might stem from the fact that you can only use vectorize with scalar function as pointed out by @jotasi.
It must be pretty silly but I do not know what is going on. Could somebody enlighten me ? Is there a way to fix it ?