Skip to content
This repository has been archived by the owner on Mar 31, 2023. It is now read-only.

slice function: None type not handled for rectangular images #31

Open
AkhilJPatil opened this issue Dec 24, 2019 · 2 comments
Open

slice function: None type not handled for rectangular images #31

AkhilJPatil opened this issue Dec 24, 2019 · 2 comments

Comments

@AkhilJPatil
Copy link

AkhilJPatil commented Dec 24, 2019

Hello Sam,

I have been using the image_slicer.slice() for some time now. Recently the input image dimensions changed and thus the new shape of input images have become rectangular now.
Current dimensions of new input images = 8235 * 10065 pixel (earlier the input images were square shaped with dimension in multiple of 183)
Expected output tile dimension = 183 * 183
So the number of tiles expected = 55 rows * 45 columns

I gave n=2475 (55 * 45) but the function sliced 2500 tiles of dimension 164*201 pixel, which is not the desired result in this case.

Can this (slicing the input images to a given number of tiles as rows and columns) be achieved using the slice function() ?
please suggest if its possible.

Best,
Akhil

@AkhilJPatil
Copy link
Author

Hello again,

I did some digging of the lib code and came across the slice() function definition.
def slice(filename, number_tiles=None, col=None, row=None, save=True):
which gave the answer to my query. I was not able to find anything related to this provision in the documents. May be the docs could be updated.

However, in the else block, the calculation of variable extra was throwing an error: unsupported operand type(s) for -: 'int' and 'NoneType' for obvious reason.
extras = (columns * rows) - number_tiles where number_tiles is None

I could get it working using a ternary operator as below
extras = (columns * rows) - 0 if number_tiles is None else number_tiles
I would keep this issue open with updated title instead of closing it and creating a new one.

Best,
Akhil

@AkhilJPatil AkhilJPatil changed the title slice function not compatible with rectangular images slice function: None type not handled for rectangular images Dec 25, 2019
@cromlyngames
Copy link

I just hit the same error (line 161 main.py)
You can delete the '-number_tiles ' bit, that code is only called if number_tiles is not defined with a value.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants