Related Articles

Related Articles

PHP | Gmagick despeckleimage() Function
  • Last Updated : 17 Jan, 2020

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
Recommended Articles
Page :