簡體   English   中英

在 Jupyter 筆記本中使用 OpenCV 查看 tif 圖像文件

[英]viewing a tif image file using OpenCV in Jupyter notebook

我有一張 TIF 格式的熱圖像,我可以使用 Ubuntu 中的display命令看到它。 我還從圖像文件中獲得了以下信息:

$ file Rec-000026_16bit_counts.tif
Rec-000026_16bit_counts.tif: Big TIFF image data, little-endian
$ exiv2 Rec-000026_16bit_counts.tif
File name       : Rec-000026_16bit_counts.tif
File size       : 2097433 Bytes
MIME type       : 
Image size      : 0 x 0
Rec-000026_16bit_counts.tif: No Exif data found in the file

$  tiffinfo Rec-000026_16bit_counts.tif
TIFF Directory at offset 0x200010 (2097168)
  Image Width: 1024 Image Length: 1024
  Bits/Sample: 16
  Sample Format: unsigned integer
  Compression Scheme: None
  Photometric Interpretation: min-is-black
  Orientation: row 0 top, col 0 lhs
  Samples/Pixel: 1
  Planar Configuration: single image plane
  Software: ExaminIR

當我運行以下單元格時:

import cv2
img = cv2.imread("Rec-000026_16bit_counts.tif", cv2.IMREAD_UNCHANGED)
cv2.imshow('image',img)
cv2.waitKey(0)
cv2.destroyAllWindows()

我收到以下錯誤:

---------------------------------------------------------------------------
error                                     Traceback (most recent call last)
<ipython-input-67-2756e499dadf> in <module>
      1 import cv2
      2 img = cv2.imread("Rec-000026_16bit_counts.tif", cv2.IMREAD_UNCHANGED)
----> 3 cv2.imshow('image',img)
      4 cv2.waitKey(0)
      5 cv2.destroyAllWindows()
 
error: OpenCV(3.4.9) /io/opencv/modules/highgui/src/window.cpp:382: error: (-215:Assertion failed) size.width>0 && size.height>0 in function 'imshow'

我應該如何解決這個問題?

我認為圖像不在您的目錄中。 否則:

import cv2
img = cv2.imread("thermal-imaging-opportunities.jpg", cv2.IMREAD_UNCHANGED)
cv2.imshow('image',img)
cv2.waitKey(0)
cv2.destroyAllWindows()

output 是:

在此處輸入圖像描述

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM