Skip to content

Instantly share code, notes, and snippets.

@tJener
Created January 15, 2013 05:58
Show Gist options
  • Save tJener/4536546 to your computer and use it in GitHub Desktop.
Save tJener/4536546 to your computer and use it in GitHub Desktop.
#!/bin/sh
# Convert an image to YUV color space, then separating out the
# channels to visual the components of the YUV color space.
# Accept STDIN, use YUV colorspace, separate channels.
# 0. Black
# 1. Y channel
# 2. U channel negated
# 3. U channel
# 4. False-color U channel (0, 1-U, U)
# 5. V channel
# 6. V channel negated
# 7. False-color V channel (V, 1-U, 0)
# 8. Append black, Y channel, false-color U channel, and false-color
# V channel. Buggy: if we delete black image, the false-colors
# become greyscale.
# 9. Crop out previous append into four images. Delete the black,
# then re-append. Dump to STDOUT.
convert - -colorspace YUV -sampling-factor 4:2:2 -separate \
\( -clone 0 -fill black -colorize 100% \) \
\( -clone 0 \) \
\( -clone 1 -negate \) \
\( -clone 1 \) \
\( -clone 3 -clone 5 -clone 6 -combine \) \
\( -clone 2 \) \
\( -clone 2 -negate \) \
\( -clone 8 -clone 9 -clone 3 -combine \) \
-delete 0-2,5-6,8-9 -append \
-crop '100%x25%' -delete 0 -append -
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment