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

BCB二值化

 
egg39383
一般會員


發表:3
回覆:2
積分:1
註冊:2006-12-18

發送簡訊給我
#1 引用回覆 回覆 發表時間:2006-12-31 14:16:22 IP:140.128.xxx.xxx 訂閱
以下是我的二值化的程式,但是當我RUN時它卻出現錯誤,可是我找不到它問題出在哪?

大大可以幫我看一下嗎?

//---------------------------------------------------------------------
#include
#pragma hdrstop
#include "SDIMain.h"
#include "About.h"
//---------------------------------------------------------------------
#pragma resource "*.dfm"
TSDIAppForm *SDIAppForm;
//---------------------------------------------------------------------
__fastcall TSDIAppForm::TSDIAppForm(TComponent *AOwner)
: TForm(AOwner)
{
}
//---------------------------------------------------------------------
void __fastcall TSDIAppForm::ShowHint(TObject *Sender)
{
StatusBar->SimpleText = Application->Hint;
}
//---------------------------------------------------------------------
void __fastcall TSDIAppForm::ExitItemClick(TObject *Sender)
{
Close();
}
//---------------------------------------------------------------------
// eVision ImgThreshold sample program
// The document handles two images and a vector.
// Code to load image goes here
void __fastcall TSDIAppForm::OpenItemClick(TObject *Sender)
{
if (OpenDialog->Execute())
// User validated it
{
m_SrcImage.Load(OpenDialog->FileName.c_str());
m_bImageLoaded= (ESuccess());
if (m_bImageLoaded)
{
// Destination image must be of the same size as the origin image
m_DstImage.SetSize(&m_SrcImage);
Invalidate();
}
}
}
// - eVision ImgThreshold sample program
//---------------------------------------------------------------------
void __fastcall TSDIAppForm::SaveItemClick(TObject *Sender)
{
SaveDialog->Execute();
}
//---------------------------------------------------------------------
void __fastcall TSDIAppForm::About1Click(TObject *Sender)
{
AboutBox->ShowModal();
}
//---------------------------------------------------------------------
void __fastcall TSDIAppForm::FormCreate(TObject *Sender)
{
Application->OnHint = ShowHint;
// eVision ImgThreshold sample program
// Perform eVision initialization to improve the execution time of the first eVision call
Euresys::eVision::Initialize();
// Set the angle unit to degrees
ESetAngleUnit(E_ANGLE_UNIT_DEGREES);
m_bLButtonDown = FALSE;
m_bRButtonDown = FALSE;
// A red pen is used to draw the contour
m_pRedPen = new TPen;
m_pRedPen->Style = psSolid;
m_pRedPen->Color = clRed;
m_pRedPen->Width = 1;
// - eVision ImgThreshold sample program
}
//---------------------------------------------------------------------
// eVision ImgThreshold sample program
// This code is called each time the form need to be redrawn
void __fastcall TSDIAppForm::FormPaint(TObject *Sender)
{
if (!m_bImageLoaded)
return; // nothing else to do otherwise
// When the left mouse button is down, we display the thresholded image
if (m_bLButtonDown)
{
// Draw the destination image
m_DstImage.Draw(Canvas->Handle);
}
else
{
// Draw the origin image
m_SrcImage.Draw(Canvas->Handle);
}
// When the right mouse button is down, we display the contour
if (m_bRButtonDown)
{
// Use the red pen
TPen *OldPen = Canvas->Pen;
Canvas->Pen = m_pRedPen;
m_Contour.Draw(Canvas->Handle);
// Release the red pen
Canvas->Pen = OldPen;
}
}
// - eVision ImgThreshold sample program

