Getting the following error when using imresize(image, scale_factor=0.5, kernel="box", antialiasing=False):
Traceback (most recent call last):
File "/home/razor27/.local/share/JetBrains/Toolbox/apps/PyCharm-P/ch-0/183.5429.31/helpers/pydev/pydevd.py", line 1741, in
main()
File "/home/razor27/.local/share/JetBrains/Toolbox/apps/PyCharm-P/ch-0/183.5429.31/helpers/pydev/pydevd.py", line 1735, in main
globals = debugger.run(setup['file'], None, None, is_module)
File "/home/razor27/.local/share/JetBrains/Toolbox/apps/PyCharm-P/ch-0/183.5429.31/helpers/pydev/pydevd.py", line 1135, in run
pydev_imports.execfile(file, globals, locals) # execute the script
File "/home/razor27/.local/share/JetBrains/Toolbox/apps/PyCharm-P/ch-0/183.5429.31/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "/hdd/temp/image_downsample.py", line 82, in
main()
File "/hdd/temp/image_downsample.py", line 42, in main
rescaled_image = resize_func(source_img, scale)
File "/hdd/temp/zssr_imresize.py", line 43, in imresize
out_im = resize_along_dim(out_im, dim, weights, field_of_view)
File "/hdd/temp/zssr_imresize.py", line 139, in resize_along_dim
tmp_im = np.swapaxes(im, dim, 0)
File "/hdd/venv_py367_tf110/lib/python3.6/site-packages/numpy/core/fromnumeric.py", line 585, in swapaxes
return _wrapfunc(a, 'swapaxes', axis1, axis2)
File "/hdd/venv_py367_tf110/lib/python3.6/site-packages/numpy/core/fromnumeric.py", line 56, in _wrapfunc
return getattr(obj, method)(*args, **kwds)
numpy.AxisError: axis1: axis 1 is out of bounds for array of dimension 1
This appears to be due to the weights returned from the contributions() function, being one dimensional (line 39).
I'm using ubuntu 17, python 3.6.7, numpy 1.16.0, scipy 1.2.0.
The tested image is 512x512, one channel.
EDIT:
The same error occurs when using "cubic" and "linear" kernels for scale=1/3.0 (also only when antialiasing=False).
I believe this is because this code is for Python 2 and you are using 3.
The problem is with '/' sign which is interpreted as integer division in py2 and float in py3.
Just replace '/' with '//' or run it using py2.
Getting the following error when using imresize(image, scale_factor=0.5, kernel="box", antialiasing=False):
I'm using ubuntu 17, python 3.6.7, numpy 1.16.0, scipy 1.2.0. The tested image is 512x512, one channel.
EDIT: The same error occurs when using "cubic" and "linear" kernels for scale=1/3.0 (also only when antialiasing=False).