c# - region growing image segmentation -


i make region growing algorithm project algorithm

(my picture have been greyscale before it) 1. value pixel (0,0) seed pixel 2. compare value seed pixel 1 neighbor pixel 3. if value of no.3 less treshold (t), go next pixel , go no.2 4. if value of no.3 more treshold (t), change pixel white(also next 10 pixel), , new seed value pixel.

my goal picture segmented white line

this code

private void button4_click(object sender, eventargs e) { // gdi+ still lies - return format bgr, not rgb. bitmapdata bmdata = rimage.lockbits(new rectangle(0, 0, rimage.width, rimage.height), imagelockmode.readwrite, pixelformat.format24bpprgb);

        int stride = bmdata.stride;         system.intptr scan0 = bmdata.scan0;          unsafe         {             byte* p = (byte*)(void*)scan0;              int noffset = stride - rimage.width * 3;              (int y = 0; y < rimage.height; ++y)             {                                    (int x = 0; x < rimage.width; ++x)                 {                       //every new line of x must new seed                     if (x == 0)                     {                                                     //getting new value seed pixel                         seedr = p[x];                         seedg = p[x+1];                         seedb = p[x+2];                     }                      //compare value of seed pixel , pixel scan                     if ((seedr - p[x] >= tred) || (p[x] - seedr >= tred))                     {                          //make white line change value of pixel                         (int i=1; <= 5; ++i)                         {                             p[x] = p[x + 1] = p[x + 2] = 0;                             x++;                         }                          //getting new value of seed pixel                         seedr = p[x];                         seedg = p[x + 1];                         seedb = p[x + 2];                     }                     p += 3;                 }                 p += noffset;             }         }          rimage.unlockbits(bmdata);     } 

my problem image become white in 1/3 of image must doing "region growing" ?? thx

i've left questions algorithm in comments, writing them realized you're trying may not image segmentation @ all.

my goal picture segmented white line

do mean want this:

alt text

if yes, you're interested in isn't image segmentation, it's edge detection. if want implement that, have read convolution well.


Comments

Popular posts from this blog

Add email recipient to all new Trac tickets -

400 Bad Request on Apache/PHP AddHandler wrapper -

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -