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-2016 Wilhelm Burger, Mark J. Burge. All rights reserved. 
007 * Visit http://imagingbook.com for additional details.
008 *******************************************************************************/
009
010package imagingbook.pub.sift.util;
011
012import java.awt.Color;
013import java.util.List;
014
015import ij.process.ImageProcessor;
016
017
018/*
019 * This class might be obsolete!?
020 */
021
022public class SiftKeyDisplay {
023        
024        private List<SiftKeypoint> keyset;
025        private double magnification = 6.0;
026        private Color boxColor = Color.green;
027        private Color lineColor = Color.red;
028        
029        
030        public SiftKeyDisplay(List<SiftKeypoint> keys) {
031                this.keyset = keys;
032        }
033        
034        public void draw(ImageProcessor ip) {
035                for (SiftKeypoint k : keyset) {
036                        drawOneKey(k,ip);
037                }
038        }
039        
040        void drawOneKey(SiftKeypoint key, ImageProcessor ip) {  
041                double x = (int) Math.rint(key.x);
042                double y = (int) Math.rint(key.y);
043                int u0 = (int) x;
044                int v0 = (int) y;
045                double phi = key.orientation;
046                double scale = key.scale;
047                double dx = magnification * scale * Math.cos(phi);      
048                double dy = magnification * scale * Math.sin(phi); // NOTE: angle runs reversed
049                int u1 = (int) Math.rint(x + dx);
050                int v1 = (int) Math.rint(y + dy);
051                
052                ip.setColor(boxColor);
053                ip.drawRect(u0-1, v0-1, 3, 3);
054                ip.setColor(lineColor);
055                ip.drawLine(u0,v0,u1,v1);
056
057        }
058
059}