# Revision history [back]

### how could I change memory layout from hwc to chw ?

Hi,

I noticed that the default memory order is HWC which means that the offset is computed as offset = h * im.rows * im.elemSize() + w * im.elemSize() + c'. However, I need to change the layout toCHWmode, which means that the offset of(h, w, c)should beoffset = c * im.rows * im.cols + h * im.cols + w.

Is there any built-in method to do this ? If not, is there any c++11/14 built-in method to do this? Or what is the fastest way to do this ?

### how could I change memory layout from hwc to chw ?

Hi,

I noticed that the default memory order is HWC which means that the offset is computed as offset = h * im.rows * im.elemSize() + w * im.elemSize() + c'. c. However, I need to change the layout toto CHWCHW mode, which means that the offset ofof (h, w, c) should be should beoffset = c * im.rows * im.cols + h * im.cols + w. w.

Is there any built-in method to do this ? If not, is there any c++11/14 built-in method to do this? Or what is the fastest way to do this ?