1

On either TurboJpeg or the underlying libJpeg APIs - is there a simple function for extracting the Y component from the Ycbcr (after I've already read the image)?

I know I can loop over the data and extract the bytes. Isn't this already implemented?

mousomer
  • 2,632
  • 2
  • 24
  • 25

1 Answers1

1

When decompressing/decoding, use the TJPF_GRAY format, it discards the colour information and only the Y (luminescence) remains.

See the this part of the API for reference, as well as that part if you are willing to transform it, or this function if you are willing to decode it directly into a gray-scale image.

Theolodis
  • 4,977
  • 3
  • 34
  • 53
  • So, if I need both the YUV and the Y components, then I load it as TJPF_GRAY and then use tjTransform to get the Y component. Got it right? – mousomer Apr 27 '14 at 13:05
  • `TJPF_GRAY` is equal to the Y component. If you need both, the YUV and the Y you got to decode it as YUV and do the transform with `tjDecodeYUV` to a "RGB" with 1 byte per pixel, the luminescence/gray/Y part. – Theolodis Apr 27 '14 at 13:08
  • And for that I need the new API 1.3.1 – mousomer Apr 27 '14 at 13:22
  • 1
    @mousomer you might maybe even need the version 1.4, but as it is backwards compatible there should be no problem upgrading it. – Theolodis Apr 27 '14 at 13:24
  • do you know where I can get the new 1.4? I can't find it at sourceforge. And the tjDecode is only in the 1.4 version. – mousomer Apr 27 '14 at 13:32
  • 1
    @mousomer I'd recommend you to contact the maintainer (information@libjpeg-turbo.org) of the project, I have had some good experience the last time I contacted him. – Theolodis Apr 27 '14 at 13:45