How to make a spiroglyphic?












9














Some (older) members of this group might remember playing vinyl LP records. Recently, at the Abbey Road studio there was a spiroglyphics coloring book for sale. It looks like a nice programming exercise using image processing—but I was wondering if anyone had already written code to turn pictures into a spiroglyphic? Indeed, it would be a nice built-in command!










share|improve this question
























  • A start: r[θ_] := (.05 + .02 Sin[20 θ]); ParametricPlot[{(.1 θ - r[θ]) {Cos[θ], Sin[θ]}, {(.1 θ + r[θ]) {Cos[θ], Sin[θ]}}}, {θ], 0, 22 [Pi]}]
    – David G. Stork
    Dec 19 '18 at 6:37












  • mathematica.stackexchange.com/a/8693/219
    – faleichik
    Dec 24 '18 at 13:37
















9














Some (older) members of this group might remember playing vinyl LP records. Recently, at the Abbey Road studio there was a spiroglyphics coloring book for sale. It looks like a nice programming exercise using image processing—but I was wondering if anyone had already written code to turn pictures into a spiroglyphic? Indeed, it would be a nice built-in command!










share|improve this question
























  • A start: r[θ_] := (.05 + .02 Sin[20 θ]); ParametricPlot[{(.1 θ - r[θ]) {Cos[θ], Sin[θ]}, {(.1 θ + r[θ]) {Cos[θ], Sin[θ]}}}, {θ], 0, 22 [Pi]}]
    – David G. Stork
    Dec 19 '18 at 6:37












  • mathematica.stackexchange.com/a/8693/219
    – faleichik
    Dec 24 '18 at 13:37














9












9








9


4





Some (older) members of this group might remember playing vinyl LP records. Recently, at the Abbey Road studio there was a spiroglyphics coloring book for sale. It looks like a nice programming exercise using image processing—but I was wondering if anyone had already written code to turn pictures into a spiroglyphic? Indeed, it would be a nice built-in command!










share|improve this question















Some (older) members of this group might remember playing vinyl LP records. Recently, at the Abbey Road studio there was a spiroglyphics coloring book for sale. It looks like a nice programming exercise using image processing—but I was wondering if anyone had already written code to turn pictures into a spiroglyphic? Indeed, it would be a nice built-in command!







image-processing code-request generative-art






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 19 '18 at 7:15









Kuba

103k12201515




103k12201515










asked Dec 19 '18 at 6:02









TheDoctor

1,432715




1,432715












  • A start: r[θ_] := (.05 + .02 Sin[20 θ]); ParametricPlot[{(.1 θ - r[θ]) {Cos[θ], Sin[θ]}, {(.1 θ + r[θ]) {Cos[θ], Sin[θ]}}}, {θ], 0, 22 [Pi]}]
    – David G. Stork
    Dec 19 '18 at 6:37












  • mathematica.stackexchange.com/a/8693/219
    – faleichik
    Dec 24 '18 at 13:37


















  • A start: r[θ_] := (.05 + .02 Sin[20 θ]); ParametricPlot[{(.1 θ - r[θ]) {Cos[θ], Sin[θ]}, {(.1 θ + r[θ]) {Cos[θ], Sin[θ]}}}, {θ], 0, 22 [Pi]}]
    – David G. Stork
    Dec 19 '18 at 6:37












  • mathematica.stackexchange.com/a/8693/219
    – faleichik
    Dec 24 '18 at 13:37
















A start: r[θ_] := (.05 + .02 Sin[20 θ]); ParametricPlot[{(.1 θ - r[θ]) {Cos[θ], Sin[θ]}, {(.1 θ + r[θ]) {Cos[θ], Sin[θ]}}}, {θ], 0, 22 [Pi]}]
– David G. Stork
Dec 19 '18 at 6:37






A start: r[θ_] := (.05 + .02 Sin[20 θ]); ParametricPlot[{(.1 θ - r[θ]) {Cos[θ], Sin[θ]}, {(.1 θ + r[θ]) {Cos[θ], Sin[θ]}}}, {θ], 0, 22 [Pi]}]
– David G. Stork
Dec 19 '18 at 6:37














