简体   繁体   English

具有自己的类的类型的2D数组的好选择

[英]What would be a good 2D-array alternative with the type of an own class

I'm doing image processing and I'd like to make an own object out of every pixel, containing stuff like position, ID, value, etc. Now in post-processing I need to access some of these specific objects around a currently selected Pixel. 我正在进行图像处理,我想用每个像素制作一个自己的对象,其中包含诸如位置,ID,值等内容。现在在后期处理中,我需要访问当前选定对象周围的某些特定对象像素

The easiest way I could imagine would be a storage like 我能想到的最简单的方法是像这样的存储

PixelClass[image.rows][image.cols]

returning a Pointer of the object at a position. 在某个位置返回对象的Pointer。 But I'm afraid this won't be easy to handle. 但恐怕这将不容易处理。 Are there any nice alternatives, to easily access the generated objects by their position (ie: x,y) in C++? 有什么不错的选择,可以通过C ++中它们的位置(即:x,y)轻松访问生成的对象?

EDIT: I forgot access needs to be as fast as possible, for real-time applications 编辑:对于实时应用程序,我忘记了访问速度需要尽快

Thanks for any advice 感谢您的任何建议

您可以提供大小为rows * cols的连续数组(例如,在类中使用std::vector<T>作为成员变量,并具有根据y * cols + x计算索引的函数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM