Study Dip last 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.
This series of the last article, follow-up articles will be written in other series, I would like to put the wavelet also in this series, but I feel a little difficult to write a recent wavelet, where the learning environment is not good, want to write some fun, such as pattern recognition, image features point What, I hope you continue to pay attention.
Algorithm principle
The simple segmentation of multi-channel images, can be given a threshold vector, and then given a range, can be three-dimensional spherical, or cube, this depends on the specific design, such as a simple example, given the RGB center threshold value is t ? ( R 0 , G 0 , B 0 ) , the threshold value is 100, so for pixel points ( x , y ) Span style= "Display:inline-block; width:0px; Height:2.56em; " > Color vector at the i ? ( r x y , g x y , b x y )
So just meet
|t ? i ? |< -
The point satisfies the requirement for the target point, otherwise the background point.
The algorithm is also suitable for other color spaces, but is designed according to the specific situation, so the flexibility is very strong.
Code
Double chanel3distance (RGB Point1,rgb point2) {return sqrt (point1. C1-point2. C1) * (point1. C1-point2. C1) + (point1. C2-point2. C2) * (point1. C2-point2. C2) + (point1. C3-point2. C3) * (point1. C3-point2. C3));}void Segmentrgb (rgb* src,rgb *dst,int width,int Height,rgb * color_center,double threshold) {double distance=0.0;for (int i=0; i<width*height;i++) {Distance=chanel3distance (Src[i], *color_center);if (distance<=threshold) {Dst[i]. C1=src[i]. C1;Dst[i]. C2=src[i]. C2;Dst[i]. C3=src[i]. C3;}else{Dst[i]. C1=0.;Dst[i]. C2=0.;Dst[i]. C3=0.;} }}
Results analysis
Below is a simple split and smooth, then merge.
Original:
Split (use simple RGB model, skin color segmentation point simple selection, so the effect is not very good):
Merge after smoothing
Original:
Split Result:
Summarize
At this point in 70 days a simple introduction of the basic knowledge of image processing, specific applications because there is no industry versatility, so there will be a choice of learning, thank you all the way to adhere to a few months, thank you have been supporting, I hope everyone's technical progress.
The end of this series.
Technology, to be continued ...
Color image--image segmentation with color space segmentation