請問RGB轉YCRCB問題 |
答題得分者是:taishyang
|
jiaching
一般會員 發表:21 回覆:21 積分:8 註冊:2003-07-05 發送簡訊給我 |
我的程式出了一點問題 請各位大大幫我看一下 感激不盡~~~
這是我的程式碼
void __fastcall TForm1::Button10Click(TObject *Sender) { if (img1->Picture->Bitmap->Empty==true) ShowMessage("請載入圖檔!!"); Graphics::TBitmap *Bmp = new Graphics::TBitmap(); Byte *ptr; int r,g,b; float y,cr,cb; int i,j; int threshold; /*threshold=ScrollBar2->Position; Edit2->Text=ScrollBar2->Position; */ Bmp->Assign(img1->Picture->Bitmap); for(j=0;j發表人 - taishyang 於 2003/07/23 23:03:06 |
taishyang
站務副站長 發表:377 回覆:5490 積分:4563 註冊:2002-10-08 發送簡訊給我 |
jiaching您好:
引言:這一段如果加進去的話 img2的畫面就會全部黑色的而我的目的是希望CR 跟CB值落在一個範圍 比方說綠色 藍色 紅色 青色等等..而且一個顏色的CR跟CB值範圍是未知的 所以需要scrollbar來輔助選取在這裡我不太會用兩個scrollbar去調CR跟CB值 是都onChange嗎?將程式碼以[ code ]與[ /code ]包起來會比較方便閱讀,我已經幫您改過了 會變成全黑是正常的,因為您的程式就是這樣寫的 if((180達到您的目的 順心 <>~我也是在學習的階段,回答的不好請您多多見諒與指教~> 發表人 - |
jiaching
一般會員 發表:21 回覆:21 積分:8 註冊:2003-07-05 發送簡訊給我 |
感謝taishyung學長~~~
我的程式碼改成如下了
其中我用了兩個scrollbar 分別可以設定CR跟CB值
其中threshold1 threshold2 threshold3 threshold4我是用全域變數設定這樣好嗎?
而且使用第一個scrollbar是全白
在用第二個scrollbar就變全黑
請問問題出在哪?
新手上路 請多多指教
第一個scrollbar
void __fastcall TForm1::ScrollBar3Change(TObject *Sender) { if (img1->Picture->Bitmap->Empty==true) ShowMessage("請載入圖檔!!"); Graphics::TBitmap *Bmp = new Graphics::TBitmap(); Byte *ptr; int r,g,b; float y,cr,cb; int i,j; threshold1=ScrollBar3->Position-20; threshold2=ScrollBar3->Position 20; Bmp->Assign(img1->Picture->Bitmap); for(j=0;j發表人 - taishyang 於 2003/07/25 15:05:45 |
taishyang
站務副站長 發表:377 回覆:5490 積分:4563 註冊:2002-10-08 發送簡訊給我 |
jiaching學弟:
1.您的RGB轉YCrCb的公式弄錯了
您要用的應該是
Y = 0.299*R + 0.587*G + 0.114*B
Cb = - 0.1687*R - 0.3313*G + 0.5 *B + 128
Cr = 0.5 *R - 0.4187*G - 0.0813*B + 128
2.判斷式也有問題應該改成
if(cr>threshold1&&cr |
n38870035
一般會員 發表:2 回覆:14 積分:3 註冊:2003-07-19 發送簡訊給我 |
我想你的問題應該是尋找膚色吧!你的cb,cr應該先+128在做判斷才對
引言: 感謝taishyung學長~~~ 我的程式碼改成如下了 其中我用了兩個scrollbar 分別可以設定CR跟CB值 其中threshold1 threshold2 threshold3 threshold4我是用全域變數設定這樣好嗎? 而且使用第一個scrollbar是全白 在用第二個scrollbar就變全黑 請問問題出在哪? 新手上路 請多多指教 第一個scrollbarvoid __fastcall TForm1::ScrollBar3Change(TObject *Sender) { if (img1->Picture->Bitmap->Empty==true) ShowMessage("請載入圖檔!!"); Graphics::TBitmap *Bmp = new Graphics::TBitmap(); Byte *ptr; int r,g,b; float y,cr,cb; int i,j; threshold1=ScrollBar3->Position-20; threshold2=ScrollBar3->Position 20; Bmp->Assign(img1->Picture->Bitmap); for(j=0;j發表人 - taishyang 於 2003/07/25 15:05:45 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |