Fixed the memory leak! Made sure the IplImage was released after it was called.