opencv中怎样将一个16位jpg图像转化为8位的

如题所述

可以参考下面的程序,其中bitCount!=8 && bitCount!=24指的就是8位与24位
//BMP与IplImage相互转换
///////////////////////////////头文件bmp2ipl.h
//bmp2ipl.h
#ifndef BMP2IPL_H
#define BMP2IPL_H
class BMP {
public:
BMP():bmpData(NULL) {
memset(&biHeader, 0, sizeof(biHeader));
}
BMP(const BMP & img);
BMP(const IplImage &img);
BMP(int width, int height, int bitCount);
~BMP(){ delete [] bmpData; }
bool CreateImage(const BITMAPINFOHEADER &biHeader);
//Export
IplImage * BMP2Ipl();
//void Show(HWND hWnd, int nID);
//void Show(CDC *pDC, CRect & rect);
//void Show(HWND hWnd);
void ReSize(int newW, int newH);
private:
void CopyData(char *dest, const char *src, int dataByteSize,
bool isConvert, int height);
// ,
温馨提示:答案为网友推荐,仅供参考
相似回答