//---------------------------------------------------------------------------
// eVision ImgThreshold sample program
// This is the message handler of the mouse down event
void __fastcall TSDIAppForm::FormMouseDown(TObject *Sender, TMouseButton Button,
TShiftState Shift, int X, int Y)
{
if (Button == mbLeft)
m_bLButtonDown = TRUE;
else if (Button == mbRight)
m_bRButtonDown = TRUE;
// Same as a mouse move
FormMouseMove(Sender, Shift, X, Y);
}
// - eVision ImgThreshold sample program
//---------------------------------------------------------------------------
// eVision ImgThreshold sample program
// This is the message handler of the mouse up event
void __fastcall TSDIAppForm::FormMouseUp(TObject *Sender, TMouseButton Button,
TShiftState Shift, int X, int Y)
{
if (Button == mbLeft)
m_bLButtonDown = FALSE;
else if (Button == mbRight)
m_bRButtonDown = FALSE;
// Same as a mouse move
FormMouseMove(Sender, Shift, X, Y);
}
// - eVision ImgThreshold sample program
//---------------------------------------------------------------------------
// eVision ImgThreshold sample program
// This is the message handler of the mouse up event
void __fastcall TSDIAppForm::FormMouseMove(TObject *Sender, TShiftState Shift,
int X, int Y)
{
if (!m_bImageLoaded)
return; // Nothing to do otherwise
if(!(X < m_SrcImage.GetWidth()) || !(Y < m_SrcImage.GetHeight()))
return; // Cursor out of image
// Get the current pixel value
INT32 n32Threshold= *(PUINT8)m_SrcImage.GetImagePtr(X, Y);
if (m_bLButtonDown)
{
// Threshold the image
ImgThreshold(&m_SrcImage, &m_DstImage, n32Threshold);
if (EFailure())
{
m_bLButtonDown = FALSE;
m_bRButtonDown = FALSE;
return;
}
// Force a redraw (without background)
RedrawWindow(Handle, NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW);
}
else
{
// Redraw image
m_SrcImage.Draw(Canvas->Handle);
}
if (m_bRButtonDown)
{
// Disable tracing
ESetTraceMode(E_TRACE_SILENT);
// Build the contour
ImgContour(&m_SrcImage,
IMG_CONTOUR_ANTICLOCKWISE_CONTINUE_IF_BORDER,
X, Y, IMG_CONTOUR_BELOW_THRESHOLD,(UINT32)n32Threshold,
IMG_CONTOUR_CONNEXITY_8, &m_Contour);
//eEasyError
// Enable tracing
ESetTraceMode(E_TRACE_DISPLAY_MESSAGE);
// Reset error messages
EOk();
// Force a redraw (without background)
RedrawWindow(Handle, NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW);
}
}
// - eVision ImgThreshold sample program
//---------------------------------------------------------------------------
void __fastcall TSDIAppForm::FormDestroy(TObject *Sender)
{
// eVision ImgThreshold sample program
// Free memory
delete (m_pRedPen);
// - eVision ImgThreshold sample program
}
//---------------------------------------------------------------------------
void __fastcall TSDIAppForm::RampItemClick(TObject *Sender)
{
// eVision ImgThreshold sample program
// The Ramp button was added to the Menu resources
// Then the CThresholdView::OnRamp function was created, using Class Wizard
// Retrieve the image
if (!m_bImageLoaded)
return;
// Draw a grey ramp in the image
INT32 n32RampX= (m_SrcImage.GetWidth() - 256)/2, n32RampY= 40;
for (INT32 n32X= 0; n32X < 256; n32X )
{
for (INT32 n32Y= 0; n32Y < 10; n32Y )
{
*(EBW8*)(m_SrcImage.GetImagePtr(n32X n32RampX,
n32Y n32RampY))= (EBW8)n32X;
}
}
// Force an image redraw (no background)
RedrawWindow(Handle, NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW);
// - eVision ImgThreshold sample program
}
//---------------------------------------------------------------------------

void __fastcall TSDIAppForm::FormActivate(TObject *Sender)
{
MessageBox(NULL, "Load a graylevel image from the 'Images\\EasyImage' "
"folder. \n"
"Play with the mouse buttons and try the 'File/Ramp' menu.\n\n"
"Required licenses: - None in case of a precompiled sample\n\t\t"
"- EasyImage otherwise.",
"ImgThreshold", MB_APPLMODAL | MB_ICONINFORMATION | MB_OK);
}
//---------------------------------------------------------------------------
void __fastcall TSDIAppForm::FormClose(TObject *Sender,
TCloseAction &Action)
{
// Perform eVision termination
Euresys::eVision::Terminate();
}
//---------------------------------------------------------------------------

taishyang
站務副站長


發表:377
回覆:5490
積分:4563
註冊:2002-10-08

發送簡訊給我
#2 引用回覆 回覆 發表時間:2007-01-12 14:23:42 IP:59.124.xxx.xxx 未訂閱
你可以把有問題的程式碼節錄出來,這樣比較好分析問題在哪邊
網站上已經有相當多二值化的程式碼供您參考


dicky9055
一般會員


發表:20
回覆:48
積分:18
註冊:2006-08-02

發送簡訊給我
#3 引用回覆 回覆 發表時間:2007-01-17 21:15:55 IP:211.76.xxx.xxx 訂閱
嗯.寫的真的有點太多了
看的不是得懂了
太亂了..

friendlly
高階會員


發表:22
回覆:144
積分:103
註冊:2003-04-08

發送簡訊給我
#4 引用回覆 回覆 發表時間:2007-01-21 10:40:59 IP:59.112.xxx.xxx 訂閱
這程式沒問題.
執行時出錯....你有License嗎?有需要可以聯絡

egg39383
一般會員


發表:3
回覆:2
積分:1
註冊:2006-12-18

發送簡訊給我
#5 引用回覆 回覆 發表時間:2007-01-22 00:48:54 IP:61.67.xxx.xxx 訂閱

===================引 用 文 章===================
這程式沒問題.
執行時出錯....你有License嗎?有需要可以聯絡
?
@@大大可以給我License嗎
因為這關係所以沒辦法執行= ="
可以寄到我信箱給我嗎??
mib050@yahoo.com.tw
謝大大^^
friendlly
高階會員


發表:22
回覆:144
積分:103
註冊:2003-04-08

發送簡訊給我
#6 引用回覆 回覆 發表時間:2007-01-23 09:06:27 IP:61.64.xxx.xxx 訂閱
license 是要買的..  沒辦法給你
還有...evision 的license是鎖硬體的

===================引 用 文 章===================

===================引 用 文 章===================

這程式沒問題.
執行時出錯....你有License嗎?有需要可以聯絡
?
@@大大可以給我License嗎
因為這關係所以沒辦法執行= ="
可以寄到我信箱給我嗎??
mib050@yahoo.com.tw
謝大大^^
系統時間:2024-11-23 7:45:27
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!