[Image segmentation] Image segmentation based on multiple algorithms of global threshold, otsu, and adaptive threshold, including Matlab source code

  1 Introduction

It focuses on the threshold research methods in image segmentation, including the global threshold method and the adaptive threshold method. The manual selection method, iterative threshold selection method, maximum inter-class variance method and watershed in adaptive algorithm in the global threshold algorithm are discussed. The algorithm is analyzed and realized by Matlab, and the experimental results are given.

The threshold segmentation method is a common area parallel technology. In principle, one or more thresholds are used to distinguish the grayscale histogram of a pixel, and then it is divided into several different classes, and the obtained pixel grayscale value is in the same class. belong to the same object. Since the direct use of the grayscale histogram can simplify the calculation part, it is particularly important to select a suitable threshold. In order to find a suitable threshold, a criterion function is inseparable [3]. In practical research, it is not easy to select an appropriate threshold value, and the main factors affecting the threshold value setting are the brightness of light and noise. With the progress of research, several methods have been gradually developed to solve the above problems. The widely used methods include adaptive threshold method, maximum entropy method, inter-class threshold method and fuzzy threshold method. And in order to ensure accuracy, at least 2 or more methods will be used to determine the threshold. First, the original image to be processed is assumed to be f(x, y). The main task of threshold segmentation is to convert the original input function into an output function g(x, y).

The image of the obtained function g(x, y) is a binary image. After comparing the original image f(x, y) with the threshold p, the segmented image can be obtained. In the current research, the core of the threshold segmentation algorithm is to find the most suitable threshold, which can be divided into manual selection method and automatic selection method. When creating a histogram, judge the appropriate threshold according to experience. However, in the absence of manual intervention, an automatic selection method is required, which is also judged by the use of professional knowledge in the professional field in a special environment.​

2 part code

function y = isrgb(x)%ISRGB Return true for RGB image.%   FLAG = ISRGB(A) returns 1 if A is an RGB truecolor image and%   0 otherwise.%%   ISRGB uses these criteria to determine if A is an RGB image:%%   - If A is of class double, all values must be in the range%     [0,1], and A must be M-by-N-by-3.%%   - If A is of class uint8 or uint16, A must be M-by-N-by-3.%%   Note that a four-dimensional array that contains multiple RGB%   images returns 0, not 1.%%   Class Support%   -------------%   A can be of class uint8, uint16, or double. If A is of %   class logical it is considered not to be RGB.%%   See also ISBW, ISGRAY, ISIND.​%   Copyright 1993-2003 The MathWorks, Inc.  %   $Revision: $  $Date: 2003/08/23 05:52:55 $​wid = sprintf('Images:%s:obsoleteFunction',mfilename);str1= sprintf('%s is obsolete and may be removed in the future.',mfilename);str2 = 'See product release notes for more information.';warning(wid,'%s\n%s',str1,str2);​y = size(x,3)==3;if y   if isa(x, 'logical')      y = false;   elseif isa(x, 'double')      % At first just test a small chunk to get a possible quick negative        m = size(x,1);      n = size(x,2);      chunk = x(1:min(m,10),1:min(n,10),:);               y = (min(chunk(:))>=0 && max(chunk(:))<=1);      % If the chunk is an RGB image, test the whole image      if y         y = (min(x(:))>=0 && max(x(:))<=1);      end   endend

3 Simulation results

4 References

[1] Li Xiaoqi. Research on Image Threshold Segmentation Algorithm Based on Matlab [J]. Software Guide, 2014, 13(12):3.

About the blogger: He is good at Matlab simulation in various fields such as intelligent optimization algorithm, neural network prediction, signal processing, cellular automata, image processing, path planning, UAV, etc. The related matlab code questions can be exchanged privately.

Some theories refer to online literature. If there is any infringement, contact the blogger to delete it.

Tags: MATLAB Algorithm image processing

Posted by bemoi on Fri, 13 May 2022 01:19:55 +0300