I applied adaptive gaussian thresholding to my .tif image, but the black frame (contour) on the edges was created. Can't understand why and how to delete.
I would be very grateful for your help!
p.s. After cv2.threshold(img,127,255,cv2.THRESH_BINARY)
there is no frame.
This is my original image:
https://drive.google.com/file/d/1DfdmQQ9AS-U2SXtyJzU94oYsLLSUmV7N/view?usp=share_link
This is fragment of my image (colored) and after gaussian thresholding (white and black). The black countour on the edge of the image is clearly visible. enter image description here
My code:
img = cv2.imread(" My.tiff", 0)
th = cv2.adaptiveThreshold(img,255,cv2.ADAPTIVE_THRESH_MEAN_C, cv2.THRESH_BINARY,115,2)
Tried this (found on the Stack overflow), but no results:
img = cv2.imread(file_path, 0)
rows, cols = img.shape
cv2.floodFill(img, None, seedPoint=(0, 0), newVal=255, loDiff=1, upDiff=1) # Fill the top left corner.
cv2.floodFill(img, None, seedPoint=(cols-1, 0), newVal=255, loDiff=1, upDiff=1) # Fill the top right corner.
cv2.floodFill(img, None, seedPoint=(0, rows-1), newVal=255, loDiff=1, upDiff=1) # Fill the bottop left corner.
cv2.floodFill(img, None, seedPoint=(cols-1, rows-1), newVal=255, loDiff=1, upDiff=1) # Fill the bottom right corner.
My image after adaptive gaussian thresholding (thresholding is ok..but why the black border was created and how to remove it, unfortunately, can't understand): enter image description here