M
M
Muhammad2015-02-22 23:23:52
PHP
Muhammad, 2015-02-22 23:23:52

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;
 
}

The result can be seen in the attached file. As you can see, the result is not important. "Bite off" part of the numbers. Maybe there are ways to improve the cleaning algorithm?
1:
06af194bf07e433c954eefccf7098b23.png
2:
66666fa4d54c4769a63edea9a4da5cd3.png
3:
6ed27a69392d4b42ada352580846efc9.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Eddy_Em, 2015-02-22
@muhammad_97

I don’t understand why puffy is here, but on specific examples, an elementary median filter would perfectly solve the problem!

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question