Câu trả lời:
Nếu bạn đã imagemagickcài đặt,
convert source.jpg -colorspace Gray destination.jpg (true grayscale only)
convert source.jpg -monochrome destination.jpg (true black and white)
convert source.jpg -separate destination.jpg (separate into gray channels)
Nếu bạn không quan tâm về việc mất các tập tin ban đầu: mogrify -colorspace Gray file.
AxBx3RGBhình ảnh thành mộtAxBx1hình ảnh thang độ xám kênh duy nhất.