Disclaimer: I'm a computer vision rookie.
I have seen a lot of stack overflow posts of how to find a specific sub-image in a larger image.
My usecase is a bit different since I don't want it to be specific and I'm not sure how I can do this (if it's even possible, but I have a feeling it should).
I have a large datasets of images, of sometimes, some of this images are a combination of two or more other images of the dataset. I'd like to automatically crop theses "combinations" to isolate the sub-images.
So the tasks would be to process each image of the dataset, and check if there are abnormal boundaries that could mean the image is a combination.
Example using great stock images:
What I've tried:
I've seen that houghs transform could be used for line detection in images but I'm couldn't achieve anything using this.
CodePudding user response:
- Use
cv.Sobel
or other derivative kernel (withcv.filter2D
) to find edges - Sum along pixel columns to score each for "edginess".
np.sum
ornp.mean
do that. - Some thresholding and
np.argsort
and indexing to find best candidates. - cut (take slices out of array)
edge map:
edgy plot:
slices to take:
array([[ 0, 578],
[ 578, 1135],
[1135, 1136]], dtype=int64)
Pictures:
complete notebook: https://gist.github.com/crackwitz/e1ba1ce7a6fba446288275d91f66261c