JFeatureLib SIFT

328 views
Skip to first unread message

Jan Fritz Saborrido

unread,
Sep 16, 2013, 1:41:52 PM9/16/13
to jfeat...@googlegroups.com
Is there anyone with a demo code which uses SIFT to extract features from an image?

Dr. Franz Graf

unread,
Sep 16, 2013, 3:11:19 PM9/16/13
to jfeat...@googlegroups.com
Hi Jan Fritz,

at https://github.com/locked-fg/JFeatureLib-Demo you can find demos.
Do you have problems with SIFT? If so, you're welcome to describe the
issues.

Regards
Franz


Am 16.09.2013 19:41, schrieb Jan Fritz Saborrido:
> Is there anyone with a demo code which uses SIFT to extract features
> from an image?
>
> --
> You received this message because you are subscribed to the Google
> Groups "JFeatureLib" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to jfeaturelib...@googlegroups.com.
> To post to this group, send email to jfeat...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.


--
Dr. Franz Graf
G+: https://plus.google.com/107945158062341260943

Jan Fritz Saborrido

unread,
Sep 17, 2013, 1:07:50 AM9/17/13
to jfeat...@googlegroups.com, in...@locked.de
I've checked the demo files and I've only found HaralickDemo, HistogramConfigDemon, and StatusListenerDemo. I can't find a way to implement SIFT. Are these demo files used to implement SIFT?

Franz Graf

unread,
Sep 17, 2013, 3:30:41 AM9/17/13
to jfeat...@googlegroups.com
Hi,

ah okay, there is no explicit SIFT demo. Sorry.
Sift works the same as the others, just ensure you have the sift
binary downloaded from http://www.cs.ubc.ca/~lowe/keypoints/ and
adjust the properties file to find the executable.
If you don't know how to do it, just give a brief hint and I'll extend
the HowTos and/or examples.

Regards
Franz



2013/9/17 Jan Fritz Saborrido <jansab...@gmail.com>:
Website: http://www.Locked.de
Google+: https://plus.google.com/u/0/107945158062341260943
Xing: https://www.xing.com/profile/Franz_Graf4

Johannes Niedermayer

unread,
Sep 17, 2013, 4:48:42 AM9/17/13
to jfeat...@googlegroups.com
This should work if you do not want to use the command line interface (I think there is also one for SIFT?):

import ij.process.ColorProcessor;
import ij.process.ImageProcessor;

import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.List;

import javax.imageio.ImageIO;

import de.lmu.ifi.dbs.jfeaturelib.features.Sift;


