I have a MOSDAC file from which I obtained and image for a specific region with clouds. And after that I used thresholds to obtain an image under specific value. But now I want to obtain boundaries of the clouds in python (OpenCV) (I know that we can use bwboundaries in MATLAB).
Code that I used :
import h5py
import cv2
import numpy as np
import matplotlib.pyplot as plt
fn = '3DIMG_30MAR2018_0000_L1B_STD.h5' #filename (the ".h5" file)
hf = h5py.File(fn, 'r')
hf.keys()
data = hf.get('IMG_TIR1')
data = data[0,:,:]
data=np.where(data>1022, np.nan, data)
Lat= hf.get('Latitude')
Lat = Lat[:,:]
Lat=Lat*0.0099999998
Lat=np.where(Lat>312, np.nan, Lat)
Long= hf.get('Longitude')
Long = Long[:,:]
Long=Long*0.0099999998
Long=np.where(Long>312, np.nan, Long)
X=Long[427:1421,804:1902]
Y=Lat[427:1421,804:1902]
Z=data[427:1421,804:1902]
fig = plt.figure(figsize=(10,10))
plt.pcolor(X, Y, Z)
plt.xlim(60, 100)
plt.ylim(0, 40)
fig = plt.figure(figsize=(10,10))
plt.pcolor(X, Y, Z)
plt.colorbar(label="Radiance", orientation="vertical")
plt.xlim(60, 100)
plt.ylim(0, 40)
#Threshold
Zn=np.where(Z>810, 1, 0)
fig = plt.figure(figsize=(10,10))
plt.pcolor(X, Y, Zn, cmap='jet', vmin=0, vmax=1)
plt.colorbar(label="Radiance", orientation="vertical")
plt.xlim(60, 100)
plt.ylim(0, 40)
fig = plt.figure(figsize=(10,10))
plt.imshow(Zn, cmap='binary', vmin=0, vmax=1)
plt.colorbar(label="Radiance", orientation="vertical")
Link for the dataset: https://drive.google.com/file/d/1S78nEM2l5thIRJLkZKlVzaskRwDo-5Iu/view?usp=sharing