Skip to content

Instantly share code, notes, and snippets.

@inian
Created June 27, 2019 09:18
Show Gist options
  • Save inian/3f2d86579996e17eabd08aba1b5e2580 to your computer and use it in GitHub Desktop.
Save inian/3f2d86579996e17eabd08aba1b5e2580 to your computer and use it in GitHub Desktop.
Convert image to Y, Cb, Cr components
convert image.png -colorspace YUV -sampling-factor 4:2:2 -separate \
\( -clone 0 \) \
\( -clone 1 -fill black -colorize 100% \) \
\( -clone 1 -negate \) \
\( -clone 1 \) \
image_b_temp.png
convert image_b_temp-4.png image_b_temp-5.png image_b_temp-6.png -channel RGB -combine image_b.png
convert image.png -colorspace YUV -sampling-factor 4:2:2 -separate \
\( -clone 2 \) \
\( -clone 2 -negate \) \
\( -clone 2 -fill black -colorize 100% \) \
image_r_temp.png
convert image_r_temp-3.png image_r_temp-4.png image_r_temp-5.png -channel RGB -combine image_r.png
mv image_b_temp-0.png image_y.png
rm image_b_temp*.png
rm image_r_temp*.png
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment