Q:

uchar* to std::vector and back?

I have some image data as a uchar*. I need to run processing on it as a std::vector<uchar>, and then convert it back. I am using this code:
unsigned char* buffer = inputImg.data; //Image data from cv::Mat

    std::vector<uchar> vec;
    size_t size_of_buffer = sizeof(buffer);
    vec.assign(buffer, buffer + size_of_buffer);

    uchar* _compressed = reinterpret_cast<uchar*>(vec.data());

When I then view the result with:
    cv::Mat mat = cv::Mat(_height, _width, inputImg.type(), _compressed );

this results in a black image. Where am I going wrong?
EDIT:
based on comments below, i have changed the code to:
//from Mat
    int COLOR_COMPONENTS = inputImg.channels();
    int _width = inputImg.cols;
    int _height = inputImg.rows;

    //to std::vector and back
    std::vector<uchar> vec;
    size_t size_of_buffer = _width * _height*COLOR_COMPONENTS;

    vec.assign(buffer, buffer + size_of_buffer);
    uchar* _compressed = reinterpret_cast<uchar*>(vec.data());

As in the answer below, this works. 

A:

This code works for me and displays the image correctly:
int main()
{
    cv::Mat input = cv::imread("C:/StackOverflow/Input/Lenna.png");
    cv::Mat inputImg = input;

    int COLOR_COMPONENTS = inputImg.channels();
    int _width = inputImg.cols;
    int _height = inputImg.rows;

    //to std::vector and back
    std::vector<uchar> vec;
    size_t size_of_buffer = _width * _height*COLOR_COMPONENTS;

    unsigned char* buffer = inputImg.data;

    vec.assign(buffer, buffer + size_of_buffer);
    uchar* _compressed = reinterpret_cast<uchar*>(vec.data());

    cv::Mat mat = cv::Mat(_height, _width, inputImg.type(), _compressed);

    cv::imshow("output", mat);
    cv::waitKey(0);
    return 0;
}

Visual Studio 2013 with OpenCV 3.4

