Study Dip 53rd 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.
Needless to say, because just now (previous) has said, P-tile may sound very scary, it's okay, say it's the object – The median, this all know, the value of the row station, and then select the middle one, or, if the data has a total of n, then the median is the first row of N? 0.5 P-digit, also called P-bit, can be understood as the value of the row after the number of N? P of that number.
P-tile mean value
According to the understanding of the P-sub-position, it can be seen that the threshold processing method is semi-automatic method, that is, the generation of thresholds need manual control, that is, to manually enter the P-bit p, the code below p value (0,1]
Code
/*********************************************************************************//*********************************************************************************///Threshold method, p-Division method//p as a statistical method//When P is 0.5 is the medianvoidPtilethreshold (Double*SRC,Double*DST,DoubleP_value,intWidthintHeightintType) {/*0<p_value<1*/ intTotal_pix_count=width*height;intPix_count=0;intHist[gray_level];DoubleThreshold_value=0.0; Inithistogram (hist); Sethistogram (SRC, hist, width,height); for(intI=0; i<gray_level;i++) {pix_count+=hist[i];if(Pix_count>= (int)((Double) {threshold_value= (Total_pix_count*p_value)) {DoubleI Break; }} Threshold (Src,dst, width, height, threshold_value,type);}
Effect
An image with only two grayscale values, which is used to add 5% to the Gaussian noise,
Image not processed:
The histogram when not processed:
Observe the histogram to estimate the optimal threshold position:
The following uses different P-values to test the results:
As you can see, the second time (I've tried for a while ...) The results of the test can be the best results.
Lena Graph Processing test:
Summarize
First determine the P-value needs experience or experiment, so the P-tile method to adapt to some difficulties, and secondly, the impact of processing results of the factors are the target and background size, too large background too small or too large background too small, will have a great impact on the test results, followed by noise, Noise can also have an effect on experimental results.
Cond...
Grayscale image-The p-tile threshold for image segmentation threshold processing