slow processing in gmic inpaint large image

Hi, I am new to gmic and its CLI. I am trying to fill a specific area in several thousand images using gmic. I successfully done it in one image using following command:

gmic a.jpg 100%,100% polygon[-1] 5,345,4095,475,3976,700,4044,901,3875,1495,4095,1,255,255,255 +inpaint_pde[0] [1]

This mask is present only in the lowest part of the image. If I try same in gimp, its processed instantly using gmic gimp qt (GUI).

I have thousands of images to process and each with same size of around 3000 x 4000. Each image with above command is taking long time to process. Can any one suggest a solution to that. I read somewhere that we can divide the image into parts, but I wasn’t able to find that in G’MIC reference documentation.

The PDE-based inpainting algorithm does not require a lot of context to work, which means you can indeed extract the image area corresponding to the region you want to inpaint, surrounded by a bit of known pixels, then apply the inpainting algorithm on this region, and paste the result back to the original image.
In you case, something like:

gmic a.jpg 100%,100% polygon[-1] 5,345,4095,475,3976,700,4044,901,3875,1495,4095,1,255,255,255 +z 330,3800,1300,100% inpaint_pde[2] [3] j[0] [2],330,3800 k[0]

should work.

1 Like

Wow thats fast… thank you so much, thats exactly what I was looking for… A little more help I appreciate if you can describe a little whats happening here, its a little complicated, I didnt really understand the “z [3] j k” …

The command z is a shortcut for command crop, so +z ... extracts some small region from the input image and the mask. After the crop, your list has 4 images :

  • [0] = Fullres color image
  • [1] = Fullres binary mask
  • [2] = Cropped region from color image.
  • [3] = Cropped region from binary mask.
    Now, we apply inpaint_pde[2] [3] to reconstruct cropped color image [2] using the inpainting mask [3], and we finally redraw the reconstructed region [2] into the fullres color image [0] (command j, aka image). Latest command k (aka keep) only keeps the fullres reconstructed color image, which is the one that is interesting.
1 Like

Thanks for your prompt reply, appreciate that