Strange Image errors with OpenCV

So I've been working on some code for a couple weeks and it is far from complete, However the one thing keeping me from moving forward is a strange problem which I cannot figure out.

The code below is for a program which accepts to command line arguments, an infile and an outfile. The infile will be a small square binary tif image, somewhere between 200x200 and 400x400. At this point the program should tile the image, stretching each part to various lengths. The outfile should have a height of 768 pixels and a width in the ballpark of 50k to 60k pixels. I apologize, but I can't supply them for example, they are confidential.
While it does work, sort of, it only replicates images to around 34k pixels and stops. The last row continues to display a black streak to the end.
I think the problem is coming from my create1track() function. I have tried optimizing it with very few changes. If I use a while loop as opposed to a for loop I get three black streaks as opposed to one. Does anyone have any suggestions on why it might do this?

I'm posting my entire code, hoping for some advice. I've been stuck for a while on this one. It's too big for this forum but you can get it here:

https://www.dropbox.com/s/sp153rz252uikue/main_backup.cpp

I'd accept any other criticism/input, just be nice, I just started teaching myself c++ about 2 months ago and since I'm pretty new to programming in general, I'm sure there is plenty of things I'm doing wrong.
Just an update, the problem is a known bug in opencv when the remap function is used in very large images. This affects functions like warpaffine.
I believe the limit is 2^15 bits. ~33k pixels for a binary image.
Yep, that was the problem.
Topic archived. No new replies allowed.