public class SiftTest {
  public static void main(String[] args) throws FileNotFoundException, IOException{
      BufferedImage img = ImageIO.read(new FileInputStream(args[0]));
      ImageProcessor ip = new ColorProcessor(img);
      ip = ip.convertToByte(false);
      Sift sift = new Sift(new File("/your/path/do/sift/binary/"));
      sift.run(ip);
      //note that result.get(i)[0..3] represent y/x/scale/rotation, respectively.
      List<double[]> result = sift.getFeatures();
      System.out.println(result.size() + " features extracted...");

Jan Fritz Saborrido

unread,
Sep 17, 2013, 3:13:50 PM9/17/13
to jfeat...@googlegroups.com
i've tried the code but it gives me an error.

Exception in thread "main" java.io.IOException: Cannot execute sift binary at: C:\Users\janfritz\Documents\workspace\JFeatureLib\bw.jpg
at de.lmu.ifi.dbs.jfeaturelib.features.Sift.<init>(Sift.java:83)
at SiftTest.main(SiftTest.java:21)

the only changes i made were
...
BufferedImage img = ImageIO.read(new File("bw1.jpg"));
...
Sift sift = new Sift(new File("bw1.jpg"));

i've tried modifying the parameter in File() to a different name (thought it was supposed to be the output) but same error appears.

Jan Fritz Saborrido

unread,
Sep 17, 2013, 3:17:28 PM9/17/13
to jfeat...@googlegroups.com
i've downloaded the sift demo from the link and i've tried it using command prompt but i cannot execute the program. i've tried entering "siftWin32 -display <book.pgm>result.pgm; as stated in the README but an error appears.

ERROR: Input is not a standard raw PGM file.
Use xv or PNM tools to convert file to 8-bit PGM format.

i can't understand why this error appears for i used the same input included in the downloaded package.

Dr. Franz Graf

unread,
Sep 18, 2013, 2:05:06 AM9/18/13
to jfeat...@googlegroups.com
Hi,
Well the image you are providing is not in the right format as the error message says.
I guess it depends on the way you created the pgm file.
The SIFT wrapper methods in JFeatureLib do the conversion implicitly.

Regards Franz



Jan Fritz Saborrido <jansab...@gmail.com> schrieb:

Dr. Franz Graf
http://www.Locked.de

Dr. Franz Graf

unread,
Sep 18, 2013, 2:13:00 AM9/18/13
to jfeat...@googlegroups.com
Hi,
Have you set the SIFT binary path in the properties correctly?
If you are instantiating the the SIFT or sift wrapper class directly, you can pass the path to the class.

Regards Franz



Jan Fritz Saborrido <jansab...@gmail.com> schrieb:
i've tried the code but it gives me an error.

Johannes Niedermayer

unread,
Sep 18, 2013, 4:33:08 AM9/18/13
to jfeat...@googlegroups.com
Franz is right, the binary path is wrong.

The error is here:

Sift sift = new Sift(new File("bw1.jpg"));
Here you pass the image, not the sift binary.

Cheers

Johannes

Jan Fritz Saborrido

unread,
Sep 19, 2013, 12:20:39 AM9/19/13
to jfeat...@googlegroups.com
The code now works, thanks!

in the SiftFeatureVector class the parameters in the constructor are x, y, scale, and rotation. i want to get these information so i can display the features in the image. I've checked and the items in the list after executing this line: List<double[]> result = sift.getFeatures();, has a length of 132. what are these 132 items and what do they represent? 

i am planning to display the image including the features represented in points and lines like sample outputs displayed in papers about SIFT. i also need these features for SIFT is just a middle process in my work and these features will be needed for further use later on.

On Wednesday, September 18, 2013 4:33:08 PM UTC+8, Johannes Niedermayer wrote:
Franz is right, the binary path is wrong.

The error is here:
Sift sift = new Sift(new File("bw1.jpg"));
Here you pass the image, not the sift binary.

Cheers

Johannes

Am 18.09.2013 08:13, schrieb Dr. Franz Graf:
Hi,
Have you set the SIFT binary path in the properties correctly?
If you are instantiating the the SIFT or sift wrapper class directly, you can pass the path to the class.

Regards Franz



Jan Fritz Saborrido <jansa...@gmail.com> schrieb:

Dr. Franz Graf

unread,
Sep 19, 2013, 1:37:06 AM9/19/13
to jfeat...@googlegroups.com, Jan Fritz Saborrido
Hi,

Glad the code works.



Jan Fritz Saborrido <jansab...@gmail.com> schrieb:
>The code now works, thanks!
>
>in the SiftFeatureVector class the parameters in the constructor are x,
>y,
>scale, and rotation. i want to get these information so i can display
>the
>features in the image. I've checked and the items in the list after
>executing this line: List<double[]> result = sift.getFeatures();, has a
>
>length of 132. what are these 132 items and what do they represent?

The output are regular feature vectors as shown in the SiftFeatureVector class:

double[] asArray() {
double[] out = new double[gradients.length + 4];
out[0] = y;
out[1] = x;
out[2] = scale;
out[3] = rotation; System.arraycopy(gradients, 0, out, 4, gradients.length);
return out; } }

The order is exactly the same as the output generated by sift itself. Keep the order of X and y in mind! As it is y, X not x, y.


>i am planning to display the image including the features represented
>in
>points and lines like sample outputs displayed in papers about SIFT. i
>also
>need these features for SIFT is just a middle process in my work and
>these
>features will be needed for further use later on.

Good luck and have fun!
Are you using it for a publication or another project (just asking out of curiosity) ?

Franz

>On Wednesday, September 18, 2013 4:33:08 PM UTC+8, Johannes Niedermayer
>
>wrote:
>>
>> Franz is right, the binary path is wrong.
>>
>> The error is here:
>> Sift sift = new Sift(new File("bw1.jpg"));
>> Here you pass the image, not the sift binary.
>>
>> Cheers
>>
>> Johannes
>>
>> Am 18.09.2013 08:13, schrieb Dr. Franz Graf:
>>
>> Hi,
>> Have you set the SIFT binary path in the properties correctly?
>> If you are instantiating the the SIFT or sift wrapper class directly,
>you
>> can pass the path to the class.
>>
>> Regards Franz
>>
>>
>>
>> Jan Fritz Saborrido <jansa...@gmail.com> <javascript:> schrieb:
>> email to jfeaturelib...@googlegroups.com <javascript:>.
>> To post to this group, send email to
>jfeat...@googlegroups.com<javascript:>
>> .

ayhan peker

unread,
Jun 9, 2014, 5:00:23 PM6/9/14
to jfeat...@googlegroups.com, in...@locked.de
Hi Franz
Could you extend the HowTos or example with the instructions about the binary location and setting the properties file to find the executable ?
Regards
Ayhan

Franz Graf

unread,
Jun 12, 2014, 3:38:36 PM6/12/14
to jfeat...@googlegroups.com
Hi Ayhan,

everything you should need to do is
- download the JAR
- follow
https://code.google.com/p/jfeaturelib/wiki/HowTo#Changing_extraction_options_and_logging
in order to extract logging and jfeaturelib.properties
- download the sift binary. For example into the same folder as the jar
resides in
- adjust the jfeaturelib.properties Line 7:
features.sift.binary=sift.exe
and point it to the binary. The path can be either absolute or
relative. If you just point it to sift.exe, you should start jfeaturelib
also from this directory. Otherwise point it to an absolute path.

Drop a note if it works, I'll extend the docs then.

Regards
Franz


Am 09.06.2014 23:00, schrieb ayhan peker:
> Hi Franz
> Could you extend the HowTos or example with the instructions about the
> binary location and setting the properties file to find the executable ?
> Regards
> Ayhan
>
> On Tuesday, September 17, 2013 8:30:41 AM UTC+1, Franz Graf wrote:
>
> Hi,
>
> ah okay, there is no explicit SIFT demo. Sorry.
> Sift works the same as the others, just ensure you have the sift
> binary downloaded from http://www.cs.ubc.ca/~lowe/keypoints/
> <http://www.cs.ubc.ca/~lowe/keypoints/> and
> adjust the properties file to find the executable.
> If you don't know how to do it, just give a brief hint and I'll extend
> the HowTos and/or examples.
>
> Regards
> Franz
>
>
>
> 2013/9/17 Jan Fritz Saborrido <jansab...@gmail.com <javascript:>>:
> <https://groups.google.com/groups/opt_out>.
> >>
> >>
> >> --
> >> Dr. Franz Graf
> >> G+: https://plus.google.com/107945158062341260943
> <https://plus.google.com/107945158062341260943>
> >>
> > --
> > You received this message because you are subscribed to the
> Google Groups
> > "JFeatureLib" group.
> > To unsubscribe from this group and stop receiving emails from it,
> send an
> > email to jfeaturelib...@googlegroups.com <javascript:>.
> > To post to this group, send email to jfeat...@googlegroups.com
> <javascript:>.
> > For more options, visit https://groups.google.com/groups/opt_out
> <https://groups.google.com/groups/opt_out>.
> <https://www.xing.com/profile/Franz_Graf4>
>
> --
> You received this message because you are subscribed to the Google
> Groups "JFeatureLib" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to jfeaturelib...@googlegroups.com
> <mailto:jfeaturelib...@googlegroups.com>.
> To post to this group, send email to jfeat...@googlegroups.com
> <mailto:jfeat...@googlegroups.com>.
> For more options, visit https://groups.google.com/d/optout.


--
Dr. Franz Graf
Homepage: http://www.Locked.de
G+: https://plus.google.com/+FranzGraf

ayhan peker

unread,
Jun 16, 2014, 7:34:54 PM6/16/14
to jfeat...@googlegroups.com, in...@locked.de
Franz
Thank you very much for the response.
What I did was :
I downloaded the zip  from the link you mentioned (http://www.cs.ubc.ca/~lowe/keypoints/siftDemoV4.zip) and opened it .
Then I just referenced it as :   Sift sift = new Sift(new File("C:/Users/xxxx/xxxx/siftDemoV4/siftWin32.exe"));
It works perfectly fine.
Regards

Ayhan
ps..Anybody tried to store the features in solr? (and search them of course)

Franz Graf

unread,
Jun 18, 2014, 5:40:25 PM6/18/14
to jfeat...@googlegroups.com, ayhan peker
Hey Ayman,

Glad to hear that it seemed to work out.
According your Solr question:
If you want to do similarity search with sift vectors, Solr might not be a good fit.
Regarding several papers you either will do a complete scan and calculate distances to all of them (so just try to keep them in ram if the size allows it) or do a bag of words approach with hashing. This might be an option with Solr but have a look at the paper first.

Regards
Franz

Derzu Omaia

unread,
Aug 11, 2014, 3:30:09 PM8/11/14
to jfeat...@googlegroups.com
Hi All,

So the JFeatureLib just works via JNI? And the binary exe is generated from a matlab code? And just runs on windows? Linux and Mac no chance?

Thanks,

Derzu.

Franz Graf

unread,
Aug 11, 2014, 3:33:53 PM8/11/14
to jfeat...@googlegroups.com, Derzu Omaia
Hi,

Nono. The Java program just calls the binary specified in the properties. Just download the Linux binary from the SIFT website, reference it in the properties and you can run it. The SIFT website should provide the necessary binaries for Linux and Windows.

Definately no Jni.

Regards
Franz

Derzu Omaia

unread,
Aug 11, 2014, 4:08:54 PM8/11/14
to jfeat...@googlegroups.com, derzu...@gmail.com, in...@locked.de
Hi Franz,

Thanks for the quick answer. It's good to know that It also works on Linux.

You said to download the binary sift from the SIFT website, with website is this? I tried the David Lowe's site (http://www.cs.ubc.ca/~lowe/keypoints) that is the site where the windows version is available (siftDemoV4), I tried the SIFT Home (sift.jcvi.org/), and I also tried the JFeatureLib site (https://code.google.com/p/jfeaturelib/). But I didn't find the Linux binary that you mentioned, I think I looked at the wrong site. Can you send me the address of the site?

Regards,

Derzu.

Franz Graf

unread,
Aug 12, 2014, 1:05:39 AM8/12/14
to jfeat...@googlegroups.com, derzu...@gmail.com
Good morning Derzu,

I'm just on the phone, so I cannot check the zip. If I remember correctly I took the zip from http://www.cs.ubc.ca/~lowe/keypoints/

The paragraph says:
The demo program can be accessed from the following link in the form of a zip file containing the compiled binaries and demo code. To unpack, use "unzip siftDemoV4.zip" from Linux or an unzip utility in Windows. The code comes with a file README giving full details.

SIFT demo program (Version 4, July 2005)

This should work. But I would appreciate any feedback.

Good luck
Franz

----- Original Nachricht -----
Von: Derzu Omaia <derzu...@gmail.com>
Gesendet: 11.08.2014 - 22:08
An: jfeat...@googlegroups.com
Betreff: Re: [JFeatureLib] Re: JFeatureLib SIFT

> Hi Franz,
>
> Thanks for the quick answer. It's good to know that It also works on Linux.
>
> You said to download the binary sift from the SIFT website, with website is
> this? I tried the David Lowe's site (http://www.cs.ubc.ca/~lowe/keypoints)
> that is the site where the windows version is available (siftDemoV4), I
> tried the SIFT Home (sift.jcvi.org/), and I also tried the JFeatureLib site
> (https://code.google.com/p/jfeaturelib/). But I didn't find the Linux
> binary that you mentioned, I think I looked at the wrong site. Can you send
> me the address of the site?
>
> Regards,
>
> Derzu.
>
> Em segunda-feira, 11 de agosto de 2014 16h33min53s UTC-3, Franz Graf
> escreveu:
>>
>> Hi,
>>
>> Nono. The Java program just calls the binary specified in the properties.
>> Just download the Linux binary from the SIFT website, reference it in the
>> properties and you can run it. The SIFT website should provide the
>> necessary binaries for Linux and Windows.
>>
>> Definately no Jni.
>>
>> Regards
>> Franz
>>
>> On 11. August 2014 21:30:09 MESZ, Derzu Omaia <derzu...@gmail.com
>> <javascript:>> wrote:
>>>
>>> Hi All,
>>>
>>> So the JFeatureLib just works via JNI? And the binary exe is generated
>>> from a matlab code? And just runs on windows? Linux and Mac no chance?
>>>
>>> Thanks,
>>>
>>> Derzu.
>>>
>>> Em segunda-feira, 16 de setembro de 2013 14h41min52s UTC-3, Jan Fritz
>>> Saborrido escreveu:
>>>>
>>>> Is there anyone with a demo code which uses SIFT to extract features
>>>> from an image?
>>>>
>>>
>> Dr. Franz Graf
>> http://www.Locked.de
>>
>
> --
> You received this message because you are subscribed to the Google Groups "JFeatureLib" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to jfeaturelib...@googlegroups.com.
> To post to this group, send email to jfeat...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Derzu Omaia

unread,
Aug 12, 2014, 7:23:52 PM8/12/14
to jfeat...@googlegroups.com, derzu...@gmail.com, in...@locked.de
Thanks Franz,

The unix binary is really on the zip file (http://www.cs.ubc.ca/~lowe/keypoints/siftDemoV4.zip), named only as "sift", I execute the example (sent from Johannes Niedermayer) and it works on Linux.

Regards,

Derzu.

Derzu Omaia

unread,
Aug 13, 2014, 1:09:51 AM8/13/14
to jfeat...@googlegroups.com, jansab...@gmail.com, in...@locked.de
Hi Franz,

I'm trying to draw de SIFT vectors (like on the Lowe's paper from 2004) over the image that is being analysing. 

The SIFT vector of atributes returned by the method getFeatures (from de Sift class (de.lmu.ifi.dbs.jfeaturelib.features.Sift)) returns a list of attributes with y,x,scale and rotation.

Is scale the amplitude of the vector? If not, how can I obtain this amplitude? Is rotation the angle of the vector? Is this angle in radians (I think it is) ?

Thanks,

Derzu.

Franz Graf

unread,
Aug 13, 2014, 1:58:36 AM8/13/14
to jfeat...@googlegroups.com, Derzu Omaia, jansab...@gmail.com
Hi Derzu,

I'm glad that you got the program working. Concerning the values I have to advise you to look at the original paper of Lowe. It's quite a bit of a time since I've been working with Sift and don't want to give you unprecise information.

If I remember correctly, Lowe described it pretty well.

Regards
Franz
Reply all
Reply to author
Forward
0 new messages