[問題] 使用OpenCV Create一個1-bit 單通道的tiff影像檔
我想使用IplImage來產生一個1-bit 單通道 非0即1的黑白影像
我的程式碼
IplImage *image;
CvSize size = cvSize( 320, 240);
char array[320*240];
image = cvCreateImageHeader( size, IPL_DEPTH_1U, 1 );
for(int x = 0 ; x < 320*240 ; x++){
array[ x ] = x%2;
}
cvSetImageData( image, array, image->widthStep );
cvSaceImage( "testImage.tiff", image );
但卻得到錯誤訊息
OpenCV ERROR: Input image depth is not supported by function ()
in function cvGetMat, ../../../cxcore/src/cxarray.cpp(2799)
Terminating the application...
called from cvUnregisterType, ../../../cxcore/src/cxpersistence.cpp(4933)
Terminating the application...
called from cvUnregisterType, ../../../cxcore/src/cxpersistence.cpp(4933)
Terminating the application...
called from cvUnregisterType, ../../../cxcore/src/cxpersistence.cpp(4933)
Terminating the application...
called from cvUnregisterType, ../../../cxcore/src/cxpersistence.cpp(4933)
Terminating the application...
called from cvUnregisterType, ../../../cxcore/src/cxpersistence.cpp(4933)
Terminating the application...
called from cvUnregisterType, ../../../cxcore/src/cxpersistence.cpp(4933)
Terminating the application...
called from cvUnregisterType, ../../../cxcore/src/cxpersistence.cpp(4933)
Terminating the application...
called from cvUnregisterType, ../../../cxcore/src/cxpersistence.cpp(4933)
Terminating the application...
called from cvUnregisterType, ../../../cxcore/src/cxpersistence.cpp(4933)
Terminating the application...
在東問西查後,cvSaceImage()的說明文件裡有提到
Only 8-bit single-channel or 3-channel (with 'BGR' channel order) images can
be saved using this function.
看到這個我心涼一半了
我主要的應用只是儲存影像而已
所以並不會對影像做操作
由於是大量的儲存影像
所以用 8-bit 來存,空間會吃很兇
請問各位大大有甚麼辦法解決這個問題嗎O_Q ?
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 118.166.50.16
→
01/16 15:48, , 1F
01/16 15:48, 1F
→
01/16 15:49, , 2F
01/16 15:49, 2F
推
01/16 23:14, , 3F
01/16 23:14, 3F
→
01/16 23:14, , 4F
01/16 23:14, 4F
推
01/25 09:44, , 5F
01/25 09:44, 5F
MacDev 近期熱門文章
PTT數位生活區 即時熱門文章