集合中不同的子集
我编写了一个扩展方法,它从位图中返回 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 分量的集合。即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;
}
}
我从上面的代码开始,但我坚持使用不同值的条件。
I wrote an extension method which returns me 2-dimensional array of YUV values from a bitmap i.e.:
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;
}
Then I need to extract sets with the same U and V components. I.e. Set1 contains all [item1;item2] pairs, Set2 conatains [_item1;_item2] pairs. So I want to get List of Lists.
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;
}
}
I started with above code but I stuck with condition to distinct values.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
听起来您有一个等价关系并且想要对数据进行分区。通过等价关系,我的意思是:
如果这就是你所拥有的,那么这应该可以工作。
用法:
It sounds like you have an equivalence relation and you want to partition the data. By equivalence relation, I mean:
If that is what you have then this should work.
Usage: