線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:978
推到 Plurk!
推到 Facebook!

我想要做一個程式同時擁有顯示直方圖和等化結果兩種功能

尚未結案
Teresa_Chang
一般會員


發表:41
回覆:42
積分:16
註冊:2004-05-04

發送簡訊給我
#1 引用回覆 回覆 發表時間:2004-11-30 01:35:51 IP:211.74.xxx.xxx 未訂閱
以下是我在這個網站看到有關直方圖的程式 但是我不太懂這個程式的作法 可以幫我解釋一下嗎    #include  #pragma hdrstop    #include "GetRGBHistogram0.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.dfm" TForm1 *Form1; //--------------------------------------------------------------------------- __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) { } //--------------------------------------------------------------------------- void __fastcall TForm1::FormCreate(TObject *Sender) { Form1->DoubleBuffered = true; } //---------------------------------------------------------------------------    void __fastcall TForm1::Exit1Click(TObject *Sender) { Close(); } //---------------------------------------------------------------------------    void __fastcall TForm1::Load1Click(TObject *Sender) { if ( OpenDialog1->Execute() ) { Image1->Picture->LoadFromFile(OpenDialog1->FileName); Image1->Top = 1; Image1->Left = 1; Graphics::TBitmap *bmp = new Graphics::TBitmap(); bmp->Width = Image1->Picture->Width; bmp->Height = Image1->Picture->Height; bmp->Canvas->Draw(0,0,Image1->Picture->Graphic); Image1->Picture->Bitmap->Assign(bmp); Image1->Refresh(); delete bmp; } } //--------------------------------------------------------------------------- void JpgToBmp(TImage *image) { Graphics::TBitmap *bmp = new Graphics::TBitmap();    bmp->Width = image->Picture->Width; bmp->Height = image->Picture->Height; bmp->Canvas->Draw(0,0,image->Picture->Graphic); image->Picture->Bitmap->Assign(bmp); image->Refresh();    delete bmp; }    void showRGBHistogram(TImage *image, TCanvas *canvas) { Byte * ptr; int rgb[3][256]={0}, max[3]={0}, r, g, b, gray, index;    image->Picture->Bitmap->PixelFormat = pf24bit; for (int row=0; rowPicture->Height; row++) { ptr = (Byte*) image->Picture->Bitmap->ScanLine[row]; index = 0; for (int col=0; colPicture->Width; col++) { b = ptr[index ]; g = ptr[index+1]; r = ptr[index+2]; rgb[0][b]++; rgb[1][g]++; rgb[2][r]++; index += 3; } } for (int x=0; x<256; x ) { for (int p=0; p<3; p ) { if ( rgb[p][x]>max[p] ) max[p] = rgb[p][x]; } } for (int p=0; p<3; p ){ float scale = (float)256 / max[p]; canvas->MoveTo(0, (int)(256-rgb[p][0]*scale)); for (int x=1; x<256; x ){ canvas->LineTo(x, (int)(256-rgb[p][x]*scale)); } } } void __fastcall TForm1::Button2Click(TObject *Sender) { JpgToBmp(Image1); showRGBHistogram(Image1, Image2->Canvas); } 發表人 - Teresa_Chang 於 2004/11/30 14:12:07
1666362
初階會員


發表:66
回覆:124
積分:43
註冊:2004-07-07

發送簡訊給我
#2 引用回覆 回覆 發表時間:2004-11-30 11:31:18 IP:202.132.xxx.xxx 未訂閱
請先看板規 把程式碼修改好  我是新手 多多指教 ^^
系統時間:2024-05-21 3:15:22
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!