Open denis-bz opened 2 years ago
Hey Denis,
Thanks for writing this. I haven't looked at this project in a long time and it was fun getting it working again.
I wrote this package with Linux in mind, but these days I'm using a macbook. Just like you, I'm finding it's not really Mac friendly. In a separate project I've had a difficult time getting OpenMP to work well enough with Clang. It's definitely possible to get those -fopenmp
compile args working on your mac, but it takes a lot more work than it should.
You can get this project working mostly in its current state by omitting some compile args and turning off some options with the flags setup.py provides. I made some changes to help you get started in a separate branch.
Here's a list of things I think are going wrong for you to keep my thoughts organized:
--no-chroma-lut
.atan2
approximation, for example, and the lightness value lookup table. The final compile command I landed on looks like this: python setup.py build_ext --cythonize --no-chroma-lut --no-hue-atan2-approx --no-light-lut --inplace
. You can omit --inplace
depending on how you're trying to install things.dev-requirements.txt
.When I run the tests with these changes I get two failures for two tests which are frankly not well written and aren't a huge concern. So the behavior of the package is fine with these changes. HOWEVER, disabling these optimizations and especially not compiling with OpenMP is a shame. It's a lot slower than it should be, as I can only generate 5 FPS in my "melonize" example given a ~1080p input image where I'd usually expect something closer to 24 FPS. I'd revisit this project to make the build process more portable and to improve performance on more platforms if I thought people were out there using it, but I think this project fits a really specific niche that makes that unlikely.
Bytheway there's another husl in https://github.com/mwaskom/seaborn/blob/master/seaborn/external/husl.py any comments ?
That code comes from another old project which I am familiar with. I worked with it to validate this project in its early stages. The goals of these two projects are pretty different. nphusl
is supposed to work with images, whereas I get the sense that most people are using the HuSL color space to automatically generate color palettes and things like that. Basically, when I tried to use the existing HuSL libraries to do image processing with this fancy color space (i.e. the stuff in the README) I found that they were much too slow. It's not really the fault of those projects it's more that they weren't designed to convert millions of color values back and forth between the HuSL and RGB color spaces. Also this project sacrifices a (small) amount of precision to make things go faster.
Hope that helps!
Tad, that does the trick, thanks ! (lovely clean code, I have a lot to learn)
A general? problem is that max_chroma( L, h )
looks way too high,
colorspacious( [L, max_chroma( L, h ), h], "CIELCh", "sRGB1" )
can have rgb < -5
but roundtrip LCh -> sRGB1 -> LCh works ??
17mar: deletd yesterday's silly plot
NOT an nphusl issue, but it seems that nphusl lch and colorspacious LCh JCh -> 3 different chromas ? Just running the corners of the RGB cube gives
rgb: (8, 3)
[[ 0 0 0 0 255 255 255 255]
[ 0 0 255 255 0 0 255 255]
[ 0 255 0 255 0 255 0 255]]
{ nphusl__rgb_to_lch max 179 at [1 0 0]
[[ 0 32 88 91 53 60 97 100]
[ 0 130 135 72 179 137 107 0]
[ 0 266 128 192 12 308 86 20]]
}
{ cspace_rgb_LCh max 133 at [0 0 1]
[[ 0 32 88 91 53 60 97 100]
[ 0 133 119 50 104 115 96 0]
[ 0 306 136 196 40 328 103 302]]
}
{ cspace_rgb_JCh max 111 at [1 0 0]
[[ 0 21 80 84 47 54 96 100]
[ 0 90 106 59 111 97 80 3]
[ 0 258 137 198 32 330 106 211]]
}
sure confusing for unwary people (me) who expect them to be the same.
"Standard" definition of Chroma ? https://xkcd.com/927/
Tad, can you help me install nphusl with Cython on macos with clang ?
pip install nphusl
Ok, comment out
-fopenmp
and-ftree-vectorizer-verbose=2
insetup.py
thenpython3 setup.py build_ext --cythonize
Versions: Python 3.9.9 cython 0.29.28 Apple clang 11.0.0 pip 22.0.4
Bytheway there's another husl in https://github.com/mwaskom/seaborn/blob/master/seaborn/external/husl.py any comments ?
Thanks, cheers -- denis