[問題] 使用OpenCV Create一個1-bit 單通道的tiff影像檔

看板MacDev作者 (GarfieldCat)時間16年前 (2009/01/15 18:43), 編輯推噓2(203)
留言5則, 3人參與, 最新討論串1/1
我想使用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
救命呀 我搞了兩天搞不出來 大大們幫幫忙O_Q
01/16 15:48, 1F

01/16 15:49, , 2F
或是有沒有其他的framework可以用O_Q ?
01/16 15:49, 2F

01/16 23:14, , 3F
Cocoa的NSImage系列就可以產生TIFF,只是不知道你的應用
01/16 23:14, 3F

01/16 23:14, , 4F
能不能配合上去而已
01/16 23:14, 4F

01/25 09:44, , 5F
用grayscale呢?
01/25 09:44, 5F
文章代碼(AID): #19RnDIfx (MacDev)
文章代碼(AID): #19RnDIfx (MacDev)