In this paper, we describe the fuzzy processing function of PHP using Gauss algorithm to realize image. Share to everyone for your reference, as follows:
<?phpclass image_blur{function Gaussian_blur ($srcImg, $savepath =null, $savename =null, $blurFactor =3) {$ Gdimageresource= $this->image_create_from_ext ($SRCIMG); $SRCIMGOBJ = $this->blur ($gdImageResource, $blurFactor); $temp = PathInfo ($SRCIMG); $name = $temp [' basename ']; $path = $temp [' dirname ']; $exte = $temp [' extension ']; $savename = $savename? $savename: $name; $savepath = $savepath? $savepath: $path; $savefile = $savepath. ' /'. $savename; $srcinfo = @getimagesize ($SRCIMG); Switch ($srcinfo [2]) {case1:imagegif ($SRCIMGOBJ, $savefile); break; Case2:imagejpeg ($SRCIMGOBJ, $savefile); Break Case3:imagepng ($SRCIMGOBJ, $savefile); Break Default:return ' save failed '; Save failed} return $savefile; Imagedestroy ($SRCIMGOBJ); }} $image _blur = new Image_blur (),//blurfactor value represents the degree of ambiguity, Savepath is directly overwritten when empty, Savename is empty directly with the original original $image_blur->gaussian_ Blur ($srcImg = "./5.jpg", $savepath =null, $savename =null, $blurFactor =5);? >
This method Baidu to, there is an interview I let me do, Baidu a pile of data to achieve.
The value of Blurfactor represents the degree of ambiguity
Effect Show:
Original:
Degree of ambiguity 2
Degree of ambiguity 3
Degree of ambiguity 4
Degree of ambiguity 5
Degree of ambiguity 6
Degree of ambiguity 7
The above is PHP using the Gaussian algorithm to implement the image of the fuzzy processing function sample content, more relevant content please pay attention to topic.alibabacloud.com (www.php.cn)!