yuv422->rgb32 컨버팅하여 출력하였더니 green이 출력이 안되는데요 확인좀 부탁드립니다.

biokk의 이미지

캠에서 나오는 yuv422을 rgb32로 컨버팅했는데요 영상을 확인해서보면 초록색이 표현이 되지 않고 있는데요

어디부분을 손봐야 하나요?

G값이 표현되지 않아서 전체적인 이미지가 보라색 바탕으로 띄면서 영상이 나오고 있습니다.

y, cb, cr 계산 순서를 바꿔봤는데도 어디서 원인인지 잘 모르겠네요..

검토좀 부탁드립니다.

#define FLOAT_MANTISSA_BITS 23

#define FLOAT_MANTISSA_MASK ((1<<(FLOAT_MANTISSA_BITS))-1)
/* Non-negative float values */
#define Float2Int(_flt_, _int_) \
(*((float *)(&(_int_)))=(_flt_)+((float)(1<<(FLOAT_MANTISSA_BITS))), (_int_)&=FLOAT_MANTISSA_MASK)

void CImage::YUV422ToRGB32(unsigned char *pbYUV, unsigned char *pbRGB, int nWidth, int nHeight)
{
float Y0, Cb, Y1, Cr;
float R0, G0, B0, R1, G1, B1;
float B_Cb128,R_Cr128,G_CrCb128;
int r0, b0, g0, r1, b1, g1;

int precalc_xy_raw = 0;
int precalc_xy = 0;

for (int i=0;i {
// optimized code for YCbCr to RGB conversion
Cb = (float)pbYUV[precalc_xy_raw++]-128.0f;
Y0 = 1.164f * ((float)pbYUV[precalc_xy_raw++]-16.0f);
Cr = (float)pbYUV[precalc_xy_raw++]-128.0f;
Y1 = 1.164f * ((float)pbYUV[precalc_xy_raw++]-16.0f);

R_Cr128 = 1.596f*Cr;
G_CrCb128 = -0.813f*Cr - 0.391f*Cb;
B_Cb128 = 2.018f*Cb;

R0 = Y0 + R_Cr128;
G0 = Y0 + G_CrCb128;
B0 = Y0 + B_Cb128;

R1 = Y1 + R_Cr128;
G1 = Y1 + G_CrCb128;
B1 = Y1 + B_Cb128;

if (R0<0.0f) R0=0.0f;
if (G0<0.0f) G0=0.0f;
if (B0<0.0f) B0=0.0f;

if (R0>255.0f) R0 = 255.0f;
if (G0>255.0f) G0 = 255.0f;
if (B0>255.0f) B0 = 255.0f;

if (R1<0.0f) R1=0.0f;
if (G1<0.0f) G1=0.0f;
if (B1<0.0f) B1=0.0f;

if (R1>255.0f) R1 = 255.0f;
if (G1>255.0f) G1 = 255.0f;
if (B1>255.0f) B1 = 255.0f;

Float2Int(R0, r0);
Float2Int(G0, g0);
Float2Int(B0, b0);

Float2Int(R1, r1);
Float2Int(G1, g1);
Float2Int(B1, b1);

pbRGB[precalc_xy++] = (unsigned char)b0;
pbRGB[precalc_xy++] = (unsigned char)g0;
pbRGB[precalc_xy++] = (unsigned char)r0;
precalc_xy++;

pbRGB[precalc_xy++] = (unsigned char)b1;
pbRGB[precalc_xy++] = (unsigned char)g1;
pbRGB[precalc_xy++] = (unsigned char)r1;
precalc_xy++;
}
}

mirheekl의 이미지

브레이스 짝이 맞지 않아 보입니다. code 태그를 사용해보세요.

다른 사람이 해둔 것을 찾아 비교해보시는 것도 좋겠습니다.

http://stackoverflow.com/questions/8042563/correct-yuv422-to-rgb-conversion

http://stackoverflow.com/questions/6959275/c-sharp-convert-yuv-422-to-rgb

http://forums.parallax.com/showthread.php/135357-Converting-YUV-to-RGB

--

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.