Mark,
no, sorry, I cannot write such a program in Python - on a Mathematica site you have to accept solutions done in Mathematica. But its a fun problem!
My simple idea is
- to separate the image components with
MorphologicalComponents[]
,
- erasing them from the image
- and retouch those parts using
Inpaint[]
.
Here is my code:
(* importing complete image: *)
img0 = Import[
"https://community.wolfram.com//c/portal/getImageAttachment?filename=Spot_the_difference.png&userId=2853753"];
iDims = ImageDimensions[img0];
(* choosing the right side/image: *)
img1 = Image[ImageTrim[img0, {{.5, 0} iDims, iDims}], ImageSize -> {.5, 1} iDims];
img2 = Binarize[ColorQuantize[img1, 9, Dithering -> False], .2];
mcmps = MorphologicalComponents[img2];
(* choosing details to disappear: *)
(* ( respective indexes can be found using: *)
(* ComponentMeasurements[img2,{"Area","Image"}] ) *)
missings = {12, 22, 111, 116, 108, 47, 88, 109};
imgMask = Image@Map[If[Or @@ First@Outer[Equal, {#}, missings], 0, 1] &, mcmps, {2}];
img3 = img1 imgMask;
GraphicsRow[{img1, Inpaint[img3, Dilation[ColorNegate@imgMask, 3]]}]

Can you spot the differences?