Here is a short set of command lines.
I first took your second image and removed the red line. So note that there is a line there that will be brighter than where you want the split. Also the bottom of the image will be brighter in the column, since it has no black border there. Thus one needs to stop the compare at the first closest match. The use of -dissimilarity-threshold is there so that the compare does not stop because the white pixel has too large an rmse when compared to any black pixel. This forces the search not to stop for too large a mismatch.
Input:
Commands:
Crop the image into two nearly equal halves vertically.
Get the image width for use later when doing the final crop
Get the height of the top half for use when computing where to do the final crop
Scale the bottom half to one column
Get the y offset from the results of the compare
Add the y offset to the height of the top half to compute the y location in the full image to do the crop
Crop the original image into two parts defined by the compare offset.
Code: Select all
convert Fql1c1.png -crop 1x2@ +repage Fql1c1_%d.png
WW=`convert Fql1c1.png -format "%w" info:`
topH=`convert Fql1c1_0.png -format "%h" info:`
convert Fql1c1_1.png -scale 1x! Fql1c1_1_col.png
yoff=`compare -metric rmse -subimage-search -similarity-threshold 0.01% \
-dissimilarity-threshold 100% Fql1c1_1_col.png xc:white null: \
2>&1 | tr -cs "0-9" " " | cut -d\ -f4`
newH=$((topH+yoff))
convert Fql1c1.png -crop ${WW}x${newH} +repage Fql1c1_crop_%d.png
Results:
If you know the thickness of the spacing, you can add half the spacing to the newH computation so that it splits it in the middle of the spacing.