mathematica.stackexchange.com/a/8693/219
– faleichik
Dec 24 '18 at 13:37




mathematica.stackexchange.com/a/8693/219
– faleichik
Dec 24 '18 at 13:37










1 Answer
1






active

oldest

votes


















10














Update



In case your want to get your coloring on:



getColoringLines = 
ColorNegate@
GradientFilter[ImportString[ExportString[#, "PNG"], "PNG"], 1] &;

getColoringLines@spiroglyph[testImg, .36, 25, {6, 2}]


enter image description here



Original



Here's my initial attempt:



Clear[spiroglyph];
Options[spiroglyph] = Options[Rasterize];
spiroglyph[img_,
clipping : _?(0 < # < 1 &) : .1,
rots_Integer: 25,
thickGap : {_Integer, _Integer} : {10, 5},
mode : "Positive" | "Negative" : "Positive",
ops : OptionsPattern] :=
Module[
{
baseDims = ImageDimensions[img],
diskRadius,
bw = ColorConvert[img, "Grayscale"],
baseMask,
mask,
clipMask,
mid,
sampleImage,
gapMask,
minMask,
pr
},
diskRadius = Min[baseDims];
mid = baseDims/2;
pr =
{
{-diskRadius, diskRadius},
{-diskRadius, diskRadius}
};
baseMask =
Binarize@
Rasterize[
ParametricPlot[
(diskRadius/rots) (θ/(2 π)) {Cos[θ],
Sin[θ]}, {θ, 0, 2 π*rots},
Axes -> False,
PlotStyle ->
Directive[AbsoluteThickness[thickGap[[1]]], Black],
ImageSize -> baseDims,
PlotRangePadding -> Scaled[.01],
PlotRange -> pr
],
ops
];
mask = ImageResize[baseMask, baseDims];
gapMask =
Binarize@
Rasterize[
ParametricPlot[
((diskRadius/
rots) ((θ + π)/(2 π))) {Cos[θ],
Sin[θ]}, {θ, 0, 2 π*rots},
Axes -> False,
PlotStyle ->
Directive[AbsoluteThickness[thickGap[[2]]], Black],
ImageSize -> baseDims,
PlotRangePadding -> Scaled[.01],
PlotRange -> pr
],
ops
];
gapMask = ImageResize[gapMask, baseDims];
If[mode === "Positive", {mask, gapMask} = {gapMask, mask}];
sampleImage =
Blend[
If[mode === "Positive",
{bw, ColorNegate@mask},
{ColorNegate@bw, mask}
],
.3
];
minMask =
Binarize@
Rasterize[
ParametricPlot[
Evaluate@
If[mode === "Positive",
(diskRadius/rots) (θ/(2 π)) {Cos[θ],
Sin[θ]},
(diskRadius/
rots) ((θ + π)/(2 π)) {Cos[θ],
Sin[θ]}
], {θ, 0, 2 π*rots},
Axes -> False,
PlotStyle -> Directive[AbsoluteThickness[1], Black],
ImageSize -> baseDims,
PlotRangePadding -> Scaled[.01],
PlotRange -> pr
],
ops
];
minMask = ImageResize[minMask, baseDims];
(
MeanFilter[
Binarize[
sampleImage,
clipping
],
3
] + gapMask
)*minMask
]


I basically use a bunch of tricks with ParametricPlot masks to try to get an image to imprint. It doesn't really pick up details well:



testImg = ExampleData[{"TestImage", "Mandrill"}]


enter image description here



spiroglyph[testImg, .36, 25, {6, 2}]


enter image description here



It can also work for the negative of the image:



spiroglyph[
ExampleData[{"TestImage", "F16"}], .35, 40, {8, 5}, "Negative"]


enter image description here



And you can play with all the parameters to try to improve things:



spiroglyph[
ExampleData[{"TestImage", "F16"}], .32, 60, {10, 3}, "Negative",
ImageResolution -> 200]


enter image description here



Oh and here's Elvis:



elvis =
ImageTake[#, ImageDimensions[#][[1]]] &@
Import[
"http://www.gstatic.com/tv/thumb/persons/1382/1382_v9_ba.jpg"];

spiroglyph[elvis, .2, 85, {4, 2}]


enter image description here



And another example on a much simpler test case:



spiroglyph[
ImageCrop[#, {Min@ImageDimensions[#], Min@ImageDimensions[#]}] &@
Import["https://i.etsystatic.com/13221305/r/il/e04597/1390417240/il_
570xN.1390417240_lnh7.jpg"],
35,
{5, 1}
]


enter image description here






share|improve this answer























    Your Answer





    StackExchange.ifUsing("editor", function () {
    return StackExchange.using("mathjaxEditing", function () {
    StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
    StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
    });
    });
    }, "mathjax-editing");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "387"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f188139%2fhow-to-make-a-spiroglyphic%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    10














    Update



    In case your want to get your coloring on:



    getColoringLines = 
    ColorNegate@
    GradientFilter[ImportString[ExportString[#, "PNG"], "PNG"], 1] &;

    getColoringLines@spiroglyph[testImg, .36, 25, {6, 2}]


    enter image description here



    Original



    Here's my initial attempt:



    Clear[spiroglyph];
    Options[spiroglyph] = Options[Rasterize];
    spiroglyph[img_,
    clipping : _?(0 < # < 1 &) : .1,
    rots_Integer: 25,
    thickGap : {_Integer, _Integer} : {10, 5},
    mode : "Positive" | "Negative" : "Positive",
    ops : OptionsPattern] :=
    Module[
    {
    baseDims = ImageDimensions[img],
    diskRadius,
    bw = ColorConvert[img, "Grayscale"],
    baseMask,
    mask,
    clipMask,
    mid,
    sampleImage,
    gapMask,
    minMask,
    pr
    },
    diskRadius = Min[baseDims];
    mid = baseDims/2;
    pr =
    {
    {-diskRadius, diskRadius},
    {-diskRadius, diskRadius}
    };
    baseMask =
    Binarize@
    Rasterize[
    ParametricPlot[
    (diskRadius/rots) (θ/(2 π)) {Cos[θ],
    Sin[θ]}, {θ, 0, 2 π*rots},
    Axes -> False,
    PlotStyle ->
    Directive[AbsoluteThickness[thickGap[[1]]], Black],
    ImageSize -> baseDims,
    PlotRangePadding -> Scaled[.01],
    PlotRange -> pr
    ],
    ops
    ];
    mask = ImageResize[baseMask, baseDims];
    gapMask =
    Binarize@
    Rasterize[
    ParametricPlot[
    ((diskRadius/
    rots) ((θ + π)/(2 π))) {Cos[θ],
    Sin[θ]}, {θ, 0, 2 π*rots},
    Axes -> False,
    PlotStyle ->
    Directive[AbsoluteThickness[thickGap[[2]]], Black],
    ImageSize -> baseDims,
    PlotRangePadding -> Scaled[.01],
    PlotRange -> pr
    ],
    ops
    ];
    gapMask = ImageResize[gapMask, baseDims];
    If[mode === "Positive", {mask, gapMask} = {gapMask, mask}];
    sampleImage =
    Blend[
    If[mode === "Positive",
    {bw, ColorNegate@mask},
    {ColorNegate@bw, mask}
    ],
    .3
    ];
    minMask =
    Binarize@
    Rasterize[
    ParametricPlot[
    Evaluate@
    If[mode === "Positive",
    (diskRadius/rots) (θ/(2 π)) {Cos[θ],
    Sin[θ]},
    (diskRadius/
    rots) ((θ + π)/(2 π)) {Cos[θ],
    Sin[θ]}
    ], {θ, 0, 2 π*rots},
    Axes -> False,
    PlotStyle -> Directive[AbsoluteThickness[1], Black],
    ImageSize -> baseDims,
    PlotRangePadding -> Scaled[.01],
    PlotRange -> pr
    ],
    ops
    ];
    minMask = ImageResize[minMask, baseDims];
    (
    MeanFilter[
    Binarize[
    sampleImage,
    clipping
    ],
    3
    ] + gapMask
    )*minMask
    ]


    I basically use a bunch of tricks with ParametricPlot masks to try to get an image to imprint. It doesn't really pick up details well:



    testImg = ExampleData[{"TestImage", "Mandrill"}]


    enter image description here



    spiroglyph[testImg, .36, 25, {6, 2}]


    enter image description here



    It can also work for the negative of the image:



    spiroglyph[
    ExampleData[{"TestImage", "F16"}], .35, 40, {8, 5}, "Negative"]


    enter image description here



    And you can play with all the parameters to try to improve things:



    spiroglyph[
    ExampleData[{"TestImage", "F16"}], .32, 60, {10, 3}, "Negative",
    ImageResolution -> 200]


    enter image description here



    Oh and here's Elvis:



    elvis =
    ImageTake[#, ImageDimensions[#][[1]]] &@
    Import[
    "http://www.gstatic.com/tv/thumb/persons/1382/1382_v9_ba.jpg"];

    spiroglyph[elvis, .2, 85, {4, 2}]


    enter image description here



    And another example on a much simpler test case:



    spiroglyph[
    ImageCrop[#, {Min@ImageDimensions[#], Min@ImageDimensions[#]}] &@
    Import["https://i.etsystatic.com/13221305/r/il/e04597/1390417240/il_
    570xN.1390417240_lnh7.jpg"],
    35,
    {5, 1}
    ]


    enter image description here






    share|improve this answer




























      10














      Update



      In case your want to get your coloring on:



      getColoringLines = 
      ColorNegate@
      GradientFilter[ImportString[ExportString[#, "PNG"], "PNG"], 1] &;

      getColoringLines@spiroglyph[testImg, .36, 25, {6, 2}]


      enter image description here



      Original



      Here's my initial attempt:



      Clear[spiroglyph];
      Options[spiroglyph] = Options[Rasterize];
      spiroglyph[img_,
      clipping : _?(0 < # < 1 &) : .1,
      rots_Integer: 25,
      thickGap : {_Integer, _Integer} : {10, 5},
      mode : "Positive" | "Negative" : "Positive",
      ops : OptionsPattern] :=
      Module[
      {
      baseDims = ImageDimensions[img],
      diskRadius,
      bw = ColorConvert[img, "Grayscale"],
      baseMask,
      mask,
      clipMask,
      mid,
      sampleImage,
      gapMask,
      minMask,
      pr
      },
      diskRadius = Min[baseDims];
      mid = baseDims/2;
      pr =
      {
      {-diskRadius, diskRadius},
      {-diskRadius, diskRadius}
      };
      baseMask =
      Binarize@
      Rasterize[
      ParametricPlot[
      (diskRadius/rots) (θ/(2 π)) {Cos[θ],
      Sin[θ]}, {θ, 0, 2 π*rots},
      Axes -> False,
      PlotStyle ->
      Directive[AbsoluteThickness[thickGap[[1]]], Black],
      ImageSize -> baseDims,
      PlotRangePadding -> Scaled[.01],
      PlotRange -> pr
      ],
      ops
      ];
      mask = ImageResize[baseMask, baseDims];
      gapMask =
      Binarize@
      Rasterize[
      ParametricPlot[
      ((diskRadius/
      rots) ((θ + π)/(2 π))) {Cos[θ],
      Sin[θ]}, {θ, 0, 2 π*rots},
      Axes -> False,
      PlotStyle ->
      Directive[AbsoluteThickness[thickGap[[2]]], Black],
      ImageSize -> baseDims,
      PlotRangePadding -> Scaled[.01],
      PlotRange -> pr
      ],
      ops
      ];
      gapMask = ImageResize[gapMask, baseDims];
      If[mode === "Positive", {mask, gapMask} = {gapMask, mask}];
      sampleImage =
      Blend[
      If[mode === "Positive",
      {bw, ColorNegate@mask},
      {ColorNegate@bw, mask}
      ],
      .3
      ];
      minMask =
      Binarize@
      Rasterize[
      ParametricPlot[
      Evaluate@
      If[mode === "Positive",
      (diskRadius/rots) (θ/(2 π)) {Cos[θ],
      Sin[θ]},
      (diskRadius/
      rots) ((θ + π)/(2 π)) {Cos[θ],
      Sin[θ]}
      ], {θ, 0, 2 π*rots},
      Axes -> False,
      PlotStyle -> Directive[AbsoluteThickness[1], Black],
      ImageSize -> baseDims,
      PlotRangePadding -> Scaled[.01],
      PlotRange -> pr
      ],
      ops
      ];
      minMask = ImageResize[minMask, baseDims];
      (
      MeanFilter[
      Binarize[
      sampleImage,
      clipping
      ],
      3
      ] + gapMask
      )*minMask
      ]


      I basically use a bunch of tricks with ParametricPlot masks to try to get an image to imprint. It doesn't really pick up details well:



      testImg = ExampleData[{"TestImage", "Mandrill"}]


      enter image description here



      spiroglyph[testImg, .36, 25, {6, 2}]


      enter image description here



      It can also work for the negative of the image:



      spiroglyph[
      ExampleData[{"TestImage", "F16"}], .35, 40, {8, 5}, "Negative"]


      enter image description here



      And you can play with all the parameters to try to improve things:



      spiroglyph[
      ExampleData[{"TestImage", "F16"}], .32, 60, {10, 3}, "Negative",
      ImageResolution -> 200]


      enter image description here



      Oh and here's Elvis:



      elvis =
      ImageTake[#, ImageDimensions[#][[1]]] &@
      Import[
      "http://www.gstatic.com/tv/thumb/persons/1382/1382_v9_ba.jpg"];

      spiroglyph[elvis, .2, 85, {4, 2}]


      enter image description here



      And another example on a much simpler test case:



      spiroglyph[
      ImageCrop[#, {Min@ImageDimensions[#], Min@ImageDimensions[#]}] &@
      Import["https://i.etsystatic.com/13221305/r/il/e04597/1390417240/il_
      570xN.1390417240_lnh7.jpg"],
      35,
      {5, 1}
      ]


      enter image description here






      share|improve this answer


























        10












        10








        10






        Update



        In case your want to get your coloring on:



        getColoringLines = 
        ColorNegate@
        GradientFilter[ImportString[ExportString[#, "PNG"], "PNG"], 1] &;

        getColoringLines@spiroglyph[testImg, .36, 25, {6, 2}]


        enter image description here



        Original



        Here's my initial attempt:



        Clear[spiroglyph];
        Options[spiroglyph] = Options[Rasterize];
        spiroglyph[img_,
        clipping : _?(0 < # < 1 &) : .1,
        rots_Integer: 25,
        thickGap : {_Integer, _Integer} : {10, 5},
        mode : "Positive" | "Negative" : "Positive",
        ops : OptionsPattern] :=
        Module[
        {
        baseDims = ImageDimensions[img],
        diskRadius,
        bw = ColorConvert[img, "Grayscale"],
        baseMask,
        mask,
        clipMask,
        mid,
        sampleImage,
        gapMask,
        minMask,
        pr
        },
        diskRadius = Min[baseDims];
        mid = baseDims/2;
        pr =
        {
        {-diskRadius, diskRadius},
        {-diskRadius, diskRadius}
        };
        baseMask =
        Binarize@
        Rasterize[
        ParametricPlot[
        (diskRadius/rots) (θ/(2 π)) {Cos[θ],
        Sin[θ]}, {θ, 0, 2 π*rots},
        Axes -> False,
        PlotStyle ->
        Directive[AbsoluteThickness[thickGap[[1]]], Black],
        ImageSize -> baseDims,
        PlotRangePadding -> Scaled[.01],
        PlotRange -> pr
        ],
        ops
        ];
        mask = ImageResize[baseMask, baseDims];
        gapMask =
        Binarize@
        Rasterize[
        ParametricPlot[
        ((diskRadius/
        rots) ((θ + π)/(2 π))) {Cos[θ],
        Sin[θ]}, {θ, 0, 2 π*rots},
        Axes -> False,
        PlotStyle ->
        Directive[AbsoluteThickness[thickGap[[2]]], Black],
        ImageSize -> baseDims,
        PlotRangePadding -> Scaled[.01],
        PlotRange -> pr
        ],
        ops
        ];
        gapMask = ImageResize[gapMask, baseDims];
        If[mode === "Positive", {mask, gapMask} = {gapMask, mask}];
        sampleImage =
        Blend[
        If[mode === "Positive",
        {bw, ColorNegate@mask},
        {ColorNegate@bw, mask}
        ],
        .3
        ];
        minMask =
        Binarize@
        Rasterize[
        ParametricPlot[
        Evaluate@
        If[mode === "Positive",
        (diskRadius/rots) (θ/(2 π)) {Cos[θ],
        Sin[θ]},
        (diskRadius/
        rots) ((θ + π)/(2 π)) {Cos[θ],
        Sin[θ]}
        ], {θ, 0, 2 π*rots},
        Axes -> False,
        PlotStyle -> Directive[AbsoluteThickness[1], Black],
        ImageSize -> baseDims,
        PlotRangePadding -> Scaled[.01],
        PlotRange -> pr
        ],
        ops
        ];
        minMask = ImageResize[minMask, baseDims];
        (
        MeanFilter[
        Binarize[
        sampleImage,
        clipping
        ],
        3
        ] + gapMask
        )*minMask
        ]


        I basically use a bunch of tricks with ParametricPlot masks to try to get an image to imprint. It doesn't really pick up details well:



        testImg = ExampleData[{"TestImage", "Mandrill"}]


        enter image description here



        spiroglyph[testImg, .36, 25, {6, 2}]


        enter image description here



        It can also work for the negative of the image:



        spiroglyph[
        ExampleData[{"TestImage", "F16"}], .35, 40, {8, 5}, "Negative"]


        enter image description here



        And you can play with all the parameters to try to improve things:



        spiroglyph[
        ExampleData[{"TestImage", "F16"}], .32, 60, {10, 3}, "Negative",
        ImageResolution -> 200]


        enter image description here



        Oh and here's Elvis:



        elvis =
        ImageTake[#, ImageDimensions[#][[1]]] &@
        Import[
        "http://www.gstatic.com/tv/thumb/persons/1382/1382_v9_ba.jpg"];

        spiroglyph[elvis, .2, 85, {4, 2}]


        enter image description here



        And another example on a much simpler test case:



        spiroglyph[
        ImageCrop[#, {Min@ImageDimensions[#], Min@ImageDimensions[#]}] &@
        Import["https://i.etsystatic.com/13221305/r/il/e04597/1390417240/il_
        570xN.1390417240_lnh7.jpg"],
        35,
        {5, 1}
        ]


        enter image description here






        share|improve this answer














        Update



        In case your want to get your coloring on:



        getColoringLines = 
        ColorNegate@
        GradientFilter[ImportString[ExportString[#, "PNG"], "PNG"], 1] &;

        getColoringLines@spiroglyph[testImg, .36, 25, {6, 2}]


        enter image description here



        Original



        Here's my initial attempt:



        Clear[spiroglyph];
        Options[spiroglyph] = Options[Rasterize];
        spiroglyph[img_,
        clipping : _?(0 < # < 1 &) : .1,
        rots_Integer: 25,
        thickGap : {_Integer, _Integer} : {10, 5},
        mode : "Positive" | "Negative" : "Positive",
        ops : OptionsPattern] :=
        Module[
        {
        baseDims = ImageDimensions[img],
        diskRadius,
        bw = ColorConvert[img, "Grayscale"],
        baseMask,
        mask,
        clipMask,
        mid,
        sampleImage,
        gapMask,
        minMask,
        pr
        },
        diskRadius = Min[baseDims];
        mid = baseDims/2;
        pr =
        {
        {-diskRadius, diskRadius},
        {-diskRadius, diskRadius}
        };
        baseMask =
        Binarize@
        Rasterize[
        ParametricPlot[
        (diskRadius/rots) (θ/(2 π)) {Cos[θ],
        Sin[θ]}, {θ, 0, 2 π*rots},
        Axes -> False,
        PlotStyle ->
        Directive[AbsoluteThickness[thickGap[[1]]], Black],
        ImageSize -> baseDims,
        PlotRangePadding -> Scaled[.01],
        PlotRange -> pr
        ],
        ops
        ];
        mask = ImageResize[baseMask, baseDims];
        gapMask =
        Binarize@
        Rasterize[
        ParametricPlot[
        ((diskRadius/
        rots) ((θ + π)/(2 π))) {Cos[θ],
        Sin[θ]}, {θ, 0, 2 π*rots},
        Axes -> False,
        PlotStyle ->
        Directive[AbsoluteThickness[thickGap[[2]]], Black],
        ImageSize -> baseDims,
        PlotRangePadding -> Scaled[.01],
        PlotRange -> pr
        ],
        ops
        ];
        gapMask = ImageResize[gapMask, baseDims];
        If[mode === "Positive", {mask, gapMask} = {gapMask, mask}];
        sampleImage =
        Blend[
        If[mode === "Positive",
        {bw, ColorNegate@mask},
        {ColorNegate@bw, mask}
        ],
        .3
        ];
        minMask =
        Binarize@
        Rasterize[
        ParametricPlot[
        Evaluate@
        If[mode === "Positive",
        (diskRadius/rots) (θ/(2 π)) {Cos[θ],
        Sin[θ]},
        (diskRadius/
        rots) ((θ + π)/(2 π)) {Cos[θ],
        Sin[θ]}
        ], {θ, 0, 2 π*rots},
        Axes -> False,
        PlotStyle -> Directive[AbsoluteThickness[1], Black],
        ImageSize -> baseDims,
        PlotRangePadding -> Scaled[.01],
        PlotRange -> pr
        ],
        ops
        ];
        minMask = ImageResize[minMask, baseDims];
        (
        MeanFilter[
        Binarize[
        sampleImage,
        clipping
        ],
        3
        ] + gapMask
        )*minMask
        ]


        I basically use a bunch of tricks with ParametricPlot masks to try to get an image to imprint. It doesn't really pick up details well:



        testImg = ExampleData[{"TestImage", "Mandrill"}]


        enter image description here



        spiroglyph[testImg, .36, 25, {6, 2}]


        enter image description here



        It can also work for the negative of the image:



        spiroglyph[
        ExampleData[{"TestImage", "F16"}], .35, 40, {8, 5}, "Negative"]


        enter image description here



        And you can play with all the parameters to try to improve things:



        spiroglyph[
        ExampleData[{"TestImage", "F16"}], .32, 60, {10, 3}, "Negative",
        ImageResolution -> 200]


        enter image description here



        Oh and here's Elvis:



        elvis =
        ImageTake[#, ImageDimensions[#][[1]]] &@
        Import[
        "http://www.gstatic.com/tv/thumb/persons/1382/1382_v9_ba.jpg"];

        spiroglyph[elvis, .2, 85, {4, 2}]


        enter image description here



        And another example on a much simpler test case:



        spiroglyph[
        ImageCrop[#, {Min@ImageDimensions[#], Min@ImageDimensions[#]}] &@
        Import["https://i.etsystatic.com/13221305/r/il/e04597/1390417240/il_
        570xN.1390417240_lnh7.jpg"],
        35,
        {5, 1}
        ]


        enter image description here







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Dec 19 '18 at 9:58

























        answered Dec 19 '18 at 7:34









        b3m2a1

        26.7k257154




        26.7k257154






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Mathematica Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            Use MathJax to format equations. MathJax reference.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f188139%2fhow-to-make-a-spiroglyphic%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Morgemoulin

            Scott Moir

            Souastre