PHP Classes

How Can PHP Compare Image Similarity and Improve Accuracy Using Human Verification With the Package PHP ICSLA: Compare images and learning from human evaluation

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2025-03-14 (Yesterday) RSS 2.0 feedNot yet rated by the usersTotal: Not yet counted Not yet ranked
Version License PHP version Categories
phpicsla 1.0GNU General Publi...5PHP 5, Graphics, Artificial intelligence
Description 

Author

This package can compare images learning from human evaluation.

It provides a class that can process uploaded image files, scale the images to make them have the same size, convert the images to gray scale, and compare the gray scale level of all points.

The class can also take the input of a human to confirm or deny if the images are similar and stores the results in a CSV file.

Picture of Roberto Aleman
  Performance   Level  
Name: Roberto Aleman <contact>
Classes: 21 packages by
Country: Venezuela Venezuela
Innovation award
Innovation award
Nominee: 12x

Winner: 1x

Example

<?php

/* PHP Image Comparison with Simple Learning Algorithm v1.02
Author: Roberto Aleman
ventics.com */

include 'config.php';
include
'ImageComparator.php';

$comparator = new ImageComparator($maxFileSize, $allowedTypes, $uploadDir, $learningFile);

if (
$_SERVER['REQUEST_METHOD'] === 'POST') {
   
$uploadResults = $comparator->processUploads($_FILES['image1'], $_FILES['image2']);

    if (isset(
$uploadResults['imagePath1'], $uploadResults['imagePath2'])) {
       
$imagePath1 = $uploadResults['imagePath1'];
       
$imagePath2 = $uploadResults['imagePath2'];

        echo
'<div style="display: flex;">';
        echo
'<img src="' . $imagePath1 . '" style="max-width: 300px; margin-right: 10px;">';
        echo
'<img src="' . $imagePath2 . '" style="max-width: 300px;">';
        echo
'</div><br>';

       
$similarity = $comparator->compareImages($imagePath1, $imagePath2);
        echo
"Similarity percentage: " . $similarity . "%\n";

        echo
'<form method="post" action="feedback.php">';
        echo
'<input type="hidden" name="imagePath1" value="' . $imagePath1 . '">';
        echo
'<input type="hidden" name="imagePath2" value="' . $imagePath2 . '">';
        echo
'<input type="hidden" name="calculatedSimilarity" value="' . $similarity . '">';
        echo
'Is the similarity calculation adequate? (Does it correctly reflect whether the images are similar or not?)<br>';
        echo
'<input type="radio" name="response" value="y"> Yes<br>';
        echo
'<input type="radio" name="response" value="n"> No<br>';
        echo
'<input type="submit" value="Submit">';
        echo
'</form>';

       
$learningResults = $comparator->analyzeLearning();
        if (
$learningResults) {
            echo
"Average similarity for similar images: " . $learningResults['averageSimilar'] . "%\n";
            echo
"Average similarity for different images: " . $learningResults['averageDifferent'] . "%\n";
        }
    } elseif (isset(
$uploadResults['errors'])) {
        foreach (
$uploadResults['errors'] as $error) {
            echo
$error . "<br>";
        }
    }
}
?>

<!DOCTYPE html>
<html>
<head>
    <title>Image Comparison</title>
</head>
<body>
    <h1>Compare Images</h1>
    <form method="post" enctype="multipart/form-data">
        <label for="image1">Image 1:</label>
        <input type="file" name="image1" id="image1" accept="image/*" required><br><br>

        <label for="image2">Image 2:</label>
        <input type="file" name="image2" id="image2" accept="image/*" required><br><br>

        <input type="submit" value="Compare">
    </form>
</body>
</html>


Details

phpicsla

PHP Image Comparison with Simple Learning Algorithm

This PHP code implements a basic image comparison system with machine learning. It allows users to upload two images, calculates a similarity percentage between them, and requests feedback to improve the calculation's accuracy.

please check documentation.html file..


  Files folder image Files (7)  
File Role Description
Plain text file config.php Aux. Configuration script
HTML file documentation.html Doc. Documentation
Plain text file example.php Example Example script
Plain text file feedback.php Example Example script
Plain text file ImageComparator.php Class Class source
Plain text file LICENSE Lic. License text
Plain text file README.md Doc. Documentation

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads  
 100%
Total:0
This week:0