Exemple #1
0
 public void SiteFeatureSetInitialization()
 {
     SiteFeatureSet[,] sitesarray = new SiteFeatureSet[3,3];
     SiteFeatureSet.Init(sitesarray, new DenseVector(1, 2.3d));
     Assert.IsNotNull(sitesarray[1,1]);
     Assert.AreEqual(2.3d, sitesarray[1,1].Features[0]);
 }
Exemple #2
0
 /// <summary>
 /// Adds 1 to the front of a's features.
 /// </summary>
 /// <param name='a'>
 ///  A SiteFeatureSet to be transformed. 
 /// </param>
 public DenseVector Transform(SiteFeatureSet a)
 {
     double[] aa = a.ToArray();
     double[] z = new double[aa.Length + 1];
     z[0] = 1;
     aa.CopyTo(z,1);
     return new DenseVector(z);
 }
Exemple #3
0
 public static ImageData FromImage(Bitmap img, ImageWindowScheme iws, FeatureSet feature_set)
 {
     SiteFeatureSet[,] sitefeatures = new SiteFeatureSet[iws.XSites, iws.YSites];
     for(int x = 0; x < iws.XSites; x++) for(int y = 0; y < iws.YSites; y++)
     {
         sitefeatures[x,y] = new SiteFeatureSet(feature_set.ApplyToBitmap(img, x, y), feature_set);
     }
     return new ImageData(sitefeatures, feature_set.Length);
 }
Exemple #4
0
 private ImageData(SiteFeatureSet[,] site_features, int feature_count)
 {
     if(site_features == null) throw new ArgumentNullException("site_features");
     XSites = site_features.GetLength(0);
     YSites = site_features.GetLength(1);
     if(XSites == 0 || YSites == 0) throw new ArgumentException("site_features must not be size zero");
     FeatureCount = feature_count;
     this.site_features = site_features;
 }
 /// <summary>
 /// Combine the specified SiteFeatureSets, returning a DenseVector containing a's features
 /// and then b's in order. It also has a constant bias term.
 /// 
 /// Note: Not commutative.
 /// </summary>
 public DenseVector Cross(SiteFeatureSet a, SiteFeatureSet b)
 {
     double[] aa = a.ToArray();
     double[] ba = b.ToArray();
     double[] z = new double[aa.Length + ba.Length + 1];
     z[0] = 1;
     aa.CopyTo(z,1);
     ba.CopyTo(z,aa.Length+1);
     return new DenseVector(z);
 }
 /// <summary>
 /// Combine the specified SiteFeatureSets, returning a DenseVector containing the component-wise absolute
 /// difference of a and b. It also has a constant bias term.
 /// 
 /// Note: Commutative.
 /// </summary>
 public DenseVector Cross(SiteFeatureSet a, SiteFeatureSet b)
 {
     double[] aa = a.ToArray();
     double[] ba = b.ToArray();
     double[] z = new double[aa.Length + 1];
     z[0] = 1;
     for(int i = 0; i < aa.Length; i++)
     {
         z[i+1] = Math.Abs(aa[i] - ba[i]);
     }
     return new DenseVector(z);
 }
 /// <summary>
 /// Returns a DenseVector, the components of which are each pairwise product of the components of a.
 /// Note that we first add a 1 to the front of a, so that these pairwise products include
 /// 1*1, 1*a[0], 1*a[1], etc.
 /// This ensures that the QuadraticBasis is a superset of the LinearBasis.
 /// </summary>
 /// <param name='a'>
 ///  A SiteFeatureSet to be transformed. 
 /// </param>
 public DenseVector Transform(SiteFeatureSet a)
 {
     //DenseVector af = a.features;
     double[] aa = LinearBasis.INSTANCE.Transform(a).ToArray();
     double[] z = new double[(aa.Length*(aa.Length+1))/2];
     int count = 0;
     for(int i = 0; i < aa.Length; i++)
     {
         for(int j = i; j < aa.Length; j++)
         {
             z[count] = aa[i]*aa[j];
             count++;
         }
     }
     return new DenseVector(z);
 }
Exemple #8
0
 public ImageData FromImage(Bitmap img)
 {
     //TODO don't make the sitefeaturesarray! start with an
     //empty imagedata object and fill it out.
     //That way you can verify the length invariants.
     SiteFeatureSet[,] sitefeatures = new SiteFeatureSet[XSites, YSites];
     for(int x = 0; x < XSites; x++) for(int y = 0; y < YSites; y++)
     {
         sitefeatures[x,y] = new SiteFeatureSet(Features.ApplyToBitmap(img, x, y), Features);
         //TODO Assert that feature_set.Length == sitefeatures[x,y].Length
     }
     SitesSeen += XSites*YSites;
     ImagesSeen += 1;
     return new ImageData(sitefeatures, Features.Length);
 }