Magick++ reading Blob YUV 4:2:2 into an Image

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
frsswdn

Magick++ reading Blob YUV 4:2:2 into an Image

Post by frsswdn »

Hi,

I am trying to read a Blob in YUV 4:2:2 format into an Image instance as follows:

image.read(blob, geo, "YUV4:2:2");

(function signature: const Blob &blob_, const Geometry &size, const string &magick_)

I get though the following error:

----------------------
terminate called after throwing an instance of 'Magick::WarningOption'
what(): ImageMagick: Unrecognized image format (YUV4:2:2)
---------------------

Trying to use "YUV" instead of "YUV4:2:2" results in a (different) error. However, trying

Image image(blob, geo, "YUV4:2:2");

works great. Trying to specify the magick_ argument with the Image::magick function yields an error as well.

How should I specify the magick_ argument for the Image::read function? Is it on purpose that the constructor and the read functions behave differently on the same magick_ string?

Version: ImageMagick 6.3.2 03/04/07 Q16
OS: GNU/Linux, FC 6.

Thanks,
Firas.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Magick++ reading Blob YUV 4:2:2 into an Image

Post by magick »

ImageMagick uses the sampling factor to determine the type of YUV image. By default it is 4:2:2. Your problem may be that you need to set the image depth. The Q16 version of ImageMagick expects images to be 16 bits per pixel. An alternative is to build/use the Q8 version of ImageMagick.
frsswdn

Re: Magick++ reading Blob YUV 4:2:2 into an Image

Post by frsswdn »

Hi,

I have tried to specify the depth of the image and I tried a couple of other potential workarounds, but I still cannot solve the issue:

Specifying the depth parameter (i.e. calling something like: ' image.read(blob, geo, 8, "YUV" ') results in the following exception/error:

--------------
terminate called after throwing an instance of 'Magick::ErrorCorruptImage'
what(): ImageMagick: Unexpected end-of-file `': No such file or directory
------------

Does this mean that there is a problem in the blob's format? I self-construct the blob out of three YUV channels by successively copying them into a continues array, then update the blob with the data array using:

blob.updateNoCopy(data, static_cast<size_t>(size) );

I guess I am missing something?

Thanks for the help,
Firas.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Magick++ reading Blob YUV 4:2:2 into an Image

Post by magick »

Post a URL where we can download a small working example that illustrates this problem and a sample image. We need to reproduce the problem before we can offer a proper fix.
frsswdn

Re: Magick++ reading Blob YUV 4:2:2 into an Image

Post by frsswdn »

Hi,

well, while preparing a working example, I managed to convert the YUV to RGB24 using a third party method (ffmpeg's img_convert). Now reading the RGB24 into an Image through a Blob works smoothly.

I can still provide the YUV example if relevant.

Thanks for asking for an example,
Firas.
Post Reply