I'm trying to read a 16 bit TIFF image (26446 x 16688) in Python. Using OpenCV only reads a black image (all the intensities reads 0) by:
self.img = cv2.imread(self.filename, cv2.IMREAD_UNCHANGED)
Can openCV handle 16 bit or large images (~840mb)? Any workaround?
EDIT: Also
cv2.imshow("output", self.img[0:600])
displays a black image.
Use image libraries specific to raster data (in your case, sentinel-1). For example you can use rasterio for reading and displaying satellite images.
Example:
import rasterio
from rasterio.plot import show
img = rasterio.open("image.tif")
show(img)
Yes, OpenCV can read uint16 perfectly fine:
img_np = cv2.imread(path, cv2.IMREAD_ANYDEPTH | cv2.IMREAD_UNCHANGED)
Speaking of file size limitation, depends on number of pixels:
By default number of pixels must be less than 2^30. Limit can be set using system variable OPENCV_IO_MAX_IMAGE_PIXELS
https://docs.opencv.org/3.4/d4/da8/group__imgcodecs.html#ga288b8b3da0892bd651fce07b3bbd3a56
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With