Regional growth code

xiaoxiao2021-03-17  197

/ ************************************************** ************************** // function name: * regionGROW () ** // Enter parameter: * CDIB * PDIB - point to CDIB class Pointer, containing original image information * unsigned char * punRegion - pointer to regional growth results ** // return value: * No ** // Description: * Punregion pointer points to the data area that stores regional growth, where 1 (logic) Representation * Corresponding pixel is the growth area, 0 is expressed as non-growth zone * regional growth generally contains three comparison questions: * 1. Selection of seed points * 2. Growth criterion * 3. Terminal condition * It is believed that these three issues require specific analysis, and each problem solves the quality of the * regional growth.

* The seed point of this function is selected as the center of the image, and the growth criterion is that the pixel value of adjacent pixels is less than * nthreshold, and the termination condition is always not satisfied with the pixel required to grow criteria. ****** *********************************************************** **************************** / VOID RegionGRow (CDIB * PDIB, Unsigned Char * Punregion, INT NTHRESHOLD) {static int ndx [] = {- 1, 0, 1, 0}; static int NDY [] = {0, 1, 0, -1}; // Traverse the intersection of the image // int y; // Traverse the horizontal wave // ​​INT X; // image Long width size CSIZE SIZEIMAGE = PDIB-> getDimensions (); int nheight = sizeImage.cx; int nHEight = sizeImage.cy; // Image in the actual size of the computer in the store CSIZESEIMAGESAVE = PDIB-> getDibsavedim (); / / Image In Memory Pixel Occupation Pixel Occupation Pixel Occupational Int NsaveWidth = SizeImageSave.cx; // Initialization MEMSET (Punregion, 0, SizeOf (Unsigned Char) * nwidth * nHEight); // Seed point Int NSEEDX, NSEEEDY; / / Set the center nSEEDX = nwidth / 2; nseedy = nHEight / 2; // Define stack, store coordinate int * pngrowQuex; int * pngrowQuey; // allocate space PNGROWQUEX = new int [nwidth * nHEight]; pngrowquey = New int [nwidth * nheight]; // Pointer Unsigned char * punchinput = (unsigned char *) PDIB-> m_lpimage; // Define the starting point and end point of the stack // When nstart = nend, only one in the stack Point int NStart; int NEND; / / Initialization N START = 0; NEND = 0; // Press the coordinate of the seed point into the stack PNGROWQUEX [NEND] = NSEEDX; PNGRowQuey [NEND] = nseedy; // Currently processed pixel Int nCurRx; int ncurry; // loop control Variable INT K; // The cross-section of the image is used to traverse Int xx; int yy; while (nstart <= NEND) {// Current seed point NCURRX = PNGROWQUEX [ NStart]; nCurry = pngrowQuey [nStart]; // Travers in FOR (k = 0; k <4; k ) {// 4 neighborhood pixels XX = NCURRX NDX [K ]; Yy = nCurry NDY [k]; // Judgment pixel (xx, yy) is in the image inside // whether pixels (xx, yy) have been processed // PunRegion [YY * NWIDTH XX] = = 0 indicates that there is no processing // growth condition: determine the absolute value IF of the pixel (xx, yy) and current pixels (NCURRX, NCURRY) pixel value ((xx

(xx> = 0) && (YY = 0) && (PUNREGON [YY * NWIDTH XX] == 0) && ABS (PunchInput [YY * NSAVEWIDTH XX] - PunchInput [ncurry * nsavewidth NCURRX])

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

New Post(0)