Data Science Asked on July 16, 2021
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 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.
Answered by Brian Spiering on July 16, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP