【发布时间】:2011-06-01 17:53:27
【问题描述】:
我编写了一个扩展方法,它从位图中返回 YUV 值的二维数组,即:
public static YUV[,] ToYuvLattice(this System.Drawing.Bitmap bm)
{
var lattice = new YUV[bm.Width, bm.Height];
for(var ix = 0; ix < bm.Width; ix++)
{
for(var iy = 0; iy < bm.Height; iy++)
{
lattice[ix, iy] = bm.GetPixel(ix, iy).ToYUV();
}
}
return lattice;
}
然后我需要提取具有相同 U 和 V 分量的集合。 IE。 Set1 包含所有 [item1;item2] 对,Set2 包含 [_item1;_item2] 对。所以我想获取列表列表。
public IEnumerable<List<Cell<YUV>>> ExtractClusters()
{
foreach(var cell in this.lattice)
{
if(cell.Feature.U != 0 || cell.Feature.V != 0)
{
// other condition to be defined
}
// null yet
yield return null;
}
}
我从上面的代码开始,但我坚持使用不同值的条件。
【问题讨论】:
标签: c# algorithm collections distinct