Numpy array to tiff file

Multi tool use
Numpy array to tiff file
I have been trying to write a tiff file using a numpy array. The file would have only one band. But when I am writing the file it is printing only 0, provided I have checked that the array is doesn't contain zeros. If I open the output tiff file and see the pixel values, all the values are zero. In the code below, rgb is the array, raster is a geotiff file.
import numpy, sys
from osgeo import gdal
from osgeo.gdalconst import *
#format1='GTiff'
gdal.AllRegister()
driver = raster.GetDriver()
#driver = gdal.GetDriverByName(format1)
output = driver.Create("E:/workplace/final/results2/final_result_h.tif", cols, rows, 1, gdal.GDT_Int16)
if output is None:
print('Could not create final_result_h.tif')
sys.exit(1)
outBand = output.GetRasterBand(1)
outBand.WriteArray(rgb)
outBand.FlushCache()
outBand.SetNoDataValue(value)
output.SetGeoTransform(raster.GetGeoTransform())
output.SetProjection(raster.GetProjection())
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.