简体   繁体   English

生成不同格式的图像字节数据

[英]Generate image byte data in different formats

I have an application which can accept images as byte data in many different formats. 我有一个应用程序,可以将图像接受为许多不同格式的字节数据。 Under the covers, the application uses both custom code and opencv conversion methods to convert those images into formats that we can use. 在幕后,该应用程序同时使用自定义代码和opencv转换方法,将这些图像转换为我们可以使用的格式。

I am attempting to write some unit tests to add images into our library in many different formats to make sure that the application works and that the application performance isn't negatively affected by the different formats. 我正在尝试编写一些单元测试,以多种不同格式将图像添加到我们的库中,以确保应用程序可以正常工作,并且应用程序性能不会受到不同格式的负面影响。

To do this, I figured I would create a tool which can load a JPEG and then use opencv's conversion methods to convert the image from the BGR format that opencv loads it in into all the different input formats we accept. 为此,我认为我将创建一个可以加载JPEG的工具,然后使用opencv的转换方法将图像从BGR格式转换为opencv并将其加载为我们接受的所有不同输入格式。 Unfortunately, it seems that OpenCV provide support for converting into the RGB space, but not so much support in the other direction (say RGB to YUV_NV21). 不幸的是,似乎OpenCV提供了转换为RGB空间的支持,但在另一个方向却没有提供太多支持(例如RGB到YUV_NV21)。

Are there any other libraries or applications that I could use to do this? 还有其他可用来执行此操作的库或应用程序吗?

It would be nice if I could do the conversions as part of the unit tests and just iterate over all the different formats, but if I need to generate the inputs ahead of time as binary data files, that would be ok too. 如果我可以将转换作为单元测试的一部分进行并仅迭代所有不同的格式,那就太好了,但是如果我需要提前将输入生成为二进制数据文件,那也可以。

Thanks in advance. 提前致谢。

EDIT: When I say image format, I don't mean a compressed image format, like JPEG or PNG. 编辑:当我说图像格式时,我并不是说压缩图像格式,例如JPEG或PNG。 I mean the different raw image formats, like RGB, RGBX, YUV (in all its different formulations) etc. 我指的是不同的原始图像格式,例如RGB,RGBX,YUV(以所有不同的方式表示)等。

You may be interested in Intel's IPP . 您可能对Intel的IPP感兴趣。 It has plenty of color conversion routines . 它具有大量的颜色转换例程 It's not free, though. 它不是免费的。

Imagemagick is one possibility: Imagemagick是一种可能性:

http://www.imagemagick.org/script/index.php http://www.imagemagick.org/script/index.php

and it's used by many popular applications. 许多流行的应用程序都在使用它。

You can also google for specific libraries that support the formats you want. 您也可以在Google上搜索支持所需格式的特定库。

Edit: Since you want the raw formats, here's a nice project that does some of what you want. 编辑:由于您需要原始格式,所以这是一个不错的项目,可以完成您想要的一些事情。 Converting RGB to YUV and viceversa isn't difficult. 将RGB转换为YUV,反之亦然并不困难。 You just need to use the formulas. 您只需要使用公式。

http://www.codeproject.com/Articles/402391/RGB-to-YUV-conversion-with-different-chroma-sampli http://www.codeproject.com/Articles/402391/RGB-to-YUV-conversion-with-different-chroma-sampli

In a way that contributes to everyone, consider just using netpbm for what exists, and adding conversion routines for what else you need. 以对所有人都有帮助的方式,考虑仅将netpbm用于存在的内容,并为其他需要添加转换例程。 netpbm.sourceforge.net netpbm.sourceforge.net

Try VTK. 尝试VTK。 They have different image writers 他们有不同的图像作家

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM