简体   繁体   中英

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.

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. 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++?

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计算索引的函数。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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