Здравствуйте! Мне нужно написать программу, которая бы на рисунке распознавала букву "М". Я использовал алгоритм такой: Сначала все линии рисунка делаются толстыми, а потом подставляется в каждую точку рисунка шаблон буквы, в разных размерах. У меня получилось очень неоднозначно, часто ошибается и надо очень точно рисовать букву. Пожалуйтса, подкиньте идейку хорошего алгоритма, желательно не сложного, либо помогите оптимизировать мою прогу! Вот код: Код (Text): .586 .MODEL FLAT , STDCALL option casemap :none include \masm32\include\windows.inc include \masm32\include\user32.inc include \masm32\include\kernel32.inc include \masm32\include\gdi32.inc include \masm32\include\masm32.inc include \masm32\include\debug.inc includelib \masm32\lib\user32.lib includelib \masm32\lib\kernel32.lib includelib \masm32\lib\gdi32.lib includelib \masm32\lib\masm32.lib includelib \masm32\lib\debug.lib DBGWIN_DEBUG_ON = 1 ;turn it off if you don't want to include debug info into the program DBGWIN_EXT_INFO = 1 ;turn it off if you don't want to include extra debug info into the program WinMain proto :DWORD,:DWORD,:DWORD,:DWORD .data ClassName db "SimpleWinClass",0 AppName db "Распознавание",0 MouseClick db 0 Paint dd 0 m_x db 1,1,1,1,2,3,4,5,5,5,5,5 m_y db 2,3,4,5,2,3,2,1,2,3,4,5 scale dd 10 Counter dd 0 .data? hInstance HINSTANCE ? CommandLine LPSTR ? hwnd HWND ? hdc HDC ? hBrush HBRUSH ? hPen HPEN ? x dd ? y dd ? x1 dd ? y1 dd ? x2 dd ? y2 dd ? current_x dd ? current_y dd ? LOWORD MACRO bigword ;; Retrieves the low word from double word argument mov eax,bigword and eax,0FFFFh ;; Set to low word ENDM HIWORD MACRO bigword ;; Retrieves the high word from double word argument mov ebx,bigword shr ebx,16 ;; Shift 16 for high word to set to high word ENDM .code start: invoke GetModuleHandle, NULL mov hInstance,eax invoke GetCommandLine mov CommandLine,eax invoke WinMain, hInstance,NULL,CommandLine, SW_SHOWDEFAULT invoke ExitProcess,0 WinMain proc hInst:HINSTANCE,hPrevInst:HINSTANCE,CmdLine:LPSTR,CmdShow:DWORD LOCAL wc:WNDCLASSEX LOCAL msg:MSG mov wc.cbSize,SIZEOF WNDCLASSEX mov wc.style, CS_HREDRAW or CS_VREDRAW mov wc.lpfnWndProc, OFFSET WndProc mov wc.cbClsExtra,NULL mov wc.cbWndExtra,NULL push hInstance pop wc.hInstance invoke LoadIcon, NULL, IDI_APPLICATION mov wc.hIcon,eax mov wc.hIconSm,eax mov wc.hbrBackground,COLOR_WINDOWTEXT+1 mov wc.lpszMenuName,NULL mov wc.lpszClassName,OFFSET ClassName invoke LoadCursor,NULL,IDC_ARROW mov wc.hCursor,eax invoke RegisterClassEx,addr wc INVOKE CreateWindowEx,NULL,ADDR ClassName,ADDR AppName,WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,CW_USEDEFAULT,308,331,NULL,NULL,hInst,NULL mov hwnd,eax INVOKE ShowWindow, hwnd,SW_SHOWNORMAL INVOKE UpdateWindow, hwnd invoke SetTimer,hwnd,1,1,NULL .WHILE TRUE INVOKE GetMessage, ADDR msg,NULL,0,0 .BREAK .IF (!eax) INVOKE TranslateMessage, ADDR msg INVOKE DispatchMessage, ADDR msg .ENDW mov eax,msg.wParam ret WinMain endp WndProc proc hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM LOCAL ps:PAINTSTRUCT LOCAL hMemDC:HDC LOCAL rect:RECT .IF uMsg==WM_CREATE invoke GetDC, hWnd mov hdc,eax invoke CreateSolidBrush,0ff00h mov hBrush,eax invoke CreatePen,PS_NULL,1,0ff00h mov hPen,eax .elseif uMsg==WM_MOUSEMOVE LOWORD lParam mov x,eax HIWORD lParam mov y,ebx .IF (wParam & MK_LBUTTON) invoke SetPixel, hdc, x, y, 0ffffffh .ENDIF .elseif uMsg==WM_KEYDOWN mov eax,wParam mov Paint,1 .elseif uMsg==WM_TIMER .if Paint==1 xor edi,edi .repeat xor esi,esi .while esi<301 invoke GetPixel,hdc,esi,edi .if eax==0ffffffh mov ebx,9 mov x1,esi sub x1,ebx mov y1,edi sub y1,ebx mov x2,esi add x2,ebx mov y2,edi add y2,ebx invoke SelectObject,hdc,hBrush invoke SelectObject,hdc,hPen invoke Ellipse,hdc,x1,y1,x2,y2 .endif inc esi .endw inc edi .until edi==301 mov Paint,0 xor edi,edi .while edi<296 xor esi,esi .while esi<296 invoke GetPixel,hdc,esi,edi .if eax==0ff00h xor ebx,ebx mov scale,5 .repeat xor eax,eax mov al,m_x[ebx] mul scale mov current_x,eax add current_x,esi xor eax,eax mov al,m_y[ebx] mul scale mov current_y,eax add current_y,edi invoke GetPixel,hdc,current_x,current_y .if eax==0ff00h inc ebx .else inc scale xor ebx,ebx .endif .if ebx>11 add Counter,1 ;add esi,13 ;add edi,13 .endif .until ((scale>40) || (ebx>11)) .endif inc esi .endw inc edi .endw ;invoke SetTextColor,hdc,0ffh ;invoke SetBkColor,hdc,0h PrintDec Counter,"Counter" PrintLine ;add Counter,'0' ;invoke TextOut,hdc,0,0,ADDR Counter,SIZEOF Counter-1 ;sub Counter,'0' mov Paint,0 .endif .elseif uMsg==WM_DESTROY invoke ReleaseDC, hWnd, hdc invoke PostQuitMessage,NULL .ELSE invoke DefWindowProc,hWnd,uMsg,wParam,lParam ret .ENDIF xor eax,eax ret WndProc endp end start Заранее благодарен!