I am new to the python. I have a problem to convert this simple function in matlab to the python. Here is the original matlab code
function Cmode=my_map(image1)
[D,A,B] = size(image1)
crp = image1((1:D),(A:-1:1),(B:-1:1));
Cmode1 = max(crp,[],1);
Cmode = permute(Cmode1,[3 2 1]);
The input file is 3d matrix. I tried this but failed
def cmode(image1):
[D,A,B] = np.shape(image1)
crp = image1[(0,D),(A,-1,0), (B,-1,0)]
cmode1 = np.max(crp,[],1)
c = np.transpose( np.expand_dims(cmode1, axis=2), (2, 1, 0) )
return c
here is the error
crp = d3image[(0,D),(A,-1,0), (B,-1,0)]
IndexError: shape mismatch: indexing arrays could not be broadcast together with shapes (2,) (3,) (3,)
Any help will be appreciated. Thank you