darrenlafreniere / lafarren-image-completer

Implementation of the research titled: "Image Completion Using Efficient Belief Propagation via Priority Scheduling and Dynamic Pruning"
http://www.lafarren.com/image-completer/
GNU General Public License v3.0
32 stars 18 forks source link

Magic numbers in GetCoordinatesToIncludeOddEdge #35

Open daviddoria opened 13 years ago

daviddoria commented 13 years ago

In Label.cpp, this function as some 3's, 1's, and -1's that should be commented.

daviddoria commented 13 years ago

it makes as many 2x2 blocks in the upper left as it can and then makes some 2x3 or 3x3 blocks around the right and bottom edges, then a 3x3 in the bottom corner (if it is odd x odd)

For 5x5, you get one 2x2 block in the upper left one 3x2 block in the upper right one 2x3 block in the lower left and one 3x3 block in the lower right

daviddoria commented 13 years ago

At line 40 in Label.cpp:

const bool widthIsOdd = (width & 1) == 1;

Is there a reason for the, what I'll call, cryptic notation? Is this at a critical point in the code? Or could it be changed to, for readability:

bool widthIsOdd; if(width & 1 == 1) // width is odd { widthIsOdd = true; } else { widthIsOdd = false; }

and then

outIncludeOddEdgeAtX = widthIsOdd ? (width - 3) : -1;

to

if(widthIsOdd) { outIncludeOddEdgeAtX = height-3; } else { outIncludeOddEdgeAtX = -1; }

?

daviddoria commented 13 years ago

I guess I also don't follow the name of GetCoordinatesToIncludeOddEdge - like what is a "Coordinate to include odd edge"?