如何在OpenFrameworks/OpenCV中用HSV颜色绘制正方形 [英] How to draw square with HSV color in OpenFrameworks / OpenCV

查看:115
本文介绍了如何在OpenFrameworks/OpenCV中用HSV颜色绘制正方形的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用OpenCv的OpenFrameworks项目.我有图像的色相和饱和度值的直方图.为了显示直方图,我正在根据直方图的值绘制一个灰色正方形的网格.为了更容易理解,我想在每个网格列下绘制一个框,它表示的色调.但是,鉴于HSV值,我如何指定绘制框的颜色?

I have a OpenFrameworks project that is using OpenCv. I have histogram of the hue and saturation values of my image. To show the histogram I am drawing a grid of gray square's based on the values from the histogram. To make it easier to understand I want to draw a box under each grid column the hue that it represents. But given the HSV values how do I specify the color to draw the box?

通常,您会使用ofSetColor或ofSetHexColor,但是它们是基于RGB的,我不知道RGB值.

Normally you would use ofSetColor or ofSetHexColor but those are RGB based, and I dont know the RGB values.

推荐答案

也许这只是更高版本提供的,但是您现在可以使用ofColor进行以下操作

Perhaps this only came in with a later version but you can now do the following using ofColor

ofColor c = ofColor::fromHsb( 0, 255, 255 ); // bright red
c.setHue( 128 ); // now bright cyan

ofColor c( 0, 0, 255 ); // vibrant blue
c.setSaturation( 128 ); // pale blue

ofColor c = ofColor_::setHsb(float hue, float saturation, float brightness)

然后您可以使用ofSetColor(c);

这篇关于如何在OpenFrameworks/OpenCV中用HSV颜色绘制正方形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