1

I have a python program where I take one initial image (I will call this image A) and compare several other images (I will refer to this set of images as set B) to the average color of the initial image A.

When I compare an image from set B to the initial image A, I get an integer value closeness score. I would like to somehow attach this score to the image from set B. This way I can sort and reference the entire set B based on this closeness score.

Here is a more code based explanation:

setB = [image1, image2, image3, ..., imageN]

closenessScore(setB)

The result of closenessScore(setB) gives me an array of values corresponding to set B. Example: [67, 32, 22, ..., 72]. I need to attach these values to the appropriate image from set B, then I need to sort the images in set B based on their closeness score.

I am kind of new to python, so if I need to provide any additional information I would be more than happy to do so.

Any advice would be greatly appreciated!

Olvin Roght
  • 7,677
  • 2
  • 16
  • 35
  • 2
    You just need to initialize [*dict*](https://docs.python.org/3/library/stdtypes.html#mapping-types-dict), where key will be an image object *(or path)* from `setB` and value will be `closenessScore` of this image. Related: [How do I sort a dictionary by value?](https://stackoverflow.com/q/613183/10824407) – Olvin Roght Aug 13 '21 at 20:34

0 Answers0