001 package util.wavelet;
002
003 import java.util.List;
004 import static java.lang.Math.*;
005
006 /**
007 * Corresponds to a feature in the original signal. A WObject contains a set of connected
008 * {@link InterscaleRelationship} instances representing a tree of Structure instances spanning multiple scales and usually restricted
009 * to a small subset of positions in the original signal. Each {@link InterscaleRelationship}
010 * share one Structure instance in common with another InterscaleRelationship instance in the same WOBject.
011 * A WObject is composed of zero or more sub-WObjects represented by a subset of the {@link InterscaleRelationship} instances
012 * of the 'parent' WOBject.
013 *
014 * @author John Talbot
015 */
016 public class WObject {
017
018 /** Set of InterscaleRelationship instances */
019 public java.util.Set<InterscaleRelationship> relationships = new java.util.HashSet<InterscaleRelationship>(16);
020
021 /** Set of structure instances sorted from smallest scale to */
022 public java.util.SortedSet<Structure> structures = new java.util.TreeSet<Structure>();
023
024 /** The size of the original signal (also the wavelet space size). */
025 private int size;
026
027 /**
028 * Construct the WObject.
029 * @param relationships a set of interscale relationships
030 */
031 public WObject(java.util.Set<InterscaleRelationship> relationships) {
032 this.relationships = relationships;
033 for (InterscaleRelationship relationship : relationships) {
034 structures.add(relationship.getChild());
035 structures.add(relationship.getParent());
036 }
037 size = relationships.iterator().next().getChild().getScale().size(); //FIX: Very kludgy !
038 }
039
040 /**
041 * Reconstruct the signal for this WOBject (without the last smoothed scale).
042 * @return the reconstructed signal
043 */
044 public SimpleSignal reconstruct() {
045 SimpleSignal sum = new SimpleSignal(size);
046 for (Structure structure : structures) sum.add(structure.getCoefficients());
047 return sum;
048 }
049
050 // TODO: Get a tree-structure starting at the root of this WObject
051
052 /**
053 * Get the list of structures in this WOBject. The list is ordered by increasing scale.
054 * @return a list of structures belonging to this WObject
055 */
056 public java.util.SortedSet<Structure> getStructures() {
057 return structures;
058 }
059
060 }