I have several thousand aerial photographs which have been scanned in and orthorectified, but the image borders and fiducial markers remain on the image. I am looking to identify these parts of the images and later remove them.
To this point, I have attempted to perform k-means clustering on the original raster, but have found that the pixel values for the border are often so close to pixel values in the image that I lose quite a lot of the image.
I have also attempted to use https://github.com/gina-alaska/dans-gdal-scripts/wiki/Gdal_trace_outline which takes a global threshold value and applies this to the image. This is better but each image requires a different threshold value which cannot be calculated using the histogram (as the peaks often correspond to regions within the image) or a percentage-area approach as, due to scanning errors, I may only have a partial image, changing the percentage of the tif that is 'actual image'.
The best approach that I have found so far is to use mean-shift segmentation to break up the image into regions, and assign zonal statistics to each polygon based on the underlying raster. While this feels like a step forward, I still need to somehow select the regions which relate to the border. In the image below, I am talking about the darker red border areas not the blue outer region.
The images are grayscale, but I have colourised the segmented image based on mean pixel value to make it easier to differentiate between regions. To a human, it seems obvious which polygons relate to the border, but there are several issues in programmatically selecting the relevant areas:
This means I can't select polygons on the edge, or based on a threshold value, to identify the borders.
The test image is here
Is there another approach which may help in separating out the image and border regions?