0
我使用的圖像,是其中我被使用imfinfo MATLAB中的細節如下:的通道數與Matlab VS opencv的
Filename: 'dog.jpg'
FileModDate: '25-Mar-2011 15:54:00'
FileSize: 8491
Format: 'jpg'
FormatVersion: ''
Width: 194
Height: 206
BitDepth: 24
ColorType: 'truecolor'
FormatSignature: ''
NumberOfSamples: 3
CodingMethod: 'Huffman'
CodingProcess: 'Sequential'
Comment: {}
NewSubFileType: 0
BitsPerSample: [8 8 8]
PhotometricInterpretation: 'RGB'
ImageDescription: [1x13 char]
StripOffsets: 154
SamplesPerPixel: 3
RowsPerStrip: 206
StripByteCounts: 119892
它顯示了信道數= 3(與NumberOfSamples:3),但當我使用下面的代碼中找到OpenCV的信道的數量,我得到No. of channels = 1
Mat img = imread("dog.jpg", 0);
printf("No. of Channels = %d\n", img.channels());
爲什麼會這樣?請解釋。
imread( 「dog.jpg」,0); //最後的0 *強制* 8位灰度。嘗試1來強制執行bgr,或者對於'as is'執行-1。 – berak
謝謝Berak。我是初學者,我剛剛開始與Opencv今天,你的幫助表示讚賞。再次感謝。 – Navdeep
不客氣。只需保留一個指向[docs]的鏈接(http://docs.opencv.org/modules/highgui/doc/reading_and_writing_images_and_video.html#imread);) – berak