04-10-2015 01:03 AM
Hi,
I just realised that we have a HSL32 datatype. Since we never access the data directly, it makes little sense to me.
The only reason I could see is to speed up some functions by avoiding implicit internal converrsion (I know Color Spectrums work in HSL), but thats it..
Has anyone ever experimented with this (is this something to really consider when looking for a speedup?), or some insight in why this exists?
Thanks,
Birgit
04-10-2015 03:34 PM
Hi Birgit.
I have never done any profiling - so I cannot tell if using HSL instead of RGB speeds up any piece of code.
My favourate usage: When checking colors I prefer to check the hue values of some adjacent pixels (which by the way only makes sense if these pixels have a certain brightness or luminance). This is much easier than doing a test in the RGB colour plane.
When specifying custom colors (in Windows or in LabVIEW running on Windows) you can specify a custom color by RGB or by HSL. From this you can estimate that the HSL color space is frequently used.
Further insight why it exists: As you use NI Vision you could have a look at the NI Vision Concepts Help or wikipedia, of course.
04-10-2015 05:32 PM - edited 04-10-2015 05:33 PM
Thanks.
I've done profiling today. So.. HSL can indeed speed up some things.
Since there is an (ugly) mapping from RGB to HSL, any algorithm wirtten for HSL can work in RGB and vice versa... but I agree, HSL is much nicer. Especiallyas it was designed to do color comparisions much more "naturally".
The RGB-HSL typecast is done internally in functions that are based on ColorLearn (splits the HSV into n bins, etc). And it is quite a costly transformation, and responsibly for the majority of computational cost of those algorithms.
So if you're doing it explicitely, you're not really losing time.. you're just moving the function call around a bit. But you can potentionally save a lot of time if you have to work with the same image on multiple color operations.
(And if you're trying to optimize for this stuff... keep in mind that any display causes an internal typecast to RGB).