# How many channels do ultrasound images have?

I have some ultrasound images. When I read them using cv.imread and check their shape or check them with ndim, it shows 3 channels:

im = cv.imread(data_path+'a1.jpg')
print(im.shape)
im = np.array(im)
print(im.ndim)

the output is:
(154, 139, 3)
3


But when I open them in photoshop and check their mode in Image > Mode, it shows grayscale with 8 bit. Also in windows properties > detail, tab shows 8 bit:

Dose anyone have any idea about that?

• what's the format of the image? – Alireza Zolanvari Mar 15 '19 at 15:14

## 1 Answer

What is happening has nothing to do with the type of image (ultrasound in this case). It has to do with the type of file (JPEG in this case). By default, cv.imread assumes it is a 3-channel color image. You can specify grayscale when calling cv.imread if appropriate. The last dimension (the color dimension) in the im object could be empty.

There is also depth info (8 bits per channel). The default is 8 bit, you could specify 16 bit or 32 bit if apporiate.

Do not rely on function or software defaults. It is better to work from first principles of the raw data.

• How can I check if my image is 3 channel or 1 channel? Is there any function to do that? – Hunar Mar 15 '19 at 18:37
• simply spoken: gray == 1 channel, everything else 3 – Andreas Look Mar 15 '19 at 21:54
• There is high-channel ultrasound that which can have 16, 48, 64, or 256 channels. – Brian Spiering Mar 15 '19 at 23:39