Message Boards Message Boards

0
|
2076 Views
|
2 Replies
|
6 Total Likes
View groups...
Share
Share this post:

Make data for spot the differences game

Posted 1 year ago

How can I write that program in Python? My program take an image, it will detect objects in that image and process, output a new image which have some differences (rotate, hide, ...). What algorithms/methods in image processing do I need to learn? I need that program to make data for Spot the differences game. Thank you for your help!enter image description here

POSTED BY: Mark Whel
2 Replies

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]]}]

enter image description here

Can you spot the differences?

POSTED BY: Henrik Schachner

POSTED BY: Martijn Froeling
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract