Simple Implementation Image Processing (Noise Reduction) in PHP
In this opportunity, I will explain the application that I did when I was in college, about Digital Image Processing but with PHP programming language. Before there I will explain about digital image processing.
Image processing is a method to convert an image into digital form and perform some operations on it, in order to get an enhanced image or to extract some useful information from it. It is a type of signal dispensation in which input is image, like video frame or photograph and output may be image or characteristics associated with that image. Usually Image Processing system includes treating images as two dimensional signals while applying already set signal processing methods to them.
Image processing basically includes the following three steps.
• Importing the image with optical scanner or by digital photography.
• Analyzing and manipulating the image which includes data compression and image enhancement and spotting patterns that are not to human eyes like satellite photographs.
• Output is the last stage in which result can be altered image or report that is based on image analysis.
Purpose of Image processing
The purpose of image processing is divided into 5 groups. They are:
- Visualization - Observe the objects that are not visible.
- Image sharpening and restoration - To create a better image.
- Image retrieval - Seek for the image of interest.
- Measurement of pattern – Measures various objects in an image.
- Noise Reduction – Distinguish the objects in an image.
Resource
In this opportunity I will explain the root of the problems and solutions, although there are many applications that can be installed to perform image processing basically many who have not understood the process of image processing from the beginning like what.
At this time I will explain about Image Noise reduction to create a better image In PHP.
This code is for uploading photos
This code is for image processing
function modus($array) $val = 1; for the results of the process as shown below https://github.com/danielniklaus/Website/tree/master/NoiseReduction<?php
function statistik($array, $output = 'modus'){
if(!is_array($array)){
return FALSE;
}else{
switch($output){
case 'modus':
$v = array_count_values($array);
arsort($v);
foreach($v as $k => $v){$total = $k; break;}
break;
}
return $total;
}
}
{
$red = $array[9];
for ($i = 1; $i < imagesx($images_source) - 1; $i++)
{
for ($j = 1; $j < imagesy($images_source) - 1; $j++)
{
$t_j = $j - 1;
$t_i = $i - 1;
for ($index = 0; $index < 9; $index++)
{
$redd[$index]= $red;
$greenn[$index] =$green;
$bluee[$index] = $blue;
if ($t_j - ($j - 1) == 2)
{
$t_i += 1;
$t_j = $j - 1;
}
else {
$t_j += 1;
}
}
}
}
}
$dir = './noise/';
$dir1 = './noise1/';
foreach(glob($dir.'.') as $v){
unlink($v);
}
$img = $_POST["gambar"];
$valgas =$_POST["ukuran"];
$image = imagecreatefromjpeg($img);
$random_image_id = rand();
$create_new_img = $dir.$random_image_id.$img;
$gaussian = array(
array(1.0, 2.0, 1.0),
array(3.0, 4.0+$valgas, 3.0),
array(1.0, 2.0, 1.0)
);
imageconvolution($image, $gaussian, 15, 0);
imagejpeg($image, $create_new_img);
imagedestroy($image);
$vas = 10;
$img1 = $create_new_img;
$images_source = imagecreatefromjpeg($img1);
for($x=0;$x<imagesx($images_source);++$x){
for($y=0;$y<imagesy($images_source);++$y){
$index = imagecolorat($images_source, $x, $y);
$rgb = imagecolorsforindex($images_source, $index);
$cal_red = $val($rgb['red']-$vas)+$vas;
$cal_green = $val($rgb['green']-$vas)+$vas;
$cal_blue = $val*($rgb['blue']-$vas)+$vas;
$color = imagecolorallocate($images_source, $cal_red, $cal_green, $cal_blue);
imagesetpixel($images_source, $x, $y, $color);
}
}
$random_image_id = $val;
$create_new_imgs = $dir.$random_image_id.$img;
$create_new_imgs1 = $dir1.$random_image_id.$img;
imagejpeg($images_source, $create_new_imgs, 600);
imagejpeg($images_source, $create_new_imgs1, 600);
imagedestroy($images_source);
print '';
?>
Proof Of Work
GitHub Link
Posted on Utopian.io - Rewarding Open Source Contributors
Your contribution cannot be approved because it does not follow the Utopian Rules, and is considered as plagiarism. Plagiarism is not allowed on Utopian, and posts that engage in plagiarism will be flagged and hidden forever.
Despite providing a source link, you cannot plagiarise the main body of your article.
You can contact us on Discord.
[utopian-moderator]
Sorry sir, I am a beginner in steemit and utopian, I do not know it contains plagiarism, because I put the source. Thanks for your information sir