When I apply a median filter in a gray image it gets converted back to a RGB image. Why?
See code below:
path = '/content/img_gray' # Source Folder
dstpath = '/content/img_filtered_gray' # Destination Folder
try:
makedirs(dstpath)
except:
print ("Directory already exist, images will be written in same folder")
# Folder won't used
files = list(filter(lambda f: isfile(join(path,f)), listdir(path)))
for image in files:
try:
img = cv2.imread(os.path.join(path,image))
median = cv2.medianBlur(img,5)
dstPath = join(dstpath,image)
cv2.imwrite(dstPath,median)
except:
print ("{} is not converted".format(image))