Answer the question
In order to leave comments, you need to log in
Removing noise on an image using php?
Hello. Wrote a function to remove noise from an image.
function removeNoise($image)
{
$width = imagesx($image);
$height = imagesy($image);
$result = imagecreatetruecolor($width, $height);
$white = imagecolorallocate($result, 255, 255, 255);
imagefilledrectangle($result, 0, 0, $width + 1, $height, $white);
for($x = 1; $x <= $width; $x++)
{
for($y = 1; $y <= $height; $y++)
{
$count = countAroundPixels($image, $x, $y);
if ($count > 4)
{
$color = imagecolorallocate($result, 0, 0, 0);
imagesetpixel($result, $x, $y, $color);
}
}
}
return $result;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question