Coder Social home page Coder Social logo

Comments (10)

chekun avatar chekun commented on July 28, 2024 2

@rhsimplex Nice, love you guys.

from image-match.

chekun avatar chekun commented on July 28, 2024 1

@rhsimplex vrde's fork fixed my problem, issue solved 😃

from image-match.

rhsimplex avatar rhsimplex commented on July 28, 2024

Nope, it should return 0.0. I'll try to replicate this Monday and see what's going on.

Thanks for reporting the issue.

from image-match.

rhsimplex avatar rhsimplex commented on July 28, 2024

Ok, I only get a distance of 0.09, which should be under the threshold for matching. However these images should be identical.

In [1]: from image_match.goldberg import ImageSignature

In [2]: gis = ImageSignature()

In [3]: path1 = 'https://cloud.githubusercontent.com/assets/1967804/18188884/53e77c7a-70e8-11e6-8e27-98c196f1e242.jpg'

In [4]: path2 = 'https://cloud.githubusercontent.com/assets/1967804/18188887/5bbba7aa-70e8-11e6-93b9-3e881bc03e66.jpg'

In [5]: sig1 = gis.generate_signature(path1)

In [6]: sig2 = gis.generate_signature(path2)

In [7]: gis.normalized_distance(sig1, sig2)
Out[7]: 0.094653959692538772

What's going on? I think one of these images is greyscale, and one is color.

In [8]: from skimage.io import imread

In [9]: imread(path1).shape
Out[9]: (1334, 750, 3)

In [10]: imread(path2).shape
Out[10]: (1334, 750)

So skimage (which image-match uses for loading the images) converts to greyscale from color with range (0,1) but if the image is already greyscale over 8 bits, it leaves it!

In [12]: imread(path1, as_grey=True)
Out[12]: 
array([[ 1.,  1.,  1., ...,  1.,  1.,  1.],
       [ 1.,  1.,  1., ...,  1.,  1.,  1.],
       [ 1.,  1.,  1., ...,  1.,  1.,  1.],
       ..., 
       [ 1.,  1.,  1., ...,  1.,  1.,  1.],
       [ 1.,  1.,  1., ...,  1.,  1.,  1.],
       [ 1.,  1.,  1., ...,  1.,  1.,  1.]])

In [13]: imread(path2, as_grey=True)
Out[13]: 
array([[255, 255, 255, ..., 255, 255, 255],
       [255, 255, 255, ..., 255, 255, 255],
       [255, 255, 255, ..., 255, 255, 255],
       ..., 
       [255, 255, 255, ..., 255, 255, 255],
       [255, 255, 255, ..., 255, 255, 255],
       [255, 255, 255, ..., 255, 255, 255]], dtype=uint8)

Hence the slightly different signatures. The correct fix would be get rid of the skimage dependency and use PIL directly. A quick fix might be to detect if an image is uint8 and divide by 255.

from image-match.

rhsimplex avatar rhsimplex commented on July 28, 2024

Interestingly, when I try dividing by 255, I get the same distance value as you: 0.70823708184882128. Maybe something has changed with skimage. Can you tell me the output of:

import skimage
print(skimage.__version__)

?

I'm using version 0.12.3

from image-match.

chekun avatar chekun commented on July 28, 2024

@rhsimplex , Thank you for your reply.

I use pavlov/match docker image pavlov/match@9b7df7ecc867.

and the skimage version is exactly 0.12.3

Would use PIL directly fix the problem? Any plan to replace it ?

from image-match.

rhsimplex avatar rhsimplex commented on July 28, 2024

If you're using pavlov's match, then the real problem is that it's using an out-of-date image-match build. Their docker file has the line:

pip install git+https://github.com/ascribe/[email protected]

And we're at version 1+ now. My colleague @vrde has actually ported match to use the latest version of image-match (which now uses python3), you can find that fork here: https://github.com/vrde/match. I'll ask him to make a PR against the original repository.

Sorry about the confusion, but see if using this version helps. If so, I probably won't make any changes because 0.09 is well below the threshold of what should be considered a match.

from image-match.

chekun avatar chekun commented on July 28, 2024

@rhsimplex Good news, I will use @vrde's fork and see if it woks out. Thank you very much. 👍

from image-match.

rhsimplex avatar rhsimplex commented on July 28, 2024

You're welcome. Please let me know if it fixes your problem.

from image-match.

rhsimplex avatar rhsimplex commented on July 28, 2024

there is now a PR dsys/match#8 on Pavlov's match. When the merge it you can pull from there directly =)

from image-match.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.