Aligning Memory, continued

If you are trying to enhance performance when performing image processing operations, for example, you should try to align every row of an image to be aligned. For this purpose you can define the width of an image in accordance with the data type you are working with: for example, for 8u data and a three-channel image, you need to choose the width w of the image in pixels so that w*3 is a multiple of 8, or preferably 16. Although the width understandably becomes larger, you can subsequently define the area that you have to process exactly as you want, using special parameters passed to almost every image processing function. The special parameters are the width step (given in bytes) and size of the rectangular region of interest (ROI) being processed. The best way to create an image with every row aligned is by using the function ippiMalloc().

You have the option of letting Intel IPP perform memory alignment if you use the ippsMalloc() function. You may also align the memory yourself by requesting memory that exceeds the required size by 32 bytes and align the memory to make sure the performance is maximal.