/// <summary>
/// Compares histogram over each possible rectangular patch of the specified size in the input images, and stores the results to the output map dst.
/// </summary>
/// <param name="srcs">Source images, all are of the same size and type</param>
/// <param name="factor">Normalization factor for histograms, will affect normalization scale of destination image, pass 1 if unsure. </param>
/// <param name="patchSize">Size of patch slid though the source images.</param>
/// <param name="method">Comparison method, passed to cvCompareHist.</param>
/// <typeparam name="TDepth">The type of depth of the image</typeparam>
/// <returns>Destination back projection image of the same type as the source images</returns>
public Image <Gray, Single> BackProjectPatch <TDepth>(Image <Gray, TDepth>[] srcs, System.Drawing.Size patchSize, CvEnum.HISTOGRAM_COMP_METHOD method, double factor) where TDepth : new()
{
Debug.Assert(srcs.Length == Dimension, Properties.StringTable.IncompatibleDimension);
IntPtr[] imgPtrs =
Array.ConvertAll <Image <Gray, TDepth>, IntPtr>(
srcs,
delegate(Image <Gray, TDepth> img) { return(img.Ptr); });
Size imgSize = srcs[0].Size;
Image <Gray, Single> res = new Image <Gray, float>(imgSize.Width - patchSize.Width + 1, imgSize.Height - patchSize.Height + 1);
CvInvoke.cvCalcBackProjectPatch(imgPtrs, res.Ptr, patchSize, Ptr, method, factor);
return(res);
}