作者nat626 (GarfieldCat)
看板MacDev
标题[问题] 使用OpenCV Create一个1-bit 单通道的tiff影像档
时间Thu Jan 15 18:43:29 2009
我想使用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
1F:→ nat626:救命呀 我搞了两天搞不出来 大大们帮帮忙O_Q 01/16 15:48
2F:→ nat626:或是有没有其他的framework可以用O_Q ? 01/16 15:49
3F:推 Blueshiva:Cocoa的NSImage系列就可以产生TIFF,只是不知道你的应用 01/16 23:14
4F:→ Blueshiva:能不能配合上去而已 01/16 23:14
5F:推 bizkit:用grayscale呢? 01/25 09:44