001/******************************************************************************* 002 * This software is provided as a supplement to the authors' textbooks on digital 003 * image processing published by Springer-Verlag in various languages and editions. 004 * Permission to use and distribute this software is granted under the BSD 2-Clause 005 * "Simplified" License (see http://opensource.org/licenses/BSD-2-Clause). 006 * Copyright (c) 2006-2023 Wilhelm Burger, Mark J. Burge. All rights reserved. 007 * Visit https://imagingbook.com for additional details. 008 ******************************************************************************/ 009 010package imagingbook.common.sift; 011 012/** 013 * <p> 014 * Represents a match between two SIFT features. See Secs. 25.5 of [1] for more details. Instances are immutable. 015 * </p> 016 * <p> 017 * [1] W. Burger, M.J. Burge, <em>Digital Image Processing – An Algorithmic Introduction</em>, 3rd ed, Springer 018 * (2022). 019 * </p> 020 * 021 * @author WB 022 * @version 2022/11/20 023 */ 024public class SiftMatch implements Comparable<SiftMatch> { 025 026 private final SiftDescriptor descriptor1, descriptor2; 027 private final double distance; 028 029 public SiftMatch(SiftDescriptor descriptor1, SiftDescriptor descriptor2, double distance) { 030 this.descriptor1 = descriptor1; 031 this.descriptor2 = descriptor2; 032 this.distance = distance; 033 } 034 035 public SiftDescriptor getDescriptor1() { 036 return descriptor1; 037 } 038 039 public SiftDescriptor getDescriptor2() { 040 return descriptor2; 041 } 042 043 public double getDistance() { 044 return distance; 045 } 046 047 @Override 048 public int compareTo(SiftMatch other) { 049 return Double.compare(this.distance, other.distance); 050 } 051 052 @Override 053 public String toString() { 054 return String.format("%s %.2f", this.getClass().getSimpleName(), distance); 055 } 056 057}