'how to align an image cv::Mat or Iplimage

I have a function that takes a pointer to an image as input, but the problem is that the image by the pointer looks like this:

enter image description here

How can I align it?

image.SetImagePtr(matWidth, matHeigth, m_originalImg.data);


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source