Skip to content

Instantly share code, notes, and snippets.

@wesen
Created October 19, 2017 16:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wesen/ce067c8c3820db25e95b3f2c11b65754 to your computer and use it in GitHub Desktop.
Save wesen/ce067c8c3820db25e95b3f2c11b65754 to your computer and use it in GitHub Desktop.
Clear[nestPimp2];
Options[nestPimp2] = Join[
{
PimpFunction -> Identity,
PostPimpFunction -> Identity,
PrePimpFunction -> Identity,
InnerPimpFunction -> Identity
},
Options[ImageRestyle]
];
nestPimp2[startImg_, restyleImgs_, level_, opts : OptionsPattern[]] :=
Module[{res},
res = Nest[
OptionValue[PimpFunction]@
ImageRestyle[OptionValue[InnerPimpFunction]@#, restyleImgs,
Evaluate[FilterRules[{opts}, Options[ImageRestyle]]]] &,
OptionValue[PrePimpFunction]@startImg, level];
OptionValue[PostPimpFunction]@res
];
Module[{
large = Import["http://bl0rg.net/~manuel/wolfram-imgs/large.png"],
fire = Import["http://bl0rg.net/~manuel/wolfram-imgs/fire.png"],
schiele = Import["http://bl0rg.net/~manuel/wolfram-imgs/schiele.png"],
},
{nestPimp2[small, {.3 -> fire, .3 -> schiele}, 5,
PostPimpFunction -> (ColorConvert[#, "Grayscale"] &),
PimpFunction -> (ImageAdjust[
Colorize[#, ColorFunction -> "GrayYellowTones"], 1] &)
],
nestPimp2[small, {.1 -> fire, .3 -> schiele}, 3,
PerformanceGoal -> "Speed",
PimpFunction -> (Sharpen[#, 5] &),
InnerPimpFunction ->
Function[x,
ImageAdjust[Colorize[x, ColorFunction -> "CherryTones"], .5]]]
}]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment