[Digital image processing] top cap and bottom cap Transform transform

Article link: http://blog.csdn.net/kk55guang2/article/details/78490069

Top cap and bottom cap Transform transform

Gray scale image f, the top-hat transform (top-hat transformation) is defined as f minus opening operation:
That (f) = F- (f∘b)

Similarly, f conversion bottom cap (bottom-hat transformation) is defined as the closing operation is subtracted f, f:
Bhat, (f) = (f ∙ B) -f

  One of the main applications of these two transformation is deleted by using a structure element the opening operation or a closing operation from objects in an image, rather than fitting the objects to be deleted. Then, retaining only difference was obtained in a deleted component of the image. Transform overcap bright objects on a dark background, and the bottom cap for converting the opposite case. For this reason, when it comes to these two conversion, often referred to as black and white top hat transformation hat transformation. One important use thereof is to correct the unevenness affect illumination. [1]
Examples
  Below, we illustrate this by an example method for FIG. 1 (A), with uneven illumination can be seen, the left stronger illumination, direct method global threshold is otsu to FIG. 1 (B), can be seen to the left of the coin division error.
  Since the background picture is bright, dark foreground, to original bottom-hat transformation to solve the problem of uneven illumination, where the first processing result is given, as shown in FIG 1 (c) and (D), can be seen in the end cap of the transformed image removed most non-uniform background, the last threshold processing, the left coin is split up, a small amount of incomplete, but little effect, incomplete follow-up can be filled by other processes morphology.

                The image processing 1 in FIG
  why the end cap or top hat transform to achieve these results it can be converted, conversion below a bottom cap, for example, be explained by a three-dimensional gray scale image of FIG.
  Bottom cap closing operation is converted into f minus f, geometric meaning closing operation can be so close to the ball rolling on a curved surface, any part of the lowest point of the sphere can be achieved at this time, i.e., it constitutes a closing operation f ∙ bf ∙ b surfaces. [2]
  FIG 2 is a three-dimensional picture gradation curved upward trend shows the inequality background gray image portions caused by uneven illumination, wherein the recess corresponding to the image gray value is relatively small area, i.e. the image the coins.

  By selecting the appropriate size of the coin is larger than the structure element, can be viewed as a sphere rolling on the gray surface, tracks curved surface constituting the spherical closing operation, shown in Figure 3, the original fill recesses are to be Representative approximately uniform background. After completion of closing operation to the original image can be obtained by subtracting the background image is approximately uniform, as shown in FIG. 4, may be the corresponding grayscale Figure 1 (c), a non-uniform background can be seen is substantially removed, which will great help behind the threshold segmentation.

 

Reference program:

// Image_Use original image, Image processing of the image to the copy 
                      for ( int I = 0 ; I <Use_ROWS; I ++ )
                            {
                                for (int j = 0; j < Use_Line; j++)
                                {
                                  Image[i][j] = Image_Use[i][j];
                                }
                            }
                    //二值化  
                    int i,j;
                    int Threshold;
                    Threshold = GetOSTU(Image);
                    for(i = 0; i < Use_ROWS; i++)   
                    {
                        for(j =0; j < Use_Line; j++)
                        {
                          
                          if(Image[i][j] >= Threshold)
                                Image[i][j]=255;
                          else
                                Image[i][j]=0;
                               
                        }
                    }
                    
                    //去噪:不处理四边
                    int bai;
                    for(i = 1; i < Use_ROWS-1; i++)   
                    {
                        for( j=1; j < Use_Line-1; j++)
                        { 
                          if(Image[i][j] == 255) continue;     
                          bai = Image[i-1][j] + Image[i-1][j-1] + Image[i-1][j+1] +Image[i][j+1] +Image[i][j-1] +Image[i+1][j] +Image[i+1][j-1] +Image[i+1][j+1] ;
                          if(bai == 2040)
                          Image[i][j] = 255;
                          
                        }
                    }
                    
                   
                    
                    //开操作
                     for (int i = 1; i < Use_ROWS-1; i++)
                            {
                                for (int j = 1; j < Use_Line - 1; j++)
                                {
                                    if (Image[i][j] == 255 &&
                                        Image[i][j + 1] == 255 &&
                                        Image[i][j - 1] == 255)
                                    {
                                        Image[i][j] = 255;
                                    }

                                }
                            }
                    for (int i = 1; i < Use_ROWS-1; i++)
                            {
                                for (int j = 1; j < Use_Line - 1; j++)
                                {
                                    if (Image[i][j] == 255 ||
                                        Image[i][j + 1] == 255 ||
                                        Image[i][j - 1] == 255)
                                    {
                                        Image[i][j] = 255;
                                    }
                                }
                            }
                  //原图像-开操作  
                  for (int i = 0; i < Use_ROWS; i++)
                            {
                                for (int j = 0; j < Use_Line; j++)
                                {
                                  Image_Use[i][j] = Image_Use[i][j] - Image[i][j];
                                }
                            }  
                    
                  //再进行顶帽变换的图像进行二值化  
                 Threshold = GetOSTU(Image_Use);
                  for(i = 0; i < Use_ROWS; i++)   
                    {
                        for(j =0; j < Use_Line; j++)
                        {
                          
                          if(Image_Use[i][j] >= Threshold)
                                Image_Use[i][j]=255;
                          else
                                Image_Use[i][j]=0;
                               
                        }
                    }
                    //去噪:不处理四边
                    for(i = 1; i < Use_ROWS-1; i++)   
                    {
                        for( j=1; j < Use_Line-1; j++)
                        { 
                          if(Image_Use[i][j] == 255) continue;     
                          bai = Image_Use[i-1][j] + Image_Use[i-1][j-1] + Image_Use[i-1][j+1] +Image_Use[i][j+1] +Image_Use[i][j-1] +Image_Use[i+1][j] +Image_Use[i+1][j-1] +Image_Use[i+1][j+1] ;
                          if(bai == 2040)
                          Image_Use[i][j] = 255;
                        }
                    }

 

参考文献
[1]《数字图像处理》(第3版),冈萨雷斯著,阮秋琦译,电子工业出版社,2013年;
[2]《数字图像处理与机器视觉——Visual C++与Matlab实现》,张铮,王艳平,薛桂香等编著,人民邮电出版社,2014年

Guess you like

Origin www.cnblogs.com/-wenli/p/11980413.html