public void FindPeaksTest2()
{
Bitmap hand = Accord.Imaging.Image.Clone(Properties.Resources.rhand0);
// ImageBox.Show(hand);
GaussianBlur median = new GaussianBlur(1.1);
median.ApplyInPlace(hand);
// Extract contour
BorderFollowing bf = new BorderFollowing(20);
List<IntPoint> contour = bf.FindContour(hand);
hand = hand.Clone(new Rectangle(0, 0, hand.Width, hand.Height), PixelFormat.Format24bppRgb);
// Find peaks
KCurvature kcurv = new KCurvature(30, new DoubleRange(0, 45));
var peaks = kcurv.FindPeaks(contour);
List<IntPoint> supports = new List<IntPoint>();
for (int i = 0; i < peaks.Count; i++)
{
int j = contour.IndexOf(peaks[i]);
supports.Add(contour[(j + kcurv.K) % contour.Count]);
supports.Add(contour[Accord.Math.Tools.Mod(j - kcurv.K, contour.Count)]);
}
// show(hand, contour, peaks, supports);
Assert.AreEqual(5, peaks.Count);
Assert.AreEqual(0, peaks[0].X);
Assert.AreEqual(80, peaks[0].Y);
Assert.AreEqual(113, peaks[1].X);
Assert.AreEqual(26, peaks[1].Y);
Assert.AreEqual(98, peaks[2].X);
Assert.AreEqual(9, peaks[2].Y);
Assert.AreEqual(73, peaks[3].X);
Assert.AreEqual(2, peaks[3].Y);
Assert.AreEqual(38, peaks[4].X);
Assert.AreEqual(14, peaks[4].Y);
}