Group Abstract Group Abstract

Message Boards Message Boards

2
|
9.7K Views
|
2 Replies
|
7 Total Likes
View groups...
Share
Share this post:

Faster ways to hue shift an RGB? OpenCV in Python still 3x faster

POSTED BY: Kyle Keane
2 Replies

Bravo, this was really clever, thank you!

POSTED BY: Kyle Keane

Using ColorSeparate / ColorCombine is about 4x faster than your third solution:

In[1]:= testImage =  Image[ExampleData[{"TestImage", "Mandrill"}], "Real32"];

In[2]:= RepeatedTiming[
 r1 = ColorConvert[
    ImageApply[
     Function[{rgb}, MapAt[Function[{p}, Mod[p + .5, 1]], rgb, 1]], 
     ColorConvert[testImage, "HSB"]], "RGB"];]

Out[2]= {0.0460944, Null}

In[3]:= RepeatedTiming[r2 = (hsbList = ColorSeparate[testImage, "HSB"];
    ColorConvert[
     ColorCombine[{Mod[hsbList[[1]] + .5, 1], hsbList[[2]], 
       hsbList[[3]]}, "HSB"], "RGB"]);]

Out[3]= {0.0123619, Null}

In[4]:= ImageDifference[r1, r2] // MinMax

Out[4]= {0., 2.38419*10^-7}
POSTED BY: Piotr Wendykier
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard