在OpenCV中更改图像的dpi

use*_*186 5 opencv dpi

当我在OpenCv中打开图像(可能为300 dpi,72 dpi等)时,图像的dpi自动更改为96 dpi。我想改变这个dpi。请帮忙。提前致谢...

#include "stdafx.h"
#include <cv.h>
#include <cxcore.h>
#include <highgui.h>
#include <iostream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
    IplImage *img1=cvLoadImage("input.jpg");
    cvSaveImage("output.jpg",img1);
    return(0);
}
Run Code Online (Sandbox Code Playgroud)

ypn*_*nos 1

OpenCV 不支持这样的元数据修改。您需要使用其他工具重新设置 DPI 或考虑直接合并 libjpeg。

另一种选择是采用 OpenCV jpeg writer 代码并根据您的需要进行更改。