用 C++ 绘制直方图RGB 值
我已经获得了图片中每个像素的 RGB 值,现在我想做的是根据 RGB 绘制直方图。所以会有 3 条线(蓝、绿、红)根据像素值上下移动。但尽管如此,我不知道如何找到解决办法。有什么我可以利用的指导吗?谢谢你!
PS:我使用的是 C++ 项目应用程序,而不是 C++ 控制台应用程序。
编辑:我正在使用 Microsoft Visual Studio 2010
编辑:我尝试绘制 X 和 Y 轴。
我知道 Y 可以保持不变,但在 X 轴上,X 轴必须在 Y 轴上向上显示 RGB 值。有什么办法可以绕过它吗?
抱歉,如果我听起来很困惑,希望你明白我的意思。
I've gotten the RGB values of each and every single pixel in the picture, now what i will like to do is to plot a histogram based on the RGB. So there will be 3 line(Blue,Green,Red) going up and down depending on the pixel value. But despite that, i do not how to find a way to go about it. Is there any guidance i can make use of? Thank you!
P.S : I am using C++ Project Application, not C++ Console Application.
Edit: I am using Microsoft Visual Studio 2010
Edit: I tried plotting a X and Y axis.
I know the Y can stay constant, but on the X axis, the X axis must show the RGB values while going up the Y axis. Is there any way to go around it?
Sorry if i sound confused, hopefully you get what i mean.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
函数
MoveTo
和LineTo
用于在Windows中画线,通常响应WM_PAINT消息。在调用它们之前,请在 DC 中选择一支适当颜色的笔。您需要将直方图值缩放到 Y 刻度。选择最大 Y 值,并对每个直方图值使用 y = histogram[x] * height / maxY。
The functions
MoveTo
andLineTo
are used to draw lines in Windows, usually in response to the WM_PAINT message. Select a pen of the appropriate color into the DC before calling them.You'll need to scale the histogram values to the Y scale. Choose a maximum Y value, and for each histogram value use
y = histogram[x] * height / maxY
.正如我从你的问题中了解到的,你是此类任务的初学者。在这种情况下,我向您推荐一些第三方 GUI 库,它可以为您完成大部分工作。最好的选择可能是 Qt by Nokia(Visual Studio 插件可用)和名为的免费库QWT 基于 Qt,非常适合绘制直方图、频谱图和许多其他技术绘图。至少你可以浏览源代码并启发自己如何以自己的方式去做。
当然,您可以使用本机 Windows API (GDI+),但这确实很痛苦。
As I can understand from your question you are a beginner in such tasks. In such a case I recommend you to us some 3rd party GUI library which does most of work for you. The best choice is probably Qt by Nokia (Visual Studio add-in is available) and the free library called QWT based on Qt which is perfectly suitable for plotting histograms, spectrograms and a lot of other technical plotting. At least you can go through the source code and inspire yourself how to do it your own way.
Of course you can do it by using native Windows API (GDI+), but it is really a pain.