two

actually the number two IRL

Thanks for playing, everyone. I'll see you around.


ROU
@ROU

I found out about Monolith, which is a good start, but unfortunately I still have to manually separate the header data and recombine it later (technically I'm still using my SoX batch files - stripped down to a couple lines - but I still have to manually rename files and it's only marginally better than my Audacity raw data days).


two
@two

I really feel this, having once gone on a Coding Odyssey to make a simple program that just puts a circle on the screen that follows the mouse cursor. It really seems like the simplest stuff is the hardest to learn how to do.

...and I got curious about bitwise xor of image data so I worked out a sort-of-not-really convenient method with ImageMagick, some code off Github that I'm amazed wasn't a virus, and an extremely fragile shell script:

#!/bin/sh

SIZE=`identify -format "%wx%h" "$1"`
convert $1 $1.rgb
convert $2 $2.rgb
xor-files $1.rgb $2.rgb > xor_temp.rgb
convert -size $SIZE -depth 8 xor_temp.rgb $3

Of course because I have no idea where they tell you how to write shell scripts this is hacked together from the parts of another script which I could work out what they did, and getting everything to actually work together was somewhat frustrating. This isn't a general solution to the problem, but it is pretty fun to mess with now that I have it working.

Vertical lines of digital noise and text, with parts of the above script, various convert errors, and the MacOS window buttons barely visible

You must log in to comment.

in reply to @ROU's post:

I used to have all sorts of tools I wanted to make like this, and then I learned about https://observablehq.com and it helped me out a ton. While on its face, it's supposed to be a site for helping people do data visualization, I found it to be helpful for abstracting out the hosting part of simple web apps that are just running Javascript with some inputs or controls to interact with.

https://observablehq.com/@iamgrahamallen/rectangular-subsampling-of-images

Whats extra cool about it is that each "cell" on the website can be opened up to see the underlying code that's being used to render it, thereby teaching you how to implement it yourself in a "go-at-your-own-pace" tutorial that has a live feedback loop. You can just try editing any cell on any page you look at there and see how it changes things. There's also good forking and importing stuff across published observablehq notebooks, so if someone else has solved your problem, you can just import what worked for them into your stuff.

Also, there's plenty of tutorials on observablehq for how the site itself works, which hopefully would help build up a toolkit of things that eventually could allow you to do this xor of images

this is relatively easy to do in processing, though it dips lightly into some more complicated material. but, if you already understand the premise it’s nothing especially heinous — i might have some time today to make a little tutorial on making a custom program that does something like this

this is pretty doable in python with just pillow installed, and not too much complexity:

from itertools import product
from sys import argv
from PIL import Image


def xor_images(a, b):
    assert a.mode in ("RGB", "RGBA")
    assert b.mode in ("RGB", "RGBA")
    aw, ah = a.size
    bw, bh = b.size
    w, h = min(aw, bw), min(ah, bh)
    result = Image.new("RGB", (w, h))

    for coord in product(range(w), range(h)):
        ar, ag, ab, *_ = a.getpixel(coord)
        br, bg, bb, *_ = b.getpixel(coord)
        result.putpixel(coord, (ar ^ br, ag ^ bg, ab ^ bb))

    return result


if __name__ == '__main__':
    a_path, b_path, output_path = argv[1:]
    xor_images(Image.open(a_path), Image.open(b_path)).save(output_path)