Skip to content

Instantly share code, notes, and snippets.

View arstropica's full-sized avatar

Akin Williams arstropica

View GitHub Profile
@arstropica
arstropica / RedisCache.php
Last active February 10, 2016 22:10
ZF2 RedisCache Driver - Restores the deleteByRegex, deleteByPrefix and deleteBySuffix methods in Doctrine 2's Zend Framework 2 RedisCache Driver
<?php
namespace Application\ORM\Tools\Cache;
use Doctrine\Common\Cache\RedisCache as BaseCache;
/**
* Redis Cache Class
*
* Restores the deleteByRegex, deleteByPrefix and deleteBySuffix methods
@arstropica
arstropica / ffmpeg_gif_converter.sh
Created November 29, 2020 21:26
Converts a video or image sequence to a animated gif with ffmpeg
#!/usr/bin/env bash
die () {
echo >&2 "$@"
exit 1
}
palette="./palette.png"
temp="./_temp.mp4"
path=false
file=false
@arstropica
arstropica / imgcompare.py
Last active March 3, 2023 15:59
Finds the 2 most similar images in an image sequence or specific image.
#!/usr/bin/env python
"""
Finds the 2 most similar images in an image sequence or specific image.
Requires:
- imgcompare==2.0.1
- python==3.7.10
"""
from imgcompare import is_equal, image_diff_percent, image_diff, ImageCompareException
import os
import sys
import numpy as np
import skvideo.io
from pprint import pprint
def equalize_histogram(image, number_bins=256):
image_histogram, bins = np.histogram(image.flatten(), number_bins)
cdf = image_histogram.cumsum()
cdf = (number_bins - 1) * cdf / cdf[-1] # normalize