whistlesAndMoans
Class RejoiningFragmenter

java.lang.Object
  extended by whistlesAndMoans.DiscardingFragmenter
      extended by whistlesAndMoans.FragmentingFragmenter
          extended by whistlesAndMoans.RejoiningFragmenter
All Implemented Interfaces:
RegionFragmenter

public class RejoiningFragmenter
extends FragmentingFragmenter

Join fragmented shapes back together again. Probably not very efficient code since it goes through the list in fragments and if it joins two fragments together, it then removes one from the list, so the list gets progressively smaller.

Author:
Doug Gillespie

Field Summary
(package private) static int gradLength
           
 
Fields inherited from class whistlesAndMoans.FragmentingFragmenter
fragments, whistleMoanControl
 
Fields inherited from class whistlesAndMoans.DiscardingFragmenter
maxPeaks, motherRegion, nFragments, nSlices, slicePeaks, totalPeaks
 
Constructor Summary
RejoiningFragmenter(WhistleMoanControl whistleMoanControl)
           
 
Method Summary
private  boolean branch(int branchIndex)
           
private  void checkDoubles()
           
private  void checkDuplicates()
           
private  void crossCrosses()
          Find regions which are clearly crosses, then find all the bits to the left and the bits to the right, then join them together.
 int fragmentRegion(ConnectedRegion connectedRegion)
          Fragment a connected region
 ConnectedRegion getFragment(int fragment)
          Get a specific fragment
private  boolean jumpCross(int crossIndex)
           
private  boolean matchPeak(SliceData sliceData1, SliceData sliceData2, int connectType)
           
private  ConnectedRegion merge(int mergeIndex)
           
private  void mergeWhistles(ConnectedRegion r1, ConnectedRegion r2)
           
private  int removeShortFragments()
          this will have called the super class fragmenter in a way which will have selected even the shortest fragments.
private  double shortPenalty(int fragLength)
          calculate a penalty to penalise very short fragments by when deciding which are the best match during a merge of a split.
 
Methods inherited from class whistlesAndMoans.FragmentingFragmenter
cleanFragments, closeRegion, createFragments, getNumFragments, isDiscardSmallOnes, matchPeak, sayFragment, sayFragments, setDiscardSmallOnes
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

gradLength

static final int gradLength
See Also:
Constant Field Values
Constructor Detail

RejoiningFragmenter

public RejoiningFragmenter(WhistleMoanControl whistleMoanControl)
Method Detail

fragmentRegion

public int fragmentRegion(ConnectedRegion connectedRegion)
Description copied from interface: RegionFragmenter
Fragment a connected region

Specified by:
fragmentRegion in interface RegionFragmenter
Overrides:
fragmentRegion in class FragmentingFragmenter
Parameters:
connectedRegion - region to fragment
Returns:
number of fragments.

checkDoubles

private void checkDoubles()

checkDuplicates

private void checkDuplicates()

crossCrosses

private void crossCrosses()
Find regions which are clearly crosses, then find all the bits to the left and the bits to the right, then join them together.


jumpCross

private boolean jumpCross(int crossIndex)

merge

private ConnectedRegion merge(int mergeIndex)

shortPenalty

private double shortPenalty(int fragLength)
calculate a penalty to penalise very short fragments by when deciding which are the best match during a merge of a split.

Parameters:
fragLength - fragment length
Returns:
penalty (to add to gradient difference)

branch

private boolean branch(int branchIndex)

mergeWhistles

private void mergeWhistles(ConnectedRegion r1,
                           ConnectedRegion r2)

matchPeak

private boolean matchPeak(SliceData sliceData1,
                          SliceData sliceData2,
                          int connectType)

removeShortFragments

private int removeShortFragments()
this will have called the super class fragmenter in a way which will have selected even the shortest fragments. Now need to get rid of those !

Returns:
number of remaining fragments.

getFragment

public ConnectedRegion getFragment(int fragment)
Description copied from interface: RegionFragmenter
Get a specific fragment

Specified by:
getFragment in interface RegionFragmenter
Overrides:
getFragment in class FragmentingFragmenter
Parameters:
fragment - fragment number (0 to getNumFragments);
Returns:
the ith fragment