PHP uses Gaussian algorithm to implement image Blur function example

Source: Internet
Author: User
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)!

  • 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.