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 ******************************************************************************/ 009package imagingbook.spectral.dft; 010 011/** 012 * Scaling mode used for the DFT. 013 */ 014public enum ScalingMode { 015 /** 016 * Same scaling factor (1/sqrt(M)) is applied in forward and inverse transform. 017 */ 018 DEFAULT { 019 @Override 020 public double getScale(int M, boolean forward) { 021 return 1.0 / Math.sqrt(M); 022 } 023 }, 024 025 /** 026 * Scaling by a factor 1/M is applied to the forward transformation only. 027 */ 028 FORWARD_ONLY { 029 @Override 030 public double getScale(int M, boolean forward) { 031 return forward ? 1.0 / M : 1.0; 032 } 033 }, 034 035 /** 036 * Scaling by a factor 1/M is applied to the inverse transformation only. 037 */ 038 INVERSE_ONLY { 039 @Override 040 public double getScale(int M, boolean forward) { 041 return forward ? 1.0 : 1.0 / M; 042 } 043 }; 044 045 /** 046 * Returns the DFT scale factor for the specified data size and transformation 047 * direction. 048 * @param M the data size 049 * @param forward {@code true} for a forward, {@code false} for a inverse transform 050 * @return the scale factor 051 */ 052 public abstract double getScale(int M, boolean forward); 053}