Created
April 5, 2017 21:01
-
-
Save NeuroWinter/acac34e49a779a4b054d3bbf1559d331 to your computer and use it in GitHub Desktop.
Colour Space CheatSheet
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sonification commands - GAC workshop | |
IM = ImageMagick | |
Conversions | |
Image format conversion: | |
[1] convert image.jpg image.bmp | |
[2] convert image.jpg image.tga | |
Convert to RAW: | |
[3] convert image.jpg -depth 8 rgb:image.raw (rgb raw) | |
[4] convert image.jpg -depth 8 -interlace line rgb:image.raw (rgb raw with interlace option set) | |
[5] convert image.jpg -colorspace luv -separate -set colorspace srgb -combine -depth 8 -interlace plane rgb:image.raw (as above, with color space changed) | |
[6] convert image.jpg -depth 8 yuv:image.raw (yuv raw) | |
[7] convert image.jpg -depth 8 -sampling-factor 4:2:0 -interlace none yuv:image.raw (with set sampling factor and interlace) | |
[8] convert image.jpg -colorspace hwb -separate -set colorspace srgb -combine -depth 8 -sampling-factor 4:1:1 -interlace line yuv:image.raw (as above, with color space conversion) | |
Convert from RAW: | |
[9] convert -depth 8 -size WIDTHxHEIGHT rgb:image.raw result.jpg | |
[10] convert -depth 8 -size WIDTHxHEIGHT -interlace line rgb:image.raw result.png | |
[11] convert -depth 8 -size WIDTHxHEIGHT -interlace plane -colorspace srgb rgb:image.raw -separate -set colorspace luv -combine -colorspace srgb result.tiff | |
[12] convert -depth 8 -size WIDTHxHEIGHT yuv:image.raw result.jpg | |
[13] convert -depth 8 -size WIDTHxHEIGHT -sampling-factor 4:2:0 -interlace none yuv:image.raw result.png | |
[14] convert -depth 8 -size WIDTHxHEIGHT -sampling-factor 4:1:1 -interlace line -colorspace srgb yuv:image.raw -separate -set colorspace hwb -combine -colorspace srgb result.tiff | |
Additional options (before result file): | |
-normalize (normalize histogram) | |
-gamma VALUE (adjust gamma) | |
-equalize (equalize historgram) | |
-auto-level (auto adjust color levels) | |
-quality VALUE (compression quality, eg. jpg, png) | |
+dither -colors VALUE (reduce colors number without dithering) | |
-colors VALUE (reduce colors number with dithering) | |
For example: | |
[15] convert image.jpg -equalize -normalize +dither -colors 11 -quality 50 result.jpg | |
Create image frames from animated gif: | |
[16] convert animation.gif -coalesce frames%04d.jpg | |
Create animated gif from frames: | |
[17] convert -delay 6 frames*.jpg -loop 0 result.gif | |
Convert RAW to WAV: | |
[18] sox -r SAMPLE_RATE -e CODING -b BITS -c CHANNELS -t TYPE input.raw result.wav | |
where: | |
SAMPLE_RATE: number from 1000 to 200000+, eg. 44100, 22050, 192000 | |
CODING: singed-interger, unsigned-integer, a-law, u-law, float | |
BITS: bits per sample: 8, 16 or 24, 32 for float | |
CHANNELS: number of channels, 1-mono, 2-stereo | |
TYPE: s8, u8, s16, u16, s24, u24, al, ul, f32 | |
For example: | |
[19] sox -r 44100 -e a-law -b 8 -c 2 -t al input.raw output.wav | |
Convert WAV to RAW: | |
[20] sox input.wav -r SAMPLE_RATE -e CODING -b BITS -c CHANNELS -t TYPE result.raw | |
Convert part of the VIDEO to frames, 10 seconds starting from 01m02s | |
[21] ffmpeg -ss 00:01:02 -t 10 -i video.mp4 -f image2 -q:v 1 frame%04d.jpg | |
Combine back: | |
[22] ffmpeg -f image2 -i frame%04d.jpg -r 25 video.mp4 | |
[23] ffmpeg -f image2 -start_number 11 -i frame%04d.jpg -r 25 video.mp4 (start from frame 11) | |
Convert video to raw: | |
[24] ffmpeg -ss 00:01:02 -t 5 -i video.mp4 -f rawvideo -pix_fmt yuv420p result.yuv | |
Convert raw to video: | |
[25] ffmpeg -f rawvideo -video_size 1280x720 -pix_fmt yuv420p -i result.yuv output.mp4 | |
Lists | |
List of image formats in IM: | |
convert -list format | |
List of color spaces in IM: | |
convert -list colorspace | |
List of RAW interlace methods in IM: | |
Line (each line RRR...GGG...BBB...) | |
None (RGBRGBRGB...) | |
Plane (whole image RRR...GGG...BBB...) | |
List of YUV sampling factors in IM: | |
4:1:0 | |
4:1:1 | |
4:2:0 | |
4:2:2 | |
4:4:4 | |
List of rawvideo formats in FFMPEG: | |
ffmpeg -pix_fmts | |
Batch processing | |
Convert all images from folder to raws: | |
[26] for f in *.jpg; do convert $f -depth 8 rgb:${f}.raw; done | |
Convert all raws to wavs: | |
[26*] for f in *.raw; do sox -r 44100 -e a-law -b 8 -c 2 -t al $f ${f}.wav; done | |
Operate on WAVs in Audacity (File->Apply chain). All results are now in ‘cleaned’ folder. | |
Change folder: | |
cd cleaned | |
Convert all wavs to raws: | |
[27*] for f in *.wav; do sox $f -r 44100 -e a-law -b 8 -c 2 -t al ${f}.raw; done | |
Convert raw to images: | |
[27] for f in *.raw; do convert -depth 8 -size WIDTHxHEIGHT rgb:$f ${f}.jpg; done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment