Region-Based Segmentation Methods

1. Definition

The region-based segmentation method is an image segmentation technique that divides an image into several regions. These regions usually have similar characteristics, such as color, texture, brightness, etc., and have continuity within the image. The goal of this segmentation method is to divide the image into a set of regions, each of which is distinct from the others and can be used for further image analysis and processing.

Common region-based segmentation methods include the following:

  1. Region Growing: Starting from a certain starting point, it continues to grow around until a certain condition is reached, such as color, texture or gray value. This method requires manual selection of the starting point and has high computational complexity.

  2. Split and Merge: Treat the entire image as a region, divide it into several sub-regions, compare adjacent regions, and merge similar regions into larger regions. This method can automatically select regions and can produce smoother segmentation results.

  3. Energy function-based methods: Segment images by defining an energy function. The energy function is a function used to measure the quality of segmentation, usually including the features of regions and the similarity between regions. The best segmentation results are obtained by minimizing the energy function.

  4. Graph theory-based methods: Represent an image as a graph, where each pixel represents a node, and the edges between nodes represent the similarity between pixels. Then use the graph segmentation algorithm to divide the graph into several subgraphs, and each subgraph corresponds to a region. This approach enables automatic region selection and generally has high segmentation quality.

2. Regional growth method 

The region growing method is a region-based image segmentation method. Its principle is to start from a certain pixel or region, and continuously add adjacent pixels or regions to the same region until a certain condition is reached. This approach usually requires manual selection of seed points and has high computational complexity.

The following are the general steps of the region growing method:

  1. Select a seed point or region.

  2. Define growing criteria, such as color, texture, or grayscale values, to join adjacent pixels or regions into the current region.

  3. Repeat the second step until no new pixels or regions can be added.

  4. Segmentation results can be post-processed, such as removing smaller regions or merging adjacent regions.

The advantage of the region growing method is that it can produce smoother segmentation results and has certain robustness to image noise. However, this method requires manual selection of seed points and is easily affected by seed point selection and growth criteria. Furthermore, since each pixel can only be assigned to one region, this method is not suitable for the case where there are overlapping regions in the image.

Region growing is done with the help of imreconstruct of MATLAB image processing:

outim = imreconstruct(markerim, maskim). markerim is the marker image, maskim is the template image, and outim is the output image.

Experimental procedure:

f=imread('E:\peppers.png'); 
f=rgb2gray(f); 
subplot(1,2,1); 
imshow(f); 
seedx=[256,128,380]; 
seedy=[128,156,354]; 
hold on 
plot(seedx,seedy,'gs','linewidth',1); 
title('原始图像及种子位置'); 
f=double(f); 
markerim=f==f(seedy(1),seedx(1)); 
for i=2:length(seedx) 
markerim=markerim|(f==f(seedy(i),seedx(i))); 
end 
thresh=[15,10,15];
maskim=zeros(size(f)); 
for i=1:length(seedx) 
g=abs(f-f(seedy(i),seedx(i)))<=thresh(i); 
maskim=maskim|g; 
end 
[g,nr]=bwlabel(imreconstruct(markerim,maskim),8); #bwlabel()函数对二值图像进行连通区域标记
g=mat2gray(g); 
subplot(1,2,2); 
imshow(g) ; 
title('三个种子点区域生长结果');

Screenshot of the experiment:

 3. Regional split and merger method

Region Split and Merge (RSM) is an image processing technique based on image segmentation, which is used to divide an image into multiple similar regions. The basic idea of ​​the algorithm is to decompose the image into small sub-images layer by layer, and realize image segmentation by merging and splitting these sub-images.

The main steps of the algorithm are as follows:

  1. Initialization: The entire image is used as the initial area, and the average gray value of each area is calculated.
  2. Splitting: Split each region until the size of all regions is smaller than a predetermined threshold. The splitting method can adopt some clustering algorithms based on pixel values, edge information or texture features.
  3. Merge: Merge adjacent regions until the size of the merged region is greater than a predetermined threshold. The merging method can adopt some similarity measurement methods based on pixel values, edge information or texture features.
  4. Repeat the above steps until the predetermined segmentation granularity is reached

Advantages and disadvantages of the region splitting and merging algorithm:

  1. Good for complex image segmentation
  2. The algorithm is complex and the amount of calculation is large
  3. Secession risks breaking regional borders

Experimental procedure:

quadtree ('rice.png'); 
子程序: 
function quadtree (x) 
f=imread(x) ; 
q=2^ nextpow2 (max(size(f))); 
[m n]=size(f); 
f=padarray(f, [q-m,q-n], 'post'); 
mindim=2; 
s=qtdecomp (f,@split,mindim,@predicate); 
lmax=full (max(s(:))); 
g=zeros(size(f)); 
marker=zeros (size(f)); 
for k=1:lmax 
    [vals,r,c]=qtgetblk(f,s,k); 
    if ~isempty(vals) 
        for i=1:length(r) 
            xlow=r(i);ylow=c(i); x
            high=xlow+k-1; 
            yhigh=ylow+k-1; 
            region=f(xlow:xhigh,ylow:yhigh);
            flag=feval(@predicate,region); 
            if flag 
                g(xlow:xhigh,ylow:yhigh)=1; 
                marker (xlow,ylow)=1; 
            end 
        end 
    end 
end 
g=bwlabel(imreconstruct (marker,g));
g=g(1:m,1:n) ; 
f=f(1:m,1:n); 
subplot(1,2,1),imshow(f),title('原始图像'); 
subplot(1,2,2), imshow(g),title ('分割后图像'); 
end 
function flag=predicate(region) 
sd=std2 (region); 
m=mean2 (region); 
flag= (sd>5)&(m>0)& (m<200); 
end 
function v=split(b,mindim, fun) 
k=size(b,3); 
v(1:k)=false; 
for i=1:k 
    quadrgn=b(:, :,i) ; 
    if size (quadrgn, 1)<=mindim 
        v(i)=false; 
        continue ;
    end 
    flag=feval (fun, quadrgn) ; 
    if flag 
        v(i)=true; 
    end
end

Screenshot of the experiment:

Guess you like

Origin blog.csdn.net/weixin_44686138/article/details/130477290