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

Lower memory usage #1

Open
StefanoD opened this issue Jun 10, 2018 · 5 comments
Open

Lower memory usage #1

StefanoD opened this issue Jun 10, 2018 · 5 comments
Labels
enhancement New feature or request

Comments

@StefanoD
Copy link
Owner

Using numpy.lexsort() results in very high memory usage. If an image is too big, this can result in a signal 9 abort.
If someone really needs this implementation for production, than this issue has to be addressed.

Pull requests are welcome.

@StefanoD StefanoD added the enhancement New feature or request label Jun 10, 2018
@StefanoD StefanoD changed the title Improve memory usage Lower memory usage Jun 10, 2018
@vitorsr
Copy link

vitorsr commented May 21, 2020

(Sorry for responding to an older thread.)

A clever trick I've used in the past is to put all the information in a single string, sortable hash, or even in distinct binary or decimal ranges in the order we'd like lexicographically sorted. Then,
.argsort() that array.

Note that finfo("float64").eps is 2e-16 (lots of room to spare). Equivalently, a 64-bit unsigned integer can hold 8 8-bit unsigned integers if you stack them along 8-bit-sized bands.

Anyways, thanks for this implementation. I will work on my own. I'll put a link to your repository as credit for the assistance. (I'd fork but I'll probably rewrite the history, which misses the point of forking. I'm still deciding.)

@StefanoD
Copy link
Owner Author

@vitorsr
Thanks for your insights and your credits! ☺
Actually, I implemented this algorithm only to proof to myself that I actually understood it and it was just for fun.
Currently I have no desire to rework the library. But pull requests are of course welcome, if there is any interest.
Of course you can start from scratch in your own repository. ☺

@coderforlife
Copy link

@vitorsr I have a library for this and it uses essentially what you say, however it is slightly more complex than that, but yeah, it works. With the additional fact that numpy now uses radix sort, it is quite a bit faster. See https://github.com/coderforlife/histmatch.

@StefanoD
Copy link
Owner Author

@coderforlife
Thx for your comment.
Your link is not working.
Why did you look for an another lib when your lib did the work? Just curious. 🙂

@coderforlife
Copy link

I was actually searching for the asymptotic memory usage of lexsort (I think the search was simply lexsort memory usage) and this issue was the first search result! I didn't even search for exact histogram equalization, just found this one randomly.

The link didn't work since it was private since it includes some thing I am working on publishing a paper about. However, at this point the paper is being submitted very soon so not much of a risk.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants