V
V
vasIvas2015-10-21 21:27:24
css
vasIvas, 2015-10-21 21:27:24

What are the fastest color conversion libraries?

It is necessary to distill rgb => hsl, hsl => rgb, rgb => hsv, hsv => rgb as quickly as possible.
Surely someone had a similar task and he measured, or somewhere he found out about the speed of the
work of various libraries, if there are any at all, and this someone can share this data, I will be very happy.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey, 2015-10-21
@vasIvas

about the speed of various libraries

Actually, there is a simple formula and it ... well, it seems to work the same for everyone within the same programming language.

A
Alexander, 2015-10-22
Madzhugin @Suntechnic

Stop. There is nothing to write. There's a simple formula and you need two unfortunate functions. What speed are you going to fight for?
oceansites.ru/pallete3/?file=k3.jpg - there, on each hit, calculation of a bunch of colors in rgb->xyz->lab, cie2000, rgb->hsv calculations. Everything is on the brake PHP and stuck together on the knee. What kind of brakes? Do you want to overtake every pixel in hsv? Even this is not a big problem. What the hell is a library for?
On HSV in puff:

function RGB2HSV($rgb) {
        
        foreach ($rgb as $C=>$V) {
            $rgb[$C] = $V/255;
        }
        
        $MAX = max($rgb['R'], $rgb['G'], $rgb['B']);
        $MIN = min($rgb['R'], $rgb['G'], $rgb['B']);
        
        if ($MAX == $MIN) {
            $HSV['H'] = 0;
        } elseif ($MAX == $rgb['R']) {
            $HSV['H'] = 60*(($rgb['G'] - $rgb['B'])/($MAX - $MIN));
            if ($rgb['B'] > $rgb['G']) {
                $HSV['H'] = $HSV['H']+360;
            }
        } elseif ($MAX == $rgb['G']) {
            $HSV['H'] = 60*(($rgb['B'] - $rgb['R'])/($MAX - $MIN))+120;
        } else { // if ($MAX == $rgb['B'])
            $HSV['H'] = 60*(($rgb['R'] - $rgb['G'])/($MAX - $MIN))+240;
        }
        
        if ($MAX == 0) {
            $HSV['S'] = 0;
        } else {
            $HSV['S'] = 1-$MIN/$MAX;
        }
        
        $HSV['V'] = $MAX;
        
        return $HSV;
    }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question