{"id":18496293,"url":"https://github.com/ridhwaans/image-comparison","last_synced_at":"2025-06-22T08:32:36.131Z","repository":{"id":151870560,"uuid":"306721724","full_name":"ridhwaans/image-comparison","owner":"ridhwaans","description":"image comparisons","archived":false,"fork":false,"pushed_at":"2021-01-19T14:47:22.000Z","size":514,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-14T04:32:24.977Z","etag":null,"topics":["csv","demo","images","ssim"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ridhwaans.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-10-23T18:52:06.000Z","updated_at":"2023-08-27T05:34:08.000Z","dependencies_parsed_at":"2023-05-13T02:45:20.730Z","dependency_job_id":null,"html_url":"https://github.com/ridhwaans/image-comparison","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ridhwaans/image-comparison","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ridhwaans%2Fimage-comparison","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ridhwaans%2Fimage-comparison/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ridhwaans%2Fimage-comparison/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ridhwaans%2Fimage-comparison/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ridhwaans","download_url":"https://codeload.github.com/ridhwaans/image-comparison/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ridhwaans%2Fimage-comparison/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261262076,"owners_count":23132379,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["csv","demo","images","ssim"],"created_at":"2024-11-06T13:28:50.652Z","updated_at":"2025-06-22T08:32:31.110Z","avatar_url":"https://github.com/ridhwaans.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"`https://github.com/ridhwaans/image-comparison`\n- [image comparison](#image-comparison)\n  * [description](#description)\n    + [example input CSV](#example-input-csv)\n  * [assumptions](#assumptions)\n  * [questions and answers](#questions-and-answers)\n  * [installation instructions](#installation-instructions)\n  * [notes on design and implementation](#notes-on-design-and-implementation)\n  * [testing](#testing)\n  * [license](#license)\n\n# image comparison\n\n## description\nThis program takes in a CSV containing the filenames of different image files. Then, the program reads those files and performs an image comparison on two sets of images. It then outputs a new CSV containing the numerical difference between each pair of images and the comparison elapsed time, in addition to the filenames of those images.\n\n### example input CSV\n```\nimage1,image2\naa.png,ba.png\nab.png,bb.png\nac.png,ac.gif\nad.png,bd.png\n```\n\n## assumptions\nThere were some ambiguities in the requirements and I made some assumptions\nAssumptions:\n1) Image files must be in the same directory as the python solution\n2) Input csv must have only two headers 'image1' and 'image2'\n3) Input csv must have a comma separated format\n4) Supported image types are .png, .gif, .jpg, .jpeg, .bmp\n5) There is no requirement if the pairs of images have equal size dimensions\n6) The absolute filepath of the input csv must be given if not in the same directory \n\n## questions and answers\n\nQ) How do you know if your code works?  \nA) I like to automate testing such as unit tests, integration and end-to-end tests if any that verify the functionality of the features \u0026 pieces of the code. I feel safe and confident as a developer to ship working working code that is backed by a test suite. Also, code reviews should be enforced which promotes code maintainability for all stakeholders. See [testing](#testing) for more information.  \n\nQ) How are you going to teach Bjorn how to use the program?  \nA) Writing good documentation and test coverage for the program will explain its usage to Bjorn at a high level and low level. Making sure the test cases run also helps to see the flow. Also, I can schedule a walkthrough or over the shoulder meeting if new users have difficulties.  \n\nQ) Your manager Jeanie is assigning you to a different task and is making Ferris the maintainer of your application. How do you make sure he succeeds?  \nA) It is a good practice to keep your code well-documented with inline comments and design docs before checking in, because it brings visibility and tracks edge cases or specific uses which may not be clearly apparent. Code reviews also help bounce ideas off one another, familiarize Bjorn and other maintainers with your work, so that they will be able to hit the ground running.  \n\nQ) How are you ensuring Bjorn gets the latest version of your application?  \nA) It is a good practice to introduce a continuous integration \u0026 continuous deployment system across the project. With version control \u0026 continuous delivery, Bjorn the user will be able to use the latest version of the application, get notified of upcoming updates and rollback any changes if necessary.  \nThe application can also be containerized so Bjorn is able to get the latest versions. Using Docker or similar orchestration, one can setup service discovery and provide runnable images that help with platform independence  \n\n## installation instructions\n\n1) Make sure git is installed by running `git --version`, if not installed, see below:  \na) if on Mac,\n```\n# Check for Homebrew and install it if missing\nif test ! $(which brew)\nthen\n\techo \"Installing Homebrew...\"\n\truby -e \"$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)\"\nfi\nbrew update\nbrew tap homebrew/versions\nbrew upgrade --all\nbrew install git\n```\nif on Linux ubuntu\n```\napt update\napt install git\n```\nOther Linux package managers include pacman, yum, rpm etc  \n\n2) Install python and pip through a version manager or a standalone version. It is *recommended* to install a python version manager such as `pyenv-virtualenv` to manage development environments. *(skip to step 3)*  \n\na) if on Mac, in Terminal\n```\n# install python and pip\nbrew install python\nbrew install python3\nsudo easy_install pip\n```\nb) if on Linux ubuntu, in Terminal\n```\napt install python\napt install python3\napt install python-pip python-dev build-essential\n```\nc) if on Windows, get linux and windows terminal\n```\nGET Windows Subsystem for Linux https://docs.microsoft.com/en-us/windows/wsl/install-win10#update-to-wsl-2\nGET Ubuntu 20.04 LTS (Focal Fossa) from the Microsoft Store\nGET Windows Terminal https://docs.microsoft.com/en-us/windows/terminal/get-started\n```\nFollow the instructions on how to install python on Linux ubuntu from step 2(b) previously  \n\n3) Install `pyenv-virtualenv`  \nFollow the instructions on https://github.com/pyenv/pyenv-virtualenv  \n\n*(optional)* installing as submodules\n```\ngit init\ngit submodule add -f git@github.com:pyenv/pyenv.git .pyenv\ncd .pyenv\ngit submodule add -f git@github.com:pyenv/pyenv-virtualenv.git plugins/pyenv-virtualenv\n```\n\n*(optional)* 4) Install from web  \nvisit `https://www.python.org/downloads/` for the installer  \n\n5) Download the project and install dependencies  \na) In terminal, clone the `image-comparison` GitHub repository using the provided HTTPS or SSH URL  \nb) `cd` to the `image-comparison` directory containing the python source code, csv and image files  \nc) run `pip install`  \n\n6) Run `python image_comparison.py`  \na) As noted in the assumptions above, the image files and input csv must exist in the same directory as the python program  \nb) Given the original CSV, enter `input_csv.csv` when asked at the python question prompt  \nc) Enter a new filename for the output csv when asked at the python question prompt  \nd) Exit the program `ctrl-c or ^C`. Open the output csv which should be saved in the same directory as the python program\n\n7) Testing\nRun `python -m pytest image_comparison.py`, see line `133` or [testing](#testing) for more information  \n\n## notes on design and implementation  \nI have kept the code clean and organized into single responsibility methods, guided by SOLID/DRY principles. \nI wanted to keep requiring non-standard, third party libraries at a mininum to reduce bloat so the solution is lightweight. There is some defensive programming and error checking such that exceptions are handled gracefully \u0026 there are no silent failures.  \nI investigated different implementations for image comparison, and I found approaches such as `pillow imagechops` difference, `mean squared error` in `numpy` to be useful. In the final solution, I used the `opencv2` \u0026 `skimage.measure` library to measure a structural similarity index and return the difference between a pair of images.  \n\n## testing  \nDue to brevity of time, full coverage is due to be completed. Unit tests are for demonstration purposes.  \nLines `142` to `156` includes `pytest` python tests for testing the edge cases of `getCsv` of the `ImageComparison` class  \nAdditional test cases to do include:  \n- unit tests for other components' functionality,  \n- checking for a .csv extension,  \n- checking for image type extension,  \n- testing the error checking logic with more edge cases  \n\n## license\nThis work is licensed under GPLv3 - see the [LICENSE](LICENSE) file for details\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fridhwaans%2Fimage-comparison","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fridhwaans%2Fimage-comparison","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fridhwaans%2Fimage-comparison/lists"}