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.scalespace;
011
012public class DogOctave extends ScaleOctave {
013
014        // TODO: check correctness of bottom and top levels!!
015        DogOctave(ScaleOctave Gp) {
016                //super(0,0,0,0);
017                super(Gp.p, Gp.Q, Gp.width, Gp.height, Gp.botLevelIndex, Gp.topLevelIndex-1);
018                // create DoG octave
019                for (int q = botLevelIndex; q <= topLevelIndex; q++) {
020                        ScaleLevel Dpq = differenceOfGaussians(Gp.getLevel(q+1), Gp.getLevel(q));
021                        this.setLevel(q, Dpq);
022                }
023        }
024        
025        public ScaleLevel differenceOfGaussians(ScaleLevel A, ScaleLevel B) {
026                // A: Gaussian at level q+1
027                // B: Gaussian at level q
028                // C <-- A - B (scale the same as B)
029                ScaleLevel C = B.duplicate();
030                final float[] pixelsA = (float[]) A.getPixels();
031                final float[] pixelsB = (float[]) B.getPixels();
032                final float[] pixelsC = (float[]) C.getPixels();
033                for (int i=0; i<pixelsA.length; i++) {
034                        pixelsC[i] = pixelsA[i] - pixelsB[i];
035                }
036                C.setAbsoluteScale(B.getAbsoluteScale());
037                return C;
038        }
039        
040
041
042}