Skip to content
This repository has been archived by the owner on Sep 20, 2021. It is now read-only.

Merge tuples of transitively similar images in dictionary #2

Merged

Conversation

plumbojumbo
Copy link
Collaborator

The current implementation of -[OSSimilaritySearch dictionaryFromSimilarImagesResult:] does not handle tuples of transitively similar images. Consider three images A, B, and C similar to each other. Similarity search will produce the tuples (A, B), (A, C), and (B, C), which are then transformed into the dictionary representation {A: [B, C], B: [C]}, whereas one would expect a representation like {A: [B, C]}.

To handle transitivity, this patch introduces a simplified union-find-like approach (another way being, for example, traversing connected components in a graph-like structure). The optimization is possible since the similarImages* methods already return the list of tuples in a strictly ordered permutation, e. g. for the images above there cannot be a tuple (C, A).

The current implementation of -[OSSimilaritySearch dictionaryFromSimilarImagesResult:] does not handle tuples of transitively similar images. Consider three images A, B, and C similar to each other. Similarity search will produce the tuples (A, B), (A, C), and (B, C), which are then transformed into the dictionary representation {A: [B, C], B: [C]}, whereas one would expect a representation like {A: [B, C]}.

To handle transitivity, this patch introduces a simplified union-find-like approach (another way being, for example, traversing connected components in a graph-like structure). The optimization is possible since the similarImages* methods already return the list of tuples in a strictly ordered permutation, e. g. for the images above there cannot be a tuple (C, A).
@ameingast ameingast merged commit 60eb3cd into ameingast:master Apr 19, 2016
@ameingast
Copy link
Owner

I will be testing these changes later this week, but so far it looks good. Merging in it in in the meanwhile.

@plumbojumbo plumbojumbo deleted the similar-images-dict-transitivity branch December 3, 2016 22:44
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants