So I have a picture of a sand dune that looks currently like this.
What I'm trying to do is identify the ripples within the picture using opencv in Python. I'm just learning this library so I don't know all the quirks within the library. I did some research, but couldn't find a problem similar to this one, this one is especially difficult because of the shadows that are created from the ripples. My expected outcome should be somewhat the inverse of this, making all the ripples standing out more than the other features. Below is a picture of a man with his hair as the feature that stands out. I want to do the same thing with the ripples in the dune below.
The following code is what I have beneath and this is the output of my final product, but still needs some work.
path = "C:/some path//to get//to my picture//Dune field_resize.jpg"
# image I'm using
img = cv2.imread ( path , cv2.IMREAD_GRAYSCALE )
kernel = np.ones ( (5 , 5) , np.uint8 )
# Canny edge detecting
edges = cv2.Canny ( img , 75 , 200 )
th , img = cv2.threshold ( img , 220 , 255 , cv2.THRESH_BINARY_INV );
# Copy the thresholded image.
img_floodfill = img.copy ()
# Mask used to flood filling.
# Notice the size needs to be 2 pixels than the image.
h , w = img.shape[:2]
mask = np.zeros ( (h + 2 , w + 2) , np.uint8 )
# Floodfill from point (0, 0)
cv2.floodFill ( img_floodfill , mask , (0 , 0) , 255 );
# Invert floodfilled image
img_floodfill_inv = cv2.bitwise_not ( img_floodfill )
# Combine the two images to get the foreground.
img_out = img | img_floodfill_inv
# Display images.
cv2.imwrite ( "Thresholded Image.png" , img )
cv2.imwrite ( "Floodfilled Image.png" , img_floodfill )
cv2.imwrite ( "Inverted Floodfilled Image.png" , img_floodfill_inv )
cv2.imwrite ( "Foreground.png" , img )
cv2.waitKey ( 0 )
cv2.imwrite ( "canny_edge.png" , edges )
img_erosion = cv2.erode ( img , kernel , iterations=1 )
cv2.waitKey ( 0 )
cv2.destroyAllWindows ()