-2

I have the following piece of code for image processing, using the library CImg.

for (int y = 0; y < height; y++)
  for (int x = 0; x < width; x++) { 
      width = in.
      float weight = strength*x*(xmax-x)*y*(ymax-y)/(xmax*xmax)/(ymax*ymax);
      int new_x  = (int) ((1-weight)*x + weight*      y * xmax/ymax);
      int new_y  = (int) ((1-weight)*y + weight*(xmax-x)* ymax/xmax);
      out(x,y) = in(new_x,new_y);
  }

What does it mean the following line at the start of the cycle?

  width = in.

'width' and 'in' are respectively an int and a CImg object declared before.

Thank you.

taocp
  • 23,276
  • 10
  • 49
  • 62
charles
  • 713
  • 1
  • 6
  • 16

1 Answers1

6

That line is a syntax error, and will not pass compilation. It most likely was accidentally pasted there.

Googling for the code gives this, which contains the same code without that line:

for (int y = 0; y < height; y++)
  for (int x = 0; x < width; x++) {
    float weight = strength*x*(xmax-x)*y*(ymax-y)/(xmax*xmax)/(ymax*ymax);
    int new_x  = (int) ((1-weight)*x + weight*      y * xmax/ymax);
    int new_y  = (int) ((1-weight)*y + weight*(xmax-x)* ymax/xmax);
    out(x,y) = in(new_x,new_y);
  }

Another part of the code contains the line const int width = in.dimx();, which is probably the source of the accidental copy/paste.

interjay
  • 107,303
  • 21
  • 270
  • 254