2

What is possible image format of Y800 which is available in OpenCV? is it always referred to GRAY? Any other options?

Thanks in advance.

alfa_80
  • 427
  • 1
  • 5
  • 21
  • Y800 is a monochrome format - what could it be except GRAY? Can you reword your question if I misunderstood? – Roger Rowland May 02 '13 at 15:05
  • Yes, it's monochrome, but is it the same as GRAY defined in OpenCV? – alfa_80 May 02 '13 at 15:07
  • 1
    Ok, according to this - http://www.fourcc.org/yuv.php - `Y800` is the same as `GREY` (not GRAY) and maybe also the same as `Y8`. – Roger Rowland May 02 '13 at 15:11
  • If you said so, that means for the following line `cv::cvtColor(frame, gray_image, CV_BGR2GRAY);`, that means gray_image that is meant to be converted to gray format is not the same as Y800. Am I right, according to your answer? – alfa_80 May 02 '13 at 15:14
  • 1
    That is correct (as I understand things) - `CV_BGR2GRAY` gives a greyscale image format, while `Y800` is a FOURCC video codec. They are not the same, but they are both greyscale. – Roger Rowland May 02 '13 at 15:21
  • Also see https://stackoverflow.com/questions/33142837/what-image-formats-other-than-y800-does-zbarimageimage-accept – Stéphane Sep 04 '19 at 02:39

1 Answers1

0

Eight years later, I stumbled upon this question. I want to add an answer with regard to OpenCV 4.2.0.

For videos, this version features an ffmpeg backend which natively understands the FOURCC identifier "Y800". Confusingly, it does not take one-channel grayscale (CV_8UC1) frames, but the usual OpenCV three-channel BGR (CV_8UC3):

cv::VideoWriter vw("y8.avi", cv::VideoWriter::fourcc('Y', '8', '0', '0'), 60, frame.size());
vw.write(frame); // note: frame must be 8UC3!

OpenCV supports the grayscale mode in number of image file formats, including, but not limited to PGM, PNG and JPEG.

cv::imwrite("gray.pgm", image);
Hermann
  • 604
  • 7
  • 23