全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:1304
推到 Plurk!
推到 Facebook!

我想請問一下

答題得分者是:阿信
dicky9055
一般會員


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

發送簡訊給我
#1 引用回覆 回覆 發表時間:2006-08-02 19:56:26 IP:211.76.xxx.xxx 訂閱
我想請問一下<br />要如何框出圖片上的文字呢??<br />ex<br />

我要將其文字框出
ex


我只知道要利用水平和垂直投影
但不太了解要怎麼做~
麻煩大家教我
謝謝
dicky9055
一般會員


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

發送簡訊給我
#2 引用回覆 回覆 發表時間:2006-08-02 20:00:09 IP:211.76.xxx.xxx 訂閱
我想請問一下
要如何框出圖片上的文字呢??
ex



我要將其文字框出
ex


我只知道要利用水平和垂直投影
但不太了解要怎麼做~
麻煩大家教我



dicky9055
一般會員


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

發送簡訊給我
#3 引用回覆 回覆 發表時間:2006-08-02 20:02:40 IP:211.76.xxx.xxx 訂閱
再補一下
下面是我用bcb寫的程式
我想請問一下
要如何框出圖片上的文字呢??
我程式框出來會變成
原始圖


我程式框出來的

是那出問題了呢~€

[code]
下面是我的程式
long* ProjectH = new long[Form1->Image1->Width];
long* ProjectV = new long[Form1->Image1->Height];
ZeroMemory(ProjectH, sizeof(long)*Form1->Image1->Width);
ZeroMemory(ProjectV, sizeof(long)*Form1->Image1->Height);

long Vmax=0,Hmax=0;
Byte *ptr;

for(int row=0;row<Form1->Image1->Height;row )
{
ptr=(Byte*)Form1->Image1->Picture->Bitmap->ScanLine[row];
for (int col=0;col<Form1->Image1->Width;col )
{
if (ptr[col*3]==0)
{
ProjectV[col] ;
ProjectH[row] ;
if(ProjectV[col]>Vmax)Vmax=ProjectV[col];
if(ProjectH[row]>Hmax)Hmax=ProjectH[row];
}
}
}

int startlocationH[100];
int endlocationH[100];
ZeroMemory (startlocationH,sizeof(int)*100);
ZeroMemory (endlocationH,sizeof(int)*100);
int count=0;
bool bStrat=false;
for(int i=0 ; i<Form1->Image1->Height ; i )
{
if(ProjectV[i]>0 && bStrat==false)
{
startlocationH[count]=i;
bStrat = true;
}

if(ProjectV[i]==0 && bStrat==true)
{
endlocationH[count]=i;
bStrat = false;
count ;
continue;
}
}



int startlocationW[100];
int endlocationW[100];
ZeroMemory (startlocationW,sizeof(int)*100);
ZeroMemory (endlocationW,sizeof(int)*100);
bStrat=false;
count=0;
for(int i=0 ; i<Form1->Image1->Width ; i )
{
if(ProjectH[i]>0 && bStrat==false)
{

startlocationW[count]=i;
bStrat = true;
}

if(ProjectH[i]==0 && bStrat==true)
{
endlocationW[count]=i;
bStrat = false;
count ;
continue;
}
}


for (int i=0; i<100;i )
{
if (startlocationW[i]==endlocationW[i] && startlocationH[i] == endlocationH[i])
continue;
Image1->Canvas->Pen->Style=psSolid;
Image1->Canvas->Pen->Color = clRed;
//框線
Image1->Canvas->MoveTo( startlocationH[i],startlocationW[i]); //左線的起始點
Image1->Canvas->LineTo( startlocationH[i],endlocationW[i]); //線的終點

Image1->Canvas->MoveTo( startlocationH[i],startlocationW[i]); //上線的起始點
Image1->Canvas->LineTo( endlocationH[i],startlocationW[i]); //線的終點

Image1->Canvas->MoveTo( endlocationH[i],startlocationW[i]); //右線的起始點
Image1->Canvas->LineTo( endlocationH[i],endlocationW[i]);

Image1->Canvas->MoveTo( startlocationH[i],endlocationW[i]); //線的起始點
Image1->Canvas->LineTo( endlocationH[i],endlocationW[i]);

}
delete [] ProjectV;
delete [] ProjectH;
[/code]
CoffeeX
中階會員


發表:18
回覆:121
積分:72
註冊:2005-02-18

發送簡訊給我
#4 引用回覆 回覆 發表時間:2006-08-02 21:34:54 IP:140.125.xxx.xxx 未訂閱
------
=.=???
CoffeeX
中階會員


發表:18
回覆:121
積分:72
註冊:2005-02-18

發送簡訊給我
#5 引用回覆 回覆 發表時間:2006-08-02 21:35:53 IP:140.125.xxx.xxx 未訂閱
------
=.=???
CoffeeX
中階會員


發表:18
回覆:121
積分:72
註冊:2005-02-18

發送簡訊給我
#6 引用回覆 回覆 發表時間:2006-08-02 21:37:10 IP:140.125.xxx.xxx 未訂閱
------
=.=???
阿信
版主


發表:111
回覆:983
積分:813
註冊:2005-03-10

發送簡訊給我
#7 引用回覆 回覆 發表時間:2006-08-04 17:45:13 IP:61.66.xxx.xxx 未訂閱

程式我不會寫 我只看邏輯
水平和垂直投影我不知道 我說我直觀的想法

你的文字在平面上是連續的 一體的
相對比較簡單
如果是要判斷i,j 或是中文字
就會變的複雜

用水平掃描
看到黑點記下來 起點跟終點(就是邊界)
可能會有好幾組 最多是圖片水平畫素的1/2
下一行 一樣記下來

若是某一組在下一行完全沒有連接
表示這一組已被掃描完 把它存起來

判斷有沒有兩行都是黑點的
若有表示是同一組的
把這兩行集合在一起
(就是刪除1組 更新上下左右邊界)
再判斷這一行這一組終點前
有沒有任何上一行的起點落在這個範圍
若有集合成一組

全部掃完 各組做運算垂直邊界水平邊界
框起來

系統時間:2024-05-10 4:48:59
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!