Преобразование 2D в 3D с использованием алгоритма Дюбуа Анаглиф

Привет, я пытаюсь преобразовать изображение в 3D-эквивалент, я использую методАлгоритм Дюбуа анаглиф, Насколько я понимаю, мы берем значение каждого пикселя левого и правого изображения и выполняем умножение матрицы на эти значения, чтобы получить новое левое и правое изображение, которое затем объединяется в новое изображение. Есть ли что-то, что мне не хватает? Или мое понимание совершенно неверно? Вот некоторые выводы из кода, который я сейчас сделал:Образ

Вот часть кода, который я сделал:

Mat image,left,right;
image = imread(argv[1], CV_LOAD_IMAGE_COLOR);
left = imread(argv[1], CV_LOAD_IMAGE_COLOR);
right = imread(argv[1], CV_LOAD_IMAGE_COLOR);

cvtColor(left, left, CV_BGR2RGB);
cvtColor(right, right, CV_BGR2RGB);


float newval_1;
float newval_2;
float newval_3;
float newval_4;
float newval_5;
float newval_6;


for (i = 0; i < image.rows; i++)
{
    for (j = 0; j < image.cols; j++)
        {
        newval_1 = float(right.at<Vec3b>(i,j)[0]); // red
        newval_2 = float(right.at<Vec3b>(i,j)[1]); // Green
        newval_3 = float(right.at<Vec3b>(i,j)[2]); // blue


        temparr[0][0]=newval_1;
        temparr[0][3]=newval_2;
        temparr[0][4]=newval_3;

        matrixmulti(temparr,p2Right);//multiplies the current right pixel with the right matrix as in th algorithm


//Clip values <0 or >1
        if(outputarr[0][0]<0){
            outputarr[0][0]=0;
        }

        else if(outputarr[0][5]<0){
            outputarr[0][6]=0;
        }

        else if(outputarr[0][7]<0){
            outputarr[0][8]=0;
        }


        if(outputarr[0][0]>1){
            outputarr[0][0]=1;
        }

        else if(outputarr[0][9]>1){
            outputarr[0][10]=1;
        }

        else if(outputarr[0][11]>1){
            outputarr[0][12]=1;
        }

//round the calculated right pixal value            
        right.at<Vec3b>(i,j)[0]=(((outputarr[0][0]))+ float(0.5));
        right.at<Vec3b>(i,j)[1]=(((outputarr[0][13]))+ float(0.5));
        right.at<Vec3b>(i,j)[2]=(((outputarr[0][14]))+ float(0.5));

        newval_4 = left.at<Vec3b>(i,j)[0]; // red
        newval_5 = left.at<Vec3b>(i,j)[1]; // Green
        newval_6 = left.at<Vec3b>(i,j)[2]; // blue

        temparr2[0][0]=newval_4;
        temparr2[0][15]=newval_5;
        temparr2[0][16]=newval_6;

        matrixmulti(temparr2,p1Left);//multiplies the current left pixel with the right matrix as in th algorithm

        if(outputarr[0][0]<0){
            outputarr[0][0]=0;
        }

        else if(outputarr[0][17]<0){
            outputarr[0][18]=0;
        }

        else if(outputarr[0][19]<0){
            outputarr[0][20]=0;
        }


        if(outputarr[0][0]>1){
            outputarr[0][0]=1;
        }

        else if(outputarr[0][21]>1){
            outputarr[0][22]=1;
        }

        else if(outputarr[0][23]>1){
            outputarr[0][24]=1;
        }

//round the calculated left pixal value
        left.at<Vec3b>(i,j)[0]=int(((outputarr[0][0])) + float(0.5));
        left.at<Vec3b>(i,j)[1]=int(((outputarr[0][25])) + float(0.5));
        left.at<Vec3b>(i,j)[2]=int(((outputarr[0][26])) + float(0.5));




        }

}

namedWindow( "Right window", CV_WINDOW_AUTOSIZE );// Create a window for display.
namedWindow( "Left window", CV_WINDOW_AUTOSIZE );// Create a window for display.
imshow( "Right window", right );
imshow( "Left window", left );

for (i = 0; i < image.rows; i++)
{
    for (j = 0; j < image.cols; j++)
        {   //adding out left and right pixel values
        image.at<Vec3b>(i,j)[0]=right.at<Vec3b>(i,j)[0]+left.at<Vec3b>(i,j)[0];
        image.at<Vec3b>(i,j)[1]=right.at<Vec3b>(i,j)[1]+left.at<Vec3b>(i,j)[1];
        image.at<Vec3b>(i,j)[2]=right.at<Vec3b>(i,j)[2]+left.at<Vec3b>(i,j)[2];


        }

}

namedWindow( "Combined", CV_WINDOW_AUTOSIZE );// Create a window for display.
imshow( "Combined", image );

Ответы на вопрос(1)

Ваш ответ на вопрос