File Exchange

## Segmentation_Growin​g(img,sx1,sx2,sy1,s​y2,f)

version 1.32.0.0 (2.65 KB) by Ingo Hermann

### Ingo Hermann (view profile)

This function grows from a certain area with a weigthing to the outer boarder of the object

Updated 16 Dec 2016

This Matlab Function segmentate a object of an image while choosing an area and growing from it with a weighting factor to the boundaries. (see here a description: http://physingo-en.blogspot.de/2016/12/matlab-segmentation-growing.html )
function [region, area, seed, sx1, sx2, sy1, sy2] = Segmentation_Growing(img,sx1,sx2,sy1,sy2,f)
%img is the image which is segmentated
%sx1 and sy1 are the values of the upper left corner and
%sx2 and sy2 are the values of the lower right corner
%f can vary between 1 and 2 and is the weigthing factor
%region is the output of the segmentated region
%if area is in region it's one otherwise it's 0
%seed is the start area
This is a methode of segmentation where a region is defined (seed) . In this seed the standard deviation and the mean is calculated and with a factor f it is weigthed. Pixel which are in the neighborhood of the seed are added to the seed if their value is in the boundary defined by the standard deviation, mean value and weighting factor f. This is done iterative as long as no more pixel is added to the seed. Then the object is segmented.
function [region, area, seed, sx1, sx2, sy1, sy2] = Segmentation_Growing(img,sx1,sx2,sy1,sy2,f):

This function needs an image as an imput. If there is no other input value one can choose with to cursors the starting point sx1, sy1, the left upper corner, and the end point sx2, sy2, the right lower corner. Otherwise one can define the s-value as one wants. If one uses cursors, one can use the second input argument for defining the factor f. This factor describes the weigthing and is in an area bigger equal to 0. This is shown in the following figure below for f=1 (blue), f=1.5 (yellow) and f=2 (green). The red rect shows the chosen seed.
The output of the function is region, which is the segmented object. Area describes the segmented area with value 1 and the rest as 0. Seed logically returns seed, if it is chosen by the cursors.

 16 Dec 2016 1.32.0.0 Update 1.32: Added a comment 14 Dec 2016 1.31.0.0 Update 1.31: Update description text. 14 Dec 2016 1.3.0.0 Update 1.3: Now one an choose any region with the cursor and the distance output is better scaled. 14 Dec 2016 1.2.0.0 Update 1.2: better definition of area in the code. 14 Dec 2016 1.1.0.0 Update 1.1: It is now possible to segmentate black areas.
##### MATLAB Release Compatibility
Created with R2016b
Compatible with any release
##### Platform Compatibility
Windows macOS Linux

### Discover Live Editor

Create scripts with code, output, and formatted text in a single executable document.