Change dpi of an image in OpenCV

佐手、 提交于 2019-12-04 01:28:48

问题


When I open an image in OpenCv (which may be of 300 dpi, 72 dpi etc.), the dpi of the image is automatically changed to 96 dpi. I want to variate this dpi. Please help. Thanks in advance...

#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);
}

回答1:


OpenCV does not support meta-data mangling like this. You need to use another tool to re-set the DPI or consider incorporating libjpeg directly.

Another option is to take the OpenCV jpeg writer code and change it according to your needs.




回答2:


You need to edit the image meta data libexif(c) or exiv2 (c++)



来源:https://stackoverflow.com/questions/10860969/change-dpi-of-an-image-in-opencv

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!