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

Magick++ is an object-oriented C++ interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning Magick++.
Post Reply
kometes77
Posts: 3
Joined: 2013-11-25T04:59:26-07:00
Authentication code: 6789

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

Post 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
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

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

Post by dlemstra »

You can do the following:

Code: Select all

image.defineValue("jpeg", "sampling-factor", "4:2:0");
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
kometes77
Posts: 3
Joined: 2013-11-25T04:59:26-07:00
Authentication code: 6789

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

Post by kometes77 »

dlemstra, thank you very much.
It works well.
kometes77
Posts: 3
Joined: 2013-11-25T04:59:26-07:00
Authentication code: 6789

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

Post 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?
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

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

Post by dlemstra »

4:2:0 seems to be the default.
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
Post Reply