Gray image--Regional growth of segmentation of image segmentation region

Source: Internet
Author: User

Study Dip 58th Day
Reprint please indicate the source of this article:Http://blog.csdn.net/tonyshengtan , out of respect for the work of the author, reprint please indicate the source! Article code is hosted, Welcome to co-development:Https://github.com/Tony-Tan/DIPpro

The opening crap.

Continue to say nonsense, yesterday blog was seen by colleagues, asked me, why do you every beginning is nonsense, I said, in a can write a little easier words, every day in the algorithm of the sea, occasionally said a few words of barren Mountain wild ridge of nonsense also counted active atmosphere.

Introduction to Regional segmentation

Today, the introduction of region-based segmentation method, the previous threshold-based segmentation method, based on the same wide range of segmentation, but compared with the threshold, regional segmentation is slightly more difficult, such as the watershed algorithm, the watershed algorithm is an algorithm family, is not a single fixed algorithm, For example, there are morphological-based, but also based on other, but the idea is the same, the watershed is the kind of typical, it seems very simple, a theory, elementary school students can understand, but the difficulty of achieving it is not small, it may be my code ability, anyway wrote nearly a day, modified a day to see the results.
Because region-based segmentation algorithms have become a specialized field of study, these few blog posts only introduce a little bit of the most basic, general-purpose algorithms, as far as the advanced high-tech algorithms, to stay for some time in the future. This is the simplest of all.
The regional growth introduced today is a relatively simple one.

Regional growth algorithms

The algorithm process for region growth is summarized as follows:

  1. Select Seed Point < Span class= "Mrow" id= "mathjax-span-5862" >c ( x , Y )
  2. Recursive traversal of its neighborhood pixels, centered on the seed point
  3. For each neighborhood pixel N ( x- , y ) , Design a discriminant Q(C(x ,y),N ( x- , y )) 。
  4. If the discriminant is true, the neighborhood pixel n is set to the new seed point, entering the 2nd step, and adding the point to the result set (the same region as the seed point). Otherwise, exit this recursive return to 3 and detect the next neighbor pixel.

The overall idea is to take the seed point as the center, traverse the graph, depth first or breadth first does not have no relationship, judge whether the center point and its neighborhood satisfies the discriminant, notice, here the final point is discriminant, design discriminant can be used for different applications, the following code design discriminant is a simple range discriminant type, That is to say, if the other pixel gray value, within a certain range, is true, otherwise false, the range is generated by the seed point and additional parameters param together.

Code
/****************************************************************************//****************************************************************************// * Area growth, set a seed point x (grayscale value of X_v), and then center the seed Point * to the surrounding map search, if the point Y (gray value is Y_v), the neighborhood satisfies Param+x_v>y_v>x_v-param (condition 1) * Then this point and seed point is classified as an area, recursively, condition 1 can set the other according to different needs. *///Recursive traversal neighborhood and determine if conditions are truevoidFindgrowregion (Double*SRC,Double*DST,intSeed_x,intSeed_y,intWidthintHeightintRegionnum,DoubleValueDoubleparam) {dst[seed_y*width+seed_x]= (Double) Regionnum; for(intj=-1;j<2; j + +) for(inti=-1;i<2; i++) {if(seed_x>=0&&seed_y>=0&&seed_x<width&&seed_y0|| i!=0)){if(src[(j+seed_y) *width+i+seed_x]>=value-param &&src[(j+seed_y) *width+i+seed_x]<=value+param &&dst[(j+seed_y) *width+i+seed_x]==0.0) findgrowregion (SRC, DST, i+seed_x, j+seed_y, width, height, regionnum, value,param); }        }}voidRegiongrow (Double*SRC,Double*dst,position * Position,intP_size,intWidthintHeightDoubleparam) {Double* Dsttemp= (Double*) malloc (sizeof (Double) *width*height); Zero (dsttemp, width, height);intregionnum= -; for(intI=0; i<p_size;i++) {intx=position[i].x;intY=POSITION[I].Y;        Findgrowregion (SRC, dsttemp, x, y, width, height, regionnum,src[y*width+x],param); regionnum+=Ten;    } matrixcopy (Dsttemp, DST, width, height); Free (dsttemp);}
Results analysis









Summarize

Region growth algorithm implementation is relatively simple, but if the recursive area is too large, may cause the program to die, may be insufficient stack space or other, this need to deal with the disadvantage of this algorithm is the need to set the seed point, the advantages of this algorithm can also be set seed point, so flexible but not intelligent, algorithm execution faster.
Cond...

Gray image--Regional growth of segmentation of image segmentation region

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.