ZQPei / patchmatch_inpainting

Implementation of PatchMatch for image inpainting in cpp
Other
48 stars 10 forks source link

Bad alloc! #1

Closed zvezdochiot closed 4 years ago

zvezdochiot commented 4 years ago

https://github.com/ZQPei/patchmatch_inpainting/blob/0bea9c6c62f1347841fd903d45bebbe2d8e2388e/source/main.cpp#L63-L65

Maybe?:

    int ** mask = (int **)calloc(int(height), sizeof(int*));
    for (int i = 0; i < height; i++)
            mask[i] = (int *)calloc(int(width), sizeof(int));

See: https://github.com/ZQPei/patchmatch_inpainting/blob/0bea9c6c62f1347841fd903d45bebbe2d8e2388e/source/main.cpp#L127-L130

ZQPei commented 4 years ago

I think you are probably right. The images I use are square, so I did not see this bug.

zvezdochiot commented 4 years ago

Testing https://github.com/ZQPei/patchmatch_inpainting/tree/master/image_files/forest

zvezdochiot commented 4 years ago

Fixed. :)