openstitching / lir Goto Github PK
View Code? Open in Web Editor NEWLargest Interior/Inscribed Rectangle implementation in Python.
License: Apache License 2.0
Largest Interior/Inscribed Rectangle implementation in Python.
License: Apache License 2.0
Would it be feasible to modify the algorithm to find the largest square instead of the largest unconstrained rectangle? More broadly, it would be great to be able to find the largest rectangle with a given aspect ratio and then specify 1:1 for squares.
bool_
First of all, many thanks for your project which help me a lot in my work. And I have a question that, is there any way to find the largest horizon rectangle inside a shape? I need a horizon rectangle to put some words in it.
Thanks,
Mi
Remove >=0.55.0
return one LIR per contour
https://github.com/lukasalexanderweber/lir/blob/main/lir_within_outline.py line 23
Hi @lukasalexanderweber ,
thanks for this fantastic project! It was very useful for my current project. However, I'm facing some problems due to numba. It's nothing wrong with your code, but with my project when I want to dockerize it. I don't know why, if I add the library numba @ git+https://github.com/numba/[email protected] to my requirements to be installed, my docker is getting ages to be build (I need to use that version because I need to use numpy 1.24 and that branch is the first to be compatible with numpy 1.24).
May I ask you, if is it possible to have a non-numba version? or simply, if you don't wanna have it here, how can I remove numba? just removing the @nb. above function definitions? what about nb.pranges? is just moving them to np.arange?
while installing through pip, it is throwing error as:
RuntimeError: Cannot install on Python version 3.11.1; only versions >=3.7,<3.11 are supported.
can anyone suggest how to use this package on Python version 3.11.1
np.unique(a)[::-1]
Arbitrary Orientation:
"To resolve this limitation, the solution is considered such that by
rotating the boundary of the shape in different directions, in each case the largest rectangle
is computed. Then, by comparing their area with each other, the largest rectangle is
specified in the desired direction."
Import duplicates from lir
bool_
Hello thank you for this library, np.Inf
is deprecated and replaced with np.inf
your code right now raise error on numpy 2.0.
The documentation doesn't discuss how to create the grid from an image. It took me a few tries to work this out
mask = np.full(img.shape, 0, dtype=np.uint8)
cv.drawContours(mask,[contour],contourIdx=-1, color=(255,255,255),thickness=-1)
grid = np.array(mask[:,:,1]) > 0
rect = lir.lir(grid)
This takes my original image, makes a copy that is all black, and fills it with the contour in white. We now convert the first dimension from uint8 to bool. This is needed because lir expects array(bool, 2d, C), not array(uint8, 3d, C). There may be other ways to do this, but this may help anyone stuck with:
TypeError: No matching definition for argument type(s) array(uint8, 3d, C)
hi,I'm interested in your project. He's a great help to me.Will you release the source code for lir_within_outline
Hi @lukasalexanderweber ,
I would like to clarify on algorithmic complexity of 'lir'. To be honest I've read both blog and original article, and could not find any detailed on what is O(...) for the algorithm we execute.
My goal is to execute 'lir' on a large grid - let it be 15000 x 18000.
The reason why I have such a large grid - first thing I translate original float number like '149.75' to be '14975'. Hopefully this will get more precise results. And the nature of this translation - an algorithm executes over integers.
Will appreciate any comments on this.
Thanks
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.