PHP | Gmagick despeckleimage() Function

The Gmagick::despeckleimage() function is an inbuilt function in PHP which is used to reduce the speckle noise in an image while preserving the edges of the original image.

Syntax:

Gmagick Gmagick::despeckleimage( void )

Parameters: This function doesn’t accept any parameter.



Return Value: This function returns a Gmagick object on success.

Exceptions: This function throws GmagickException on error.

Used Image: To capture the canvas area.

Below given programs illustrate the Gmagick::despeckleimage() function in PHP:

Program 1:

filter_none

edit
close

play_arrow

link
brightness_4
code

<?php
  
// Create a new Gmagick object
$gmagick = new Gmagick('geeksforgeeksgnoised.png');
  
// Apply the despeckle function
$gmagicknew = $gmagick->despeckleimage();
  
// Output the image
header('Content-type: image/png');
echo $gmagicknew;
?>

chevron_right


Output:

Program 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

<?php
  
// Create a new Gmagick object
$gmagick = new Gmagick('./geeksforgeeksnoised.png');
  
// Get the image histogram
$pixels = $gmagick->getimagehistogram();
  
echo "Color of 100th pixel before removing noise: ";
echo $pixels[99]->getcolor();
  
// Apply the despeckle function
$gmagicknew = $gmagick->despeckleimage();
  
// Get the image histogram
$pixels = $gmagick->getimagehistogram();
  
echo "<br>Color of 100th pixel after removing noise: ";
echo $pixels[99]->getcolor();
?>

chevron_right


Output:

Color of 100th pixel before removing noise: rgb(0, 6682, 8995)
Color of 100th pixel after removing noise: rgb(3084, 5397, 7967)

Reference: https://www.php.net/manual/en/gmagick.despeckleimage.php




My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.