?? dualtree.cs
字號:
// Waveblend - complex dualtree based image fusion// (C) Copyright 2004 -- Sebastian Nowozin <nowozin@cs.tu-berlin.de>//// This file is part of Waveblend.//// Waveblend is free software; you can redistribute it and/or modify// it under the terms of the GNU General Public License as published// by the Free Software Foundation; version 2 of the License.//// Waveblend is distributed in the hope that it will be useful,// but WITHOUT ANY WARRANTY; without even the implied warranty of// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the// GNU General Public License for more details.//// The license is included with the distribution in the file 'LICENSE'.///* Dualtree.cs * * 1d, Real 2d, Complex 2d Dualtree wavelet data structures. */using System;public classDualtree{ private Dualtree next; public Dualtree Next { get { if (lastLevel) return (null); return (next); } set { next = value; } } private object[] store = new object[2]; private bool lastLevel; public bool LastLevel { get { return (lastLevel); } set { lastLevel = value; } } public object this[int index] { get { if (index < 0 || index > 1) throw (new ArgumentException (String.Format ("Only two subtrees (0, 1), requested {0}", index))); return (store[index]); } set { if (index < 0 || index > 1) throw (new ArgumentException (String.Format ("Only two subtrees (0, 1), set operation on {0}", index))); store[index] = value; } }}public classDualtree2dReal{ private Dualtree2dReal next; public Dualtree2dReal Next { get { if (lastLevel) return (null); return (next); } set { next = value; } } private object[] store = new object[4]; private bool lastLevel; public bool LastLevel { get { return (lastLevel); } set { lastLevel = value; } } public object this[int index] { get { if (index < 0 || index > 3) throw (new ArgumentException (String.Format ("Only four subtrees (0-3), requested {0}", index))); return (store[index]); } set { if (index < 0 || index > 3) throw (new ArgumentException (String.Format ("Only four subtrees (0-3), set operation on {0}", index))); store[index] = value; } }}public classDualtree2dComplex{ private Dualtree2dComplex next; public Dualtree2dComplex Next { get { if (lastLevel) return (null); return (next); } set { next = value; } } private Dualtree2dComplex () { } public Dualtree2dComplex (Dualtree2dReal real, Dualtree2dReal imaginary) { trends[0] = (double[,]) real[0]; trends[1] = (double[,]) imaginary[0]; store[0] = (double[,]) real[1]; store[1] = (double[,]) real[2]; store[2] = (double[,]) real[3]; store[3] = (double[,]) imaginary[1]; store[4] = (double[,]) imaginary[2]; store[5] = (double[,]) imaginary[3]; if (real.Next == null && imaginary.Next == null) { lastLevel = true; } else if (real.Next == null || imaginary.Next == null) { throw (new ArgumentException ("Trees are not equally sized.")); } else { next = new Dualtree2dComplex (real.Next, imaginary.Next); lastLevel = false; } } public Dualtree2dReal ProduceRealDualtree (int ri) { Dualtree2dReal dt = new Dualtree2dReal (); dt[0] = trends[ri]; dt[1] = store[ri * 3 + 0]; dt[2] = store[ri * 3 + 1]; dt[3] = store[ri * 3 + 2]; if (LastLevel) { dt.LastLevel = true; dt.Next = null; return (dt); } dt.LastLevel = false; dt.Next = Next.ProduceRealDualtree (ri); return (dt); } public double[,] GetDirectStore (int ri, int idx) { return (store[ri * 3 + idx]); } private double[][,] trends = new double[2][,]; private double[][,] store = new double[(2 * 3)][,]; private bool lastLevel; public bool LastLevel { get { return (lastLevel); } set { lastLevel = value; } } public class ComplexArray { double[,] realArr; double[,] imaginaryArr; private ComplexArray () { } public ComplexArray (double[,] real, double[,] imag) { realArr = real; imaginaryArr = imag; } public int GetLength (int dim) { return (realArr.GetLength (dim)); } // ri == 0 -> real, ri == 1 -> imaginary public double this[int y, int x, int ri] { get { if (ri == 0) return (realArr[y, x]); if (ri == 1) return (imaginaryArr[y, x]); throw (new ArgumentException ("Invalid real/imaginary index.")); } set { if (ri == 0) { realArr[y, x] = value; } else if (ri == 1) { imaginaryArr[y, x] = value; } else throw (new ArgumentException ("Invalid real/imaginary index.")); } } } public double[,] GetTrend (int trendIndex) { if (trendIndex < 0 || trendIndex > 1) throw (new ArgumentException ("Trend index out of bounds, should be zero or one.")); return (trends[trendIndex]); } public ComplexArray this[int index] { get { if (index < 0 || index > 2) throw (new ArgumentException (String.Format ("Only three subtrees (0-2), requested {0}", index))); return (new ComplexArray (store[index], store[index + 3])); } /* set { if (index < 0 || index > 3) throw (new ArgumentException (String.Format ("Only four subtrees (0-3), set operation on {0}", index))); store[index] = value; } */ }}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -