Ask Your Question
0

Error left operand must be l-value

asked 2013-06-01 11:10:48 -0600

william gravatar image

updated 2013-06-01 13:00:04 -0600

Guanta gravatar image

Hi, please help.

I got an error while building my program: "error C2106: '=' : left operand must be l-value". Actually i want to assign first pixel of Output_image with first pixel of 3x3 Gaussian mask, then second pixel of Output_image with second pixel of 5x5 Gausssian mask and so on. I figure that the problem come from the line [int(outputimage.at<uchar>(x,y)) = int(image_3.at<uchar>(x,y))] for the program shown below:

cv::GaussianBlur(image,image_3,cv::Size(3,3),0,0);
cv::GaussianBlur(image,image_5,cv::Size(3,3),0,0);

for(int x=0; x<image_height; x++)
        for(int y=0; y<image_width; y++)
        {
            if(y%2==0)
              int(Output_image.at<uchar>(x,y)) = int(image_3.at<uchar>(x,y));
            else if (y%2==1)
              int(Output_image.at<uchar>(x,y)) = int(image_5.at<uchar>(x,y));
        }

Is it correct for me to assign [int(Output_image.at<uchar>(x,y)) = int(image_3.at<uchar>(x,y))]? Please advise me on how to solve the above error.

Thamk you very much.

edit retag flag offensive close merge delete

Comments

int() ??!! please try: Output_image.at<uchar>(x,y) = image_4.at<uchar>(x,y) .

Offtopic: typically you take y-index for the rows (=height) and x-index for the columns (=width).

Guanta gravatar imageGuanta ( 2013-06-01 13:04:36 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2013-06-01 14:30:09 -0600

unxnut gravatar image

updated 2013-06-01 14:35:10 -0600

Remove the int around Output_image.at<uchar>(x,y).

Another stylistic thing:

Output_image.at<uchar>(x,y) = ( y % 2 ) ? image_5.at<uchar>(x,y) : image_3.at<uchar>(x,y);

edit flag offensive delete link more

Question Tools

Stats

Asked: 2013-06-01 11:10:48 -0600

Seen: 437 times

Last updated: Jun 01 '13