in some order idk
the two nonlinearities involved in (a scalar version of) converting RGB to CIELAB.
f(x) converts RGB to linear sRGB. g(x) is used in converting linear sRGB to XYZ.
the black line is the combination of the two, not quite linear.
| # Arithmetic coding compressor and decompressor for binary strings. | |
| # via: http://www.inference.org.uk/mackay/python/compress/ac/ac_encode.py | |
| # main page: http://www.inference.org.uk/mackay/python/compress/ | |
| # this has been cleaned up (passes pycodestyle) and ported to python 3. | |
| # default prior distribution | |
| BETA0 = 1 | |
| BETA1 = 1 | |
| M = 30 |
| // arbitrary terminology i made up on the spot: | |
| // "entry" = code as exposed to user, in ASCII. | |
| // "code" = code as indices into lut, used internally. | |
| #include <stdint.h> | |
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <string.h> | |
| typedef uint32_t u32; |
| #!/usr/bin/env bash | |
| set -e | |
| # set this as needed! | |
| rom="Legend of Zelda, The - Ocarina of Time (U) (V1.0) [!].z64" | |
| output="reconstructed.z64" | |
| gcc_flags="-std=gnu11 -Wall -O3 -s" |
| # Example Huffman coding implementation | |
| # Distributions are represented as dictionaries of { 'symbol': probability } | |
| # Codes are dictionaries too: { 'symbol': 'codeword' } | |
| def huffman(p): | |
| '''Return a Huffman code for an ensemble with distribution p.''' | |
| # Base case of only two symbols, assign 0 or 1 arbitrarily | |
| if len(p) == 2: | |
| return dict(zip(p.keys(), ['0', '1'])) |
| -- This is free and unencumbered software released into the public domain. | |
| -- For more information, please refer to <http://unlicense.org/> | |
| local charset = ("\ | |
| \x00☺☻♥♦♣♠•◘○◙♂♀♪♫☼\ | |
| ►◄↕‼¶§▬↨↑↓→←∟↔▲▼\ | |
| !\"#$%&'()*+,-./\ | |
| 0123456789:;<=>?\ | |
| @ABCDEFGHIJKLMNO\ | |
| PQRSTUVWXYZ[\\]^_\ |
| /* Clocks (v1) | |
| * Portable Snippets - https://github.com/nemequ/portable-snippets | |
| * Created by Evan Nemerson <evan@nemerson.com> | |
| * | |
| * To the extent possible under law, the authors have waived all | |
| * copyright and related or neighboring rights to this code. For | |
| * details, see the Creative Commons Zero 1.0 Universal license at | |
| * https://creativecommons.org/publicdomain/zero/1.0/ | |
| * | |
| * Modified by Connor Olding, 2017 |
| int validate(const char *key) { | |
| int magic = 3; | |
| int count = 0; | |
| for (char c; (c = *key); key++) { | |
| if (c < '0' || c > '9') continue; | |
| int v = c - '0'; | |
| if (++count == 13) { | |
| // final character. | |
| return magic % 10 == v; | |
| } else { |
in some order idk
the two nonlinearities involved in (a scalar version of) converting RGB to CIELAB.
f(x) converts RGB to linear sRGB. g(x) is used in converting linear sRGB to XYZ.
the black line is the combination of the two, not quite linear.
| #!/usr/bin/env python3 | |
| # find duplicate images given a hamming distance threshold. | |
| # employs dhash to do the heavy lifting. | |
| # doesn't recurse into "./_duplicate/" so you can dump things there if you wish. | |
| # dependencies: pillow, dhash | |
| import sys, os, os.path, pickle | |
| from PIL import Image | |
| import dhash |