Page 1 of 1

How to convert Magick::Image to YUV 4:2:0 format?

Posted: 2013-11-25T05:13:22-07:00
by kometes77
I converted a image with the below ImageMagick command line option.
$convert input_image.jpg -sampling-factor 4:2:0 output_image.jpg
I used ImageMagick/bin/convert and Now, I want to implement it with Magick++.

I have a Magick::Image instance which read the pixel values with .read() method.
I'd like to do chromatic downsampling in YUV format
and want to save this instance to the file, as I did in the above command line options.

I cannot find any method to convert Magick::Image to YUV4:2:0 format.
Can you help me?

Then I will save this Magick::Image instance as Jpeg, 75 quality.

Thanks

Re: How to convert Magick::Image to YUV 4:2:0 format?

Posted: 2013-11-25T10:13:42-07:00
by dlemstra
You can do the following:

Code: Select all

image.defineValue("jpeg", "sampling-factor", "4:2:0");

Re: How to convert Magick::Image to YUV 4:2:0 format?

Posted: 2013-11-25T20:54:23-07:00
by kometes77
dlemstra, thank you very much.
It works well.

Re: How to convert Magick::Image to YUV 4:2:0 format?

Posted: 2013-11-26T02:28:29-07:00
by kometes77
If I save like the below codes with the default parameter.

Magick::Image image;
image.read(src_width, src_height, "RGB", Magick::CharPixel, (char *) pPixelData );
image.write("/home/myid/output.jpg");

If I just save image without any change.
what is the default for chroma option?
4:4:4? or 4:2:0?

Re: How to convert Magick::Image to YUV 4:2:0 format?

Posted: 2013-11-26T03:37:31-07:00
by dlemstra
4:2:0 seems to be the default.