|
Преобразование графического изображения в текст
A
ianoiyuaa a?aiy, n ?inoii ?enea ia?niiaeuiuo eiiiu?oa?ia, ia?iiiia eiee?anoai
eioi?iaoee aaiaeony n aoia?iuo iineoaeae ia iaaieoiua aenee eiiiu?oa?ia.
?acoiaaony yoi i?aiu ooiieoaeuiay ?aaioa. E auei au iaieioi eiaou a naiai
?anii?y?aiee i?ia?aiiiia n?aanoai, eioi?ia auei au niiniaii aini?eieiaou aoiaiia
ecia?a?aiea aieoiaioa, eioi?ia aiiaua aiai?y yaeyaony ea?oeieie, e
i?aia?aciauaaou aai a oaeno, ioa?anuaay i?e yoii ana eeoiea aaoaee ecia?a?aiey (
oaeea eae eeiee ?aciaoee, ia?aieaiey e o.i. ). Yoio aii?in aieioao iiiaea
oe?iu ii ?ac?aaioea i?ia?aiiiiai iaania?aiey e nae?an a ie?a ?ac?aaioaii
ianeieuei i?ia?aii aey ?aniiciaaaiey iaoeiiieniiai oaenoa. Ii yoi oieuei
ia?aeuiue yoai ia iooe ?aoaiey aaiiie caaa?e. Aaiiua i?ia?aiiiua i?iaoeou
?aniicia?o oaeno n aiaieuii aieuoie aa?iyoiinou? ioeaee i?e oneiaee
iaea?anoaaiiiai ecia?a?aiey. I oii, ?oiau ?aniiciaaaou ?oeiieniue oaeno iiea
aa?a ia i?eoiaeony e aiai?eou. Oaeu? ?ac?aaioee aaiiie i?ia?aiiiie nenoaiu
yaeyaony aaoaeuiia eco?aiea aaiiiai aii?ina e nicaaiea aeai?eoia, iicaiey?uaai
i?aia?aciauaaou a?aoe?aneia ecia?a?aiea a oaeno. Aaeinoaaiiia ioee?ea aaiiie
nenoaiu io ?ac?aaioaiiuo ?aiaa yoi oi, ?oi ?aniiciaaaou i?aanoieo ea?iaeeou. Yoe
ciaee eia?o nouanoaaiiia ioee?ea io i?eau?iie iai ee?eeeeou e eaoeineeo
neiaieia. O?a iaii oi, ?oi iie ninoiyo ec iii?anoaa ?acee?iuo oci?ia ioa?anuaaao
eaa? no?ieou ?aniiciaaaiea ia aii?ieneie?iaaiee ecia?a?aiey neiaiea n iiiiuu?
eaeie eeai ooieoee. Oioy caanu ii?ii iii?iaiaaou eniieuciaaou o?aeoaeuiua
i?aia?aciaaiey, n iiiiuu? eioi?uo ii?ii iienaou e?aia neieu oaiaii nei?iia
ecia?a?aiea. Ii oai?ey, iienuaa?uay i?eiaiaiea aaiiuo i?aia?aciaaiee yaeyaony
eiiia??aneie oaeiie e yaeyaony iaainooiiie. Nenoaia iaania?eaaao aaia neaie?iaaiiiai
ecia?a?aiey oaenoa ec a?aoe?aneiai oaeea, caienaiiiai a iaiii ec oi?iaoia: PCX,
BMP, WMF, JPEG, GIF. ?acia? ecia?a?aiey ia aie?ai i?aauoaou 3000 o 3000 oi?ae.
?a?ei neaie?iaaiey aie?ai auou aua?ai oae, ?oiau ?acia?u ioaaeuiiai neiaiea
(ea?iaeeoa) ia i?aauoae 30 ieenaeia e aue ia iaiaa 5 ieenaeia. Aiioneaaony
iaeeii no?ie e ai?eciioaee ia aieaa ?ai ia 6°. ?annoiyiea ia?ao ioaaeuiuie
no?ieaie oaenoa ia aie?ii auou iaiuoa 1/5 iaeneiaeuiie auniou ea?iaeeoa. Nenoaia
iaania?eaaao ?acaaeaiea aaaaaiiiai oaenoa ia ioaaeuiua no?iee e ia ioaaeuiua
neiaieu. ?acoeuoaoii ?aaiou yaeyaony aecoaeuiia ?acaaeaiea oaenoa ia no?iee e
neiaieu, a oae?a oaenoiaue oaee, niaa??auee eii?aeiaou ea?aiai auaaeaiiiai
neiaiea oaenoa a ii?yaea auaaeaiey. I?e ?acaaeaiee neiaieia nenoaia eniieucoao
i?aaeei ia?a?oaiey ea?iaeeoia, a niioaaonoaee n eioi?ui ioaaeuiue ea?iaeeo
aienuaaaony a aieaa eee iaiaa i?aaeeuiue eaaa?ao. Neaaiaaoaeuii, ia
aa?aioe?oaony, ?oi oaenou, ia?a?oaiea neiaieia eioi?uo ia niioaaonoao?o aaiiiio
i?aaeeo, aoaoo ?acaeaaouny ia neiaieu ei??aeoii. Oae?a a ea?anoaa aiiieiaiey e
ia?aaioea ecia?a?aiey nenoaia niiniaia auaaeyou ioaaeuii aa?oeeaeuiua e
ai?eciioaeuiua eeiee. Aaiiay aicii?iinou ii?ao auou eniieuciaaia aey aiaeeca
ecia?a?aiey ii ioaaeuiui eeieyi. Naaeaiu i?iaiua yenia?eiaiou ii aoeiiui
i?aia?aciaaieyi. Yoe i?aia?aciaaiey a aoaouai iaaua?o aaou iiiai iieaciiai a
iaeanoe ia?aaioee ecia?a?aiee. IBM - niaianoeiue ia?niiaeuiue eiiiu?oa? n i?ioanni?ii ia ie?a
Intel80486sx33, iauaiii ICO ia iaiaa 4 Ia. Iia?aoeiiiay iaiei?ea Windows 95, eeai Windows NT eee Windows
aa?nee 3.1 eee 3.11 a eiiieaeoa n MS-DOS aa?nee ia ie?a 3.30. I?ia?aiiiia
iaania?aiea aey neaia?a, iaania?eaa?uaa aicii?iinou nio?aiaiey neaie?iaaiiiai
ecia?a?aiey a iaiii ec oi?iaoia PCX, JPG, BMP, WMF. A ea?anoaa n?aau aey ?ac?aaioee aaiiie nenoaiu
aua?aia iia?aoeiiiay iaiei?ea Microsoft Windows. Yoi iaoneiaeaii oai, ?oi
Windows iiaaa??eaaao ?aaioo n a?aoe?aneeie ecia?a?aieyie ia o?iaia ?ac?aaio?eea
i?eei?aiee. Oai naiui ec ?aaiou enee??aaony aii?in i eiae?iaaiee naieo n?aanoa
ii ?aaioa n a?aoeeie. Anoanoaaiii nei?inou ?aaiou nenoaiu ni noaiaa?oiuie
a?aoe?aneeie n?aanoaaie iiiai ie?a, ?ai iaiin?aanoaaiiay caienu a aeaaiiaiyou,
ii ia aaiiii yoaia ?aaiou aii?in oie?aaony ia a nei?inou. Aey ?ac?aaioee
nenoaiu auea aua?aia n?aaa i?ia?aiie?iaaiey Borland Delphi i?iecaianoaa oe?iu
Borland International USA, California. Delphi i?aanoaaeyao niaie n?aao,
iiaaa??eaa?uo? aecoaeuiia i?iaeoe?iaaiea i?eei?aiee aey Windows. I?e yoii
eioa?oaen iieuciaaoaey nicaaaony iooai eiiaeie?iaaiey e ?aaaeoe?iaaiey
noaiaa?oiuo eiiiiiaioia (oi?i (ieii), iai?, iieae aaiaa, noaoe?aneeo oaenoia,
nieneia ?acee?iie oi?iu, ye?aiiuo eiiiie e o.i.), eia?ueony a noaiaa?oiie
aeaeeioaea aecoaeuiiai eiino?oeoi?a. N?aaa aecoaeuiiai i?ia?aiie?iaaiey aua?aia
iioiio, ?oi iia iaania?eaaao aicii?iinou iaeneiaeuii i?inoiai, auno?iai e
ea?anoaaiiiai nicaaiey noaiaa?oiuo o?aaiaioia i?ia?aiiu. Ii n?aaiaie? n
a?oaeie nenoaiaie aecoaeuiiai i?ia?aiie?iaaiey (Visual FoxPro, DBase for
Windows, Microsoft Visual Basic, Microsoft Visual C++, Gupta SQLWindows e i?.)
Delphi eiaao neaao?uea i?aeiouanoaa. Ana auoaia?a?eneaiiua nenoaiu yaey?ony
eioa?i?aoaoi?aie, oi anou aey auiieiaiey nicaaiiuo a ieo i?ia?aii o?aaoaony
caa?ocea iiaoey eioa?i?aoaoi?a ycuea, eeai inaaaieiiieeyoi?aie, eioi?ua
oi?ie?o?o i?ia?aiio a aeaa EXE-iiaoey, niaa??auaai inaaaieia i?ia?aiiu
(ii?aaaeaiiui ia?acii caeiae?iaaiiue oaeno) e iiaoeu eioa?i?aoaoee, auiieiy?uaai
yoio inaaaieia. A Delphi ?acoeuoaoii aaia?aoee i?iaeoa yaeyaony i?ia?aiia ia
ycuea Object Pascal, eioi?ue eiiieee?oaony eiiieeyoi?ii Borland Pascal 8.0 a EXE
- iiaoeu, eeai DLL - aeaeeioaeo. EXE - iiaoeu niaa??eo i?ioanni?iue eia e ii?ao
auou caiouai iaiin?aanoaaiii ec Windows. DLL-aeaeeioaeo ii?ao eniieuciaaou e?aia
Windows - i?eei?aiea, a oii ?enea iaienaiiia ia a?oaii ycuea. Aaenoaeoaeuiay
eiiieeyoey iaania?eaaao cia?eoaeuii aieuoaa auno?iaaenoaea e aaao auea?uo ii
iaiyoe e aeneiaiio i?ino?ainoao (anee o?eouaaou ?ano?nu, iio?aaeyaiua iiaoeai
eioa?i?aoaoee a eioa?i?aoe?o?ueo nenoaiao). A ioee?ea io ?yaa nenoai (Visual
FoxPro, DBase for Windows, Microsoft Visual Basic) Delphi iaania?eaaao
aicii?iinou aecoaeuiiai eiino?oe?iaaiey ia oieuei eioa?oaena, ii e ?yaa
noaiaa?oiuo iiaoeae i?ia?aiiu, ia ioia?a?aaiuo ia ye?aia. E?iia oiai, Delphi
eiaao noaiaa?oiua n?aanoaa nicaaiey nianoaaiiuo ye?aiiuo e iaaeaeiuo
eiiiiiaioia, ?oi iicaieyao iaia?aie?aiii ?anoe?you iaai? iauaeoia, eniieuciaaiea
eioi?uo aicii?ii a e?aii i?iaeoa e ie?ai ia ioee?aaony io eniieuciaaiey
noaiaa?oiuo iauaeoia aeaeeioaee Delphi. A Delphi ainooiiu oaenou i?ia?aiiu,
ii?i?aaiiie aecoaeuiui eiino?oeoi?ii, i?e?ai eciaiaiey a ieo ia aeey?o ia
aicii?iinou aaeuiaeoae ia?aaioee eo eiino?oeoi?ii. Yoi aaao aicii?iinou
i?iecaiaeou o?aaoaio? ei??aeoe? ?aaiou iauaeoia i?ia?aiiu, anee iia ia
iaania?eaaaony aecoaeuiui eiino?oeoi?ii. Oaeei ia?acii, Delphi
oaiaeaoai?yao o?aaiaaieyi oaianoaa, auno?iou e ea?anoaa ?ac?aaioee. E?iia oiai,
eniieuciaaiea ycuea Pascal iicaieyao iaania?eou i?eaieaio? nei?inou auiieiaiey
i?aia?aciaaiee, o?aao?ueo aieuoiai iauaia au?eneaiee ca n?ao aaenoaeoaeuiie
eiiieeyoee e aicii?iinoe iaiin?aanoaaiiie ?aaiou n iaiyou?
eiiiu?oa?a. Ia?aiia?aeuii ieaie?iaaeinu nicaaou aeai?eoi eiae?iaaiey
neiaiea, eioi?ue au iicaieye inouanaeyou aai iaiicia?io? eaaioeoeeaoe? ( ?en. 1
). Oae a iai ieaie?iaaeinu aaeua ieenaeu eiae?iaaou 0, a ?a?iua - 1 e
?anniao?eaaou eo ie eae ioaaeuiua a a?oiiie, o.a. a?oiia aaeuo ieenaeia - yoi 0,
aaeaa a?oiia ?a?iuo - 1 e o.a. A ?acoeuoaoa, neiaie, caee??aiiue a i?yiioaieuio?
( ?en. 1 ) ?aieo aaao neaao?uee eia: 01010----
- 0101 Ii ia i?aeoeea
ieacaeinu, ?oi aaiiue niinia ia iiaoiaeo aey ?aoaaiie caaa?e, o.e. ii i?aiu
neeuii i?eaycai e ia?a?oaie? neiaiea. I?e eciaiaiee ?acia?a neiaiea eee i?e
iaiiiai ioee?iii ia?a?oaiee aai eia eciaiyaony i?aiu nouanoaaiii. I?e oaaee?aiee
?acia?a neiaiea iiyaey?ony aiiieieoaeuiua no?iee, a cia?eo e aiiieieoaeuiua
neiaieu eiaa. Neaaiaaoaeuii iaiicia?iia aaeiae?iaaiea neiaiea i?e aaiiuo
ianoiyoaeunoaao ia i?aanoaaeyaony aicii?iui. Iaeucy i?eaycuaaouny e
ia?a?oaie? neiaiea, o.a. e ioaaeuiui ieenaeai. Aeuoa?iaoeaie i?aauaouaio auaiao yaeyaony ii?aaaeaiea ieioiinoe
ecia?a?aiey a ioaaeuiuo aai ?anoyo. A ?ac?aaaouaaaiie
nenoaia eniieucoaony eiaiii o?aoee iaoia, o.a. ii?aaaeaiea ieioiinoe ecia?a?aiey
a ioaaeuiuo aai ?anoyo. Aia?aea ia anai
ecia?a?aiee auaaeyaony iaeanou, ia?aie?eaa?uay ioaaeuiue neiaie. A ea?aii
ec 9 eaaa?aoia iian?eouaaaony ?enei ?a?iuo ieenaeia e aaeeony ia ieiuaau aaiiiai
eaaa?aoa, o.a. ii?aaaeyaony ieioiinou caiieiaiey a ea?aii eaaa?aoa. Ana 9
ii?aaaeaiiuo ieioiinoae i?aia?aco?ony a oi?iao O.OOO e aaeaa a no?ieo oeia O.OOO
O.OOO O.OOO O.OOO O.OOO O.OOO O.OOO O.OOO O.OOO. I?aia?aciaaiea a no?ieo
i?iecaiaeony aey aieaa oaiaiiai o?aiaiey aaiiuo a aaca aaiiuo ( no?oeoo?a aacu
iienaia a i?eei?aiee ), oae eae yoi iaiiiai oaiaiaa, ?ai aaeaou a aaca 9 iieae
aey o?aiaiey 9 cia?aiee ieioiinoe. Aaeiae?iaaiea neiaiea i?iecaiaeony
aiaeiae?iui niiniaii, oieuei iieo?aiiua aaiiua n?aaieaa?ony ni cia?aieyie
o?aieiuie a aaca aaiiuo. Ana iia?aoee inouanoaey?ony
iin?aanoaii aeaaiiai iai? i?ia?aiiu. Aeaaiia iai? ninoieo ec neaao?ueo
ioieoia: Anee aua?aiiue oaee yaeyaony i?aaeeuiui
a?aoe?aneei oaeeii, oi o?aieiia a iai ecia?a?aiea auaiaeony a ieii
i?ia?aiiu. Ia?aa iieuciaaoaeai iiyaeyaony aeaeiaiaia
ieii, a eioi?ii aio i?aainoaaeyaony aicii?iinou aua?aou eaeea eeiee auaaeyou (
aa?oeeaeuiua eee ai?eciioaeuiua ). Oio oaee, eioi?ue
aue ioe?uo ioe?uaaaony niiaa e ana eeiee iiyaeaoeany a i?ioanna ?aaiou
oaaey?ony. Yoio ioieo iai? i?aaiacia?ai aey
iao?aiey nenoaiu. A ieia aie?ai iaoiaeony yoaeiiiue oaeno. N iiiiuu? "iuoee"
auaaeyaony io?iue neiaie e auae?aaony aaiiue ioieo. Aneaa ca yoei iieuciaaoae?
i?aainoaaeyaony aicii?iinou oeacaou oieeaeuiue eia aey aua?aiiiai neiaiea.
Ii?aaaeaiiay ieioiinou e eia caienuaa?ony a aaco aaiiuo. Yoio
ioieo i?ioeaiiiei?ai i?aauaouaio. N iiiiuu? "iuoee" auaaeyaony io?iue neiaie e
auae?aaony aaiiue ioieo. I?ienoiaeo ii?aaaeaiea ieioiinoe aua?aiiiai neiaiea e
aaeaa a aaca inouanoaeyaony iiene caiene, o eioi?ie iiea n yoaeiiiie no?ieie
aieaa noiaii n ieioiinou? auaaeaiiiai neiaiea. Ii?aaaeyaony e neeaauaa?ony ia?ao niaie ?aciinoe ia?ao
ieioiinoyie yoaeiiiiai e auaaeaiiiai neiaieaie aey ea?aiai eaaa?aoa. Oio
yoaeiiiue neiaie, o eioi?iai iieo?aiiay noiia iea?aony iaeiaiuoae n?eoaaony
yeaeaaeaioii aey auaaeaiiiai. Yoe i?aia?aciaaiey yaey?ony
yenia?eiaioaeuiuie e ia yaey?ony oaeu? iinoaaeaiiie caaa?e. Iieo?aiiua
?acoeuoaou i?e aieaa aeoaieii enneaaiaaiee iiaoo auou a aaeuiaeoai eniieuciaaiu
aey ia?aaioee ecia?a?aiee. Yoe aaa ioieoa
no?iyo ecia?a?aiea iieucoynu aoeiiuie i?aia?aciaaieyie n ?acee?iuie
eiyooeoeaioaie. A caaeneiinoe io yoeo eiyooeoeaioia ecia?a?aiey iieo?a?ony
?acee?iuie. Iiyou ?a iniiauaaynu ia aoeiiuo
i?aia?aciaaieyo no?ieony eeno iaii?ioieea. Aaiiia i?aia?aciaaiea eiaao ia?iiiia
i?aeoe?aneia cia?aiea, oae eae ioiineoaeuii nei?iia ecia?a?aiea ( eeno
iaii?ioieea ) no?ieony n iiiiuu? iaiie oi?ioeu. No?oeoo?a aacu aey o?aiaiey yoaeiiiuo
neiaieia - iaiicia?ii eaaioeoeoe?oao o?aieiue neiaie. Oae eae a aaca
o?aiyony yoaeiiu ea?iaeeoia, aey eioi?uo a ?onneii aeoaaeoa iao i?eia?a
ia?a?oaiey, oi aey caiaiu ?aniiciaiiiai neiaiea io?ii aua o?aieou e aai
yoaeiiiia ecia?a?aiea. Ii oae eae oaeu? aaiiie ?aaiou yaeyaony ia caiaia
?aniiciaiiuo neiaieia ia yoaeiiiua, a oieuei niioianaiea n yoaeiiii, oi aey
yeiiiiee aeneiaiai i?ino?ainoaa ?aoaii o?aieou ia yoaeiiiia ecia?a?aiea neiaiea,
a oieuei aai oieeaeuiue eia, n iiiiuu? eioi?iai ii?ii iaiicia?ii
eaaioeoeoe?iaaou neiaie. Oaeno i?ia?aiiu SysUtils,
WinTypes, WinProcs, Messages, Classes, Graphics, Controls, MainMenu: TMainMenu; OpenDialog:
TOpenDialog; Onemore1: TMenuItem; DataTableID: TFloatField; procedure
NSelectClick(Sender: TObject); Shift:
TShiftState; X, Y: Integer); procedure
8526_MouseMove(Sender: TObject; Shift: TShiftState; X,
procedure Onemore1Click(Sender: TObject); procedure N5Click(Sender:
TObject); DetectRectX,
DetectRectY: real; { Oaie, iia eioi?ui auaaeyou eeiee } procedure SetRect; procedure
Paporotnik; implementation procedure TMainForm.NFileOpenClick(Sender:
TObject); end Result: word;
RectXEdit.Text := FloatToStr(DetectRectX); X2Edit.Text :=
IntToStr(xEnd); DetectRectX :=
StrToInt(RectXEdit.Text); yStart :=
StrToInt(Y1Edit.Text); if Result = mrOK then
SetRect; procedure TMainForm.DefGradient(var Gx, Gy: real; x,y: word); if Pixels[x-
1,y-1] = clBlack then a := 0 if Pixels[x+1,y-1] = clBlack then c := 0 if Pixels[x+1,y]
= clBlack then e := 0 if Pixels[x,y+1] = clBlack then h := 0
Gx := g + 2*h + i - a - 2*b - c; Gy := c + 2*e + i - a - 2*d - g; Gx, Gy, Qx, Qy: real; { Neaie?oai ana ecia?a?aiea }
DefGradient(Gx,Gy,x,y); { Ii?aaaeeou a?aaeaio a oi?ea [x,y] } { Qx := Round(90*Gx/4); {
if (Q <= -Pi/3) or (Q >= Pi/3) then Pixels[x,y+200] := clRed;} Pixels[x,y+200] := clRed;
CloseFile(OutF); begin x1 := x; y1 := y; else Range :=
dy; else Range := dx; for x := x1 to x1+Range do begin end; { for x } y1 := y1+dy; { Neaao?uee eaaa?ao
ii aa?oeeaee } OpenDialog.FileName :=
'c:\delphi\mydir\diplom\pict\pict1.bmp'; procedure TMainForm.8526_MouseDown(Sender:
TObject; Button: TMouseButton; 8526_.8526_Name := OpenDialog.FileName; Pen.Color := clGreen; end; { with
} Shift: TShiftState; X, Y: Integer); Pen.Style := psSolid; procedure TMainForm.8526_MouseMove(Sender: TObject; Shift:
TShiftState; X, Y: Integer); xEnd := X;
yEnd := Y; begin procedure TMainForm.AfinConvert; A :=
0.5; B := 0.5; E := 0; dy := (yEnd-yStart+1) div 2; yEnd := yStart
+2*dy - 1; Case Rand of 4: begin x := xStart + 1 + (x-xStart+1) div
2; y := yStart + dy + (y-yStart+1) div 2; procedure TMainForm.N7Click(Sender: TObject); A, B, C, D, E, F: real; dx := (xEnd-xStart+1) div Kx; xEnd :=
xStart +Kx*dx - 1; for i := 1 to 100000 do begin K := (Rand - Kx*(Rand div Kx)) *dx; procedure TMainForm.Onemore1Click(Sender:
TObject); begin for y := yStart to yEnd do begin if (Z.Re < 2)
and (Z.Im < 2) then Z.Free; procedure
TMainForm.Paporotnik; ((85,0,0,0),(0,85,11,70),(0,-10,85,0)), b: array[1..15000] of word; Randomize; i :=
1; a[b[i],0,3]; z := (a[b[i],2,0]*x +
a[b[i],2,1]*y + a[b[i],2,2]*z) / 100+
8526_.Canvas.Pixels[Round(300-x+z), Round(350-y)] := clGreen; function TMainForm.GetDensity: string; P: real; { Ieioiinou ieenaeia a eaaa?aioa } LenX := xEnd-xStart+1; if j = 2 then dy
:= LenY-2*Round(LenY/3) else dx :=
Round(LenX/3); BlackCnt := 0; { Eie-ai ?a?iuo ieenaeia a eaaa?aioa } if
8526_.Canvas.Pixels[x,y] <> clWhite then Inc(BlackCnt); TotCnt := dx*dy; end; {
for i } procedure TMainForm.N5Click(Sender:
TObject); DataTable.AppendRecord([ID+1,
S]); S, DStr1, DStr2, OldS: string; Value := 100; {----------------------------------------------------
-------} NewValue := NewValue +
Abs(StrToFloat(DStr2)-StrToFloat(DStr1)); if NewValue < Value then
begin
ShowMessage(IntToStr(ID));
| |