简体   繁体   中英

Map angle to RGB color

This video shows what I think is a great visualization of gradient angle by mapping angle (in [-pi,pi]) to RGB color:

在此处输入图片说明

I would like to know if it is possible in OpenCV C++ to map a floating point value angle , whose range is -M_PI to M_PI , to an RGB value in some preset colorwheel. Thank you!

Look up hsv to rgb. H, or hue, is the angle you are looking for. You probably want full saturated values with maximum value, but if you turn s and v down a notch, the coding will look less artificial and computery.

Can you calculate this directly from the angle and the edge strength?

red   = edgeStrength * sin(angle);
green = edgeStrength * sin(angle + 2*M_PI / 3.); // + 60°
blue  = edgeStrength * sin(angle + 4*M_PI / 3.); // + 120°

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM