PHP using a Gaussian algorithm to implement the image of the fuzzy processing function Example _php tips

Source: Internet
Author: User
Tags php class

This article illustrates the use of a Gaussian algorithm in PHP to implement the fuzzy processing function of the image. Share to everyone for your reference, specific as follows:

<?php class image_blur{function Gaussian_blur ($srcImg, $savepath =null, $savename =null, $blurFactor =3) {$gdImageRe
    Source= $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); 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 (); The Blurfactor value represents the ambiguity degree, Savepath is the empty time direct cover, the savename is the empty direct use formerly known as $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 information to achieve.

The value of the Blurfactor represents the degree of ambiguity

Effect Display:

Original:

Blur degree 2

Blur degree 3

Blur degree 4

Blur degree 5

Blur degree 6

Blur degree 7

More about PHP Interested readers can view the site topics: "PHP graphics and pictures Operating skills summary", "PHP file Operation Summary", "PHP Array" operation Skills Encyclopedia, "PHP Basic Grammar Introductory Course", "PHP Operations and Operator Usage Summary", " Introduction to PHP object-oriented programming program, "PHP Network Programming Skills Summary", "PHP string (String) Usage Summary", "Php+mysql database Operation Tutorial" and "PHP common database Operation Skills Summary"

I hope this article will help you with the PHP program design.

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.