Main image algorithm for work

zhaozj2021-02-16  46

Hough transformation

Bool hough (hough hwnd) {// Defines the linear structure typef struct {int topx; int topX; int boty;} myline; // memory dword bufsize; // file information head pointer lpbitmapInfoheader lpimgdata; // data area pointer LPSTR LPPTR; HDC HDC; Long X, Y; Long i, Maxd; INT K; INT DIST, Alpha; // Defines a full-bureau HGlobal Hdistalpha, HMYLINE; INT * LPDistalpha; MYLINE * LPMYLINE, * TEMPLINE, MAXDLINE; / / Define a logical brush static logpen rlp = {ps_solid, 1, 1, rgb (255, 0)}; // brush HPEN RHP; // Judgment whether it is 256 color bitmap IF (Numcolors! = 256) {MessageBox (HWND, "Must Be a mono bitmap with grayscale paste!", "error message", MB_ok | MB_ICONEXCLAMATION; RETURN FALSE;} // calculate diagonal length dist = (int) (SQRT (Double) bi.biwidth * bi.bi.biheight * bi.biheight 0.5); alpha = 180/2; // Allocate memory to process data IF ((hdistalpha = Globalalloc (GHND, (DWORD) dist * alpha * sizeof (int)) == null) {MessageBox (hwnd, "error", "error message", MB_OK | MB_ICONEXCLAMATION; RE Turn false;} // Allocate memory to store line data IF ((hmyline = GlobalAlloc (GHND, (DWORD) DIST * alpha * sizeof (myline))) == NULL) {globalfree (hdistalpha); return false;} // file header to obtain the data area offset BufSize = bf.bfSize-sizeof (BITMAPFILEHEADER); // lock memory lpImgData = (LPBITMAPINFOHEADER) GlobalLock (hImgData); lpDistAlpha = (int *) GlobalLock (hDistAlpha); lpMyLine = (MYLINE * Globalock (hmyline); // Initialize the linear array for (i = 0; i <(long) dist * alpha; i ) {templine = (MYLINE *); (* templine) .boty = 32767; } // Scan the entire source image for (y = 0; y

转载请注明原文地址:https://www.9cbs.com/read-16322.html

New Post(0)