When reading or reading an image, you must set the image type, number of digits, and number of channels. The number of channels (channels) is confusing:
Sort out the image channels in the OpenCV Chinese forum as follows:
(1) What is an image channel? Is it true that the number of channels in a grayscale image is 1, and that in a color image is 3? (Zhuker)
Correct!
Basically, describe a pixel. If it is grayscale, you only need a numerical value to describe it, that is, a single channel.
If a pixel has three colors of RGB, it is three channels. (Ollydbg23)
(2) What do we think of Channel 2 and Channel 4? Which one can explain this? (Feixue)
I have seen four channels. I haven't seen the two channels yet. It's probably just convenient programming. Windows bmp is sometimes A four-channel image, and R, G, and B plus A Channel A, indicating transparency. (Eralvc)
Yes. In the end, this is generally called the alpha channel, indicating transparency. (Ollydbg23)
The 4-channel is usually RGBA, which may be used in some processing.
2-channel images are not common and are usually used in program processing. For example, Fourier transformation may be used. One channel is a real number, and one channel is a virtual number, which is mainly convenient for programming.
There is also a situation where 16-bit images are originally 3 channels, but in order to reduce the data volume, the compression is 16 bits, just two channels, common formats: RGB555 or RGB565, that is to say, R occupies 5 places, G occupies 5 or 6 places, B occupies 5 places, and RGBA5551 format also exists. The old format. (Loren)
The main reason is that some cameras often use some "weird" formats.
In addition, some common cameras like YUV2, which are in the following format: YUYV. You can use four or two channels for processing.
For example, if the original format is Y1UY2V and the interpolation is Y1UV, Y2UV is two color points.
YCrCb also has similar compression conditions. (Loren)
See: http://www.opencv.org.cn/forum/viewtopic.php? F = 1 & t = 4921 & start = 0 & st = 0 & sk = t & sd = a & hilit = RGB
This article from the CSDN blog, reproduced please indicate the source: http://blog.csdn.net/chenyusiyuan/archive/2009/10/13/4662783.aspx