Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Index out bounds for axis 0? #24

Open
AI-ML-Enthusiast opened this issue Jun 27, 2020 · 1 comment
Open

Index out bounds for axis 0? #24

AI-ML-Enthusiast opened this issue Jun 27, 2020 · 1 comment
Assignees
Labels
bug Something isn't working
Projects

Comments

@AI-ML-Enthusiast
Copy link

@karolzak
Thank you very much for your awesome repo. I am using you code for getting patches and reconstructing from patches, but it produces the following error:
When I use plot_patches:
Image Shape: (3648, 5472, 3) ### original image
Image_crop shape: (169, 512, 512, 3)

Traceback (most recent call last):

 runfile('E:/PythonSampleCode/SliceMerge/slicemerge1.py', wdir='E:/PythonSampleCode/SliceMerge')
Reloaded modules: cv2, cv2.cv2, cv2.data
Image Shape: (3648, 5472, 3)
Image_crop shape:  (169, 512, 512, 3)
Traceback (most recent call last):

  File "<ipython-input-31-b244771ea495>", line 1, in <module>
    runfile('E:/PythonSampleCode/SliceMerge/slicemerge1.py', wdir='E:/PythonSampleCode/SliceMerge')

  File "C:\ProgramData\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 786, in runfile
    execfile(filename, namespace)

  File "C:\ProgramData\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 110, in execfile
    exec(compile(f.read(), filename, 'exec'), namespace)

  File "E:/PythonSampleCode/SliceMerge/slicemerge1.py", line 195, in <module>
    org_img_size=(x.shape[0], x.shape[1]), stride=256, size=256) # required - original size of the image

  File "E:/PythonSampleCode/SliceMerge/slicemerge1.py", line 110, in plot_patches
    axes[i, j].imshow(img_arr[jj])

IndexError: index 169 is out of bounds for axis 0 with size 169

when I use reconstruct_from_patches:

    stride=256) # use only if stride is different from patch size

  File "E:/PythonSampleCode/SliceMerge/slicemerge1.py", line 166, in reconstruct_from_patches
    ] = img_arr[kk, :, :, layer]

IndexError: index 169 is out of bounds for axis 0 with size 169

The crop size is 512 and stride is 256

Is there any suggestion?

@karolzak
Copy link
Owner

Hi @IbrahimLearning !
Thanks for submitting this feedback1
Just checked and indeed there's a problem with get_patches function. Because of how it is implemented right now it will only work for square images as input. It's an obvious mistake...
I'm marking this as a bug and will update this thread once it's fixed.

@karolzak karolzak self-assigned this Jun 28, 2020
@karolzak karolzak added the bug Something isn't working label Jun 28, 2020
@karolzak karolzak added this to To do in Release 1.0 via automation Jul 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Release 1.0
  
To do
Development

No branches or pull requests

2 participants