图像颜色错误 [英] Image has wrong colors

查看:55
本文介绍了图像颜色错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用C#2005编写的Windows窗体程序。

我不断通过来自摄像机的TCP读取数据流

(NTSC)。

当我拥有一帧的所有数据时,我更新了一个图片框(pbVideo),如

这个:


pbVideo.Image = (位图)Bitmap.FromStream(新的MemoryStream(m_ImageBuff,0,

m_TotalImageBytes),true,true);

或者这个
pbVideo。 Image =(Bitmap)Bitmap.FromStream(new MemoryStream(m_ImageBuff,0,

m_TotalImageBytes));


除了颜色错误外,一切都按预期工作。例如,

应该看起来是黄色的东西是绿松石,那些应该是蓝色或橙色的东西显示为红色或橙色。


数据流采用mjpeg格式 - 我只是一次挑出一帧。

任何想法或建议都会受到赞赏......


谢谢,

Joe

I have a Windows form program written in C# 2005.
I continually read a stream of data via TCP that comes from a video camera
(NTSC).
When I have all the data for one frame I update a picturebox (pbVideo) like
this:

pbVideo.Image = (Bitmap)Bitmap.FromStream(new MemoryStream(m_ImageBuff, 0,
m_TotalImageBytes), true, true);
or this
pbVideo.Image = (Bitmap)Bitmap.FromStream(new MemoryStream(m_ImageBuff, 0,
m_TotalImageBytes));

Everything works as expected except the colors are wrong. For example, the
things that should look yellow are turquoise and the things that should be
blue appear as red or orange.

The data stream is in mjpeg format - I just pick out the frames one at a time.
Any ideas or suggestions would be appreciated...

Thank you,
Joe

推荐答案

" Joe Thompson" < Jo ********* @ discussion.microsoft.com写信息

新闻:0B ******************* *************** @ microsof t.com ...
"Joe Thompson" <Jo*********@discussions.microsoft.comwrote in message
news:0B**********************************@microsof t.com...

>我有一个用C#编写的Windows表单程序2005.

我不断通过来自摄像机的TCP读取数据流

(NTSC)。

当我拥有所有的一帧的数据我更新了一个图片框(pbVideo)

喜欢

这个:


pbVideo.Image =(Bitmap)Bitmap .FromStream(新的MemoryStream(m_ImageBuff,0,

m_TotalImageBytes),true,true);

或者这个

pbVideo.Image =(位图)Bitmap.FromStream(新的MemoryStream(m_ImageBuff,0,

m_TotalImageBytes));


除了颜色错误外,一切都按预期工作。例如,



应该看起来是黄色的东西是绿松石,那些应该是蓝色或橙色的东西显示为红色或橙色。 />

数据流采用mjpeg格式 - 我只需在

时间选出一帧。

任何想法或建议都会赞赏...
>I have a Windows form program written in C# 2005.
I continually read a stream of data via TCP that comes from a video camera
(NTSC).
When I have all the data for one frame I update a picturebox (pbVideo)
like
this:

pbVideo.Image = (Bitmap)Bitmap.FromStream(new MemoryStream(m_ImageBuff, 0,
m_TotalImageBytes), true, true);
or this
pbVideo.Image = (Bitmap)Bitmap.FromStream(new MemoryStream(m_ImageBuff, 0,
m_TotalImageBytes));

Everything works as expected except the colors are wrong. For example,
the
things that should look yellow are turquoise and the things that should be
blue appear as red or orange.

The data stream is in mjpeg format - I just pick out the frames one at a
time.
Any ideas or suggestions would be appreciated...



什么是mjpeg格式?可能你应该使用Bitmap.LockBits和

在收到数据时复制数据。这样你只需保留一份

图像数据,并可以在显示时显示它。


Michael

What is mjpeg format? Possibly you should be using Bitmap.LockBits and
copying the data in as it is received. That way you keep only 1 copy of the
image data and can display it as it comes in.

Michael


嗨迈克尔,


感谢您的回复。我不确定格式 - 我相信它是24位

颜色。每个帧只是一个jpg文件。我正在尝试重写一个写在Linux机器上的应用程序

,它正确地显示颜色(我不是没有b $ b有这个代码)。


就我的应用程序而言,我一次收集字节1450,直到我得到一个完整的

帧。然后我立刻构建整个位图。我不熟悉

LockBits - 它有什么作用?我希望这只是一个彩色地图问题或

之类的东西。


谢谢你,

Joe
Hi Michael,

Thank you for the reply. I''m not sure of the format - I beleive it''s 24 bit
color. Each frame is just a jpg file. I am trying to rewrite an application
that was written on a Linux box and it displays the colors correctly (I don''t
have that code).

As far as my app goes, I gather the bytes 1450 at a time until I get a full
frame. Then I build the whole bitmap at once. I''m not familiar with
LockBits - what does it do? I was hoping it was just a color map problem or
something like that.

Thank you,
Joe


On Thu,2008年1月17日21:44:00 -0800,Joe Thompson

< Jo ********* @ discussion .microsoft.comwrote:
On Thu, 17 Jan 2008 21:44:00 -0800, Joe Thompson
<Jo*********@discussions.microsoft.comwrote:

感谢您的回复。我不确定格式 - 我相信它是24美元b $ b $

颜色。每个帧只是一个jpg文件。我正在尝试重写一个写在Linux机器上的

应用程序

并且它正确显示颜色(我不是
不要

有代码)。
Thank you for the reply. I''m not sure of the format - I beleive it''s 24
bit
color. Each frame is just a jpg file. I am trying to rewrite an
application
that was written on a Linux box and it displays the colors correctly (I
don''t
have that code).



你知道Linux代码是使用普通的JPEG库,还是为了这个目的而自定义编写了什么?b $ b?br />

我认为如果是前者,你使用的代码应该可行。但是

如果是后者,所有的赌注都已关闭。


我对M-JPEG格式的了解不够充分。具体细节。 />
但是,我知道许多视频格式都是_not_ RGB,并且对于你收到的数据来说,这可能是相同的。


老实说,你的问题听起来不像是这个新闻组中可能得到一个好答案的那种东西。你应该监视

线程以防万一,但我会看一个更具体的视频论坛

流媒体,甚至可能特定于你正在使用的设备(还有

,因为我知道没有明确定义的M-JPEG规格,所以你可能需要

设备特定的建议。

Pete

Do you know whether the Linux code is using a plain JPEG library, or has
something custom-written for the purpose?

I would think that if the former, the code you''re using should work. But
if the latter, all bets are off.

I don''t know enough about the M-JPEG format to comment with specifics.
However, I do know that many video formats are _not_ RGB, and it''s
possible that the same is true for the data you''re receiving.

To be honest, your question doesn''t sound like the sort of thing that''s
likely to get a good answer in this newsgroup. You should monitor the
thread just in case, but I would look to a forum more specific to video
streaming, perhaps even specific to the device you''re using (there is as
far as I know no well-defined specification for M-JPEG, so you may need
device-specific advice).

Pete


这篇关于图像颜色错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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