Fixed potential threading issue with Swing and the Layer panels when
[trakem2.git] / mpi / fruitfly / registration / Feature.java
blob60c4b7e2a98f2bfd923059ed6af932dfe7ef333a
1 package mpi.fruitfly.registration;
3 import java.io.Serializable;
5 /**
6 * SIFT feature container
7 */
8 public class Feature implements Comparable< Feature >, Serializable
10 public float scale;
11 public float orientation;
12 public float[] location;
13 public float[] descriptor;
15 /** Dummy constructor for Serialization to work properly. */
16 public Feature() {}
18 public Feature( float s, float o, float[] l, float[] d )
20 scale = s;
21 orientation = o;
22 location = l;
23 descriptor = d;
26 /**
27 * comparator for making Features sortable
28 * please note, that the comparator returns -1 for
29 * this.scale &gt; o.scale, to sort the features in a descending order
31 public int compareTo( Feature f )
33 return scale < f.scale ? 1 : scale == f.scale ? 0 : -1;
36 public float descriptorDistance( Feature f )
38 float d = 0;
39 for ( int i = 0; i < descriptor.length; ++i )
41 float a = descriptor[ i ] - f.descriptor[ i ];
42 d += a * a;
44 return ( float )Math.sqrt( d );