Gray image--p-tile threshold of image segmentation threshold processing

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.