opencv raw8转rgb

#include 
#include 
#include 
#include 
#include 
#include 
using namespace std;
using namespace cv;

int main()
{
    Mat srcImage ;
    int width = 4000 ;
    int height = 3000;
    Size2i rgb_size(width / 2 ,height / 2 );
    Mat dstImage(rgb_size,CV_8UC3);
    ushort pixel;

    //read date of image from file
    FILE *fp ;
    if((fp = fopen("/home/solitary/Documents/4000x3000_raw8.raw","rb")) == nullptr)
    {
        cout << "image is not exist!" <(cols / 2 , rows / 2);
            if( fread( &pixel, sizeof(pixel), 1, fp ) != 1 )
            {
                cout << "read data of image failed! sizeof(pixel) = " << sizeof (pixel) <((pixel >> 8) & 0xFF);
                //  Gr
                v_mat[1] = saturate_cast((pixel >> 0) & 0xFF);
            }else
            {   //  Gb
                uchar Gb = saturate_cast((pixel >> 8) & 0xFF);
                //  G
                v_mat[1] = saturate_cast((Gb + v_mat[1]) / 2);
                //  B
                v_mat[0] = saturate_cast((pixel >> 0) & 0xFF);
            }

//            cout << "v_mat[0] = 0x" << hex << v_mat[0] <

 

你可能感兴趣的:(opencv)