Suppose I have an image or a document, provided in a high-quality PDF file. You can open and view it in a PDF viewer, but then it has a kind of static look: it's not something tangible, it's just an image on a screen. For instance, I have the following image:

Monriaan's Broadway Boogie Woogie

To get a more realistic look and feel, to get something "tangible", I could print it (or paint it on a canvas) and take a picture of it from an angle, to give the object depth. For instance, I'd say the following photo gives the image above a more tangible, realistic feeling:

Photo of Broadway Boogie Woogie

For documents, there's not as much depth as paper is flat, but still a photo of a printed document makes it a bit more "realistic", and allows you to put emphasis on part of the document. For instance, the following photo (taken from a relatively small angle) shows only part of some page, and the lighting, focus/blur of the camera etc. make the document look like a real object:

Photo of a text document
(source: answcdn.com)

So the question is: given a (flat) image or text document like in the first image above, is it possible to transform it into a realistic (3D) "photo" of the image with Mathematica, like in the second and third images? If possible, it would be nice to be able to tune the lighting, focus, blur, etc. of the resulting output, and to make it look as realistic as possible.

  • 2
    $\begingroup$ Why must it use Mathematica? Why not use a proper image editor? Exploratory image editing generally will involve a lot of subjective judgments and trial and errors to see what works and what doesn't, it's not the kind of editing that is easily scriptable. $\endgroup$ – Lie Ryan Feb 2 '15 at 0:09
  • $\begingroup$ slightly related 38076 $\endgroup$ – Kuba Feb 2 '15 at 12:05
  • $\begingroup$ @LieRyan: Do you have suggestions for image editors that can do these things without too much effort? And sure, for the first time it may be a lot of trial and error to get it right, but the advantage of scripting would be that in the end you can batch-process hundreds of files with exactly the same effects very quickly (rather than repeating the same editing procedure in your image editor over and over for each file). $\endgroup$ – TMM Feb 3 '15 at 0:19
  • $\begingroup$ @TMM: GIMP is an option, and it can be scripted too, with either Scheme or Python. One advantage of an image editor is that you can go back and forth between manual and scripting, do the manual edit, then once you find out a way that work, find out how to replicate the effect in script. For example, here is my shoddy attempt at replicating the first image with a random sunset image I found on the internet: i.stack.imgur.com/iuFGi.jpg, took about half hour without writing a script. It can definitely be improved if you spend more time on it. $\endgroup$ – Lie Ryan Feb 3 '15 at 0:50

As written, I think that this question is a bit too broad, and has a "what can Mathematica do for me?" style that would be better answered by sales reps at Wolfram. That said, I'm going to steal some of Kuba's code and show how one might simulate a 3D effect from a 2D image.

img = Import[
graphics = 
 Graphics3D[{Texture@img, EdgeForm@Black, 
   Polygon[{{0, 0, 0}, {0, 1, 0}, {2, 1, 0}, {2, 0, 0}}, 
    VertexTextureCoordinates -> {{.98, .02}, {.02, .02}, {.02, .98}, \
{.98, .98}}]}, Boxed -> False, Background -> White, 
  ViewVertical -> {0, 0, 1}, ImageSize -> {500, 500}, 
  ViewVector -> ({{0, .5, 1}, {1, .5, 0}}), ViewAngle -> 1, 
  Lighting -> "Neutral", SphericalRegion -> True]

enter image description here

Briefly, the image is being converted into a texture that is then applied to a 3D Polygon. I am then using the mouse to move the 3D graphic.

| improve this answer | |

Mathematica doesn't has a render engine integrated to It, with advanced ray trace capability. So, you can do some toy render or prototype, but with the present technology you will never reach a realistic image render like you would get in a specialized tool like Rhino, Blender or Unit3D.

Video about Rhino Mathemtica integration

Video about Unit3D Mathemtica integration

Check this beautiful post in Wolfram Community. As you can see, Mathematica can be a nice tool to create abstracts and complex geometry (in this case, the geometric materialization of an "I love you" speak), but not to render it in in an advanced/realistic mode. enter image description here

So, I would say the answer to your question is no.

| improve this answer | |
  • 1
    $\begingroup$ What part exactly of the above would be impossible with Mathematica? I've seen answers showing how to e.g. import and rotate images, how to apply filters to images, and the Mathematica documentation also discusses lighting. (Getting all the syntax right and combining all these elements in a neat way is beyond me though.) $\endgroup$ – TMM Feb 1 '15 at 21:43
  • $\begingroup$ @TMM everything is possible but some things are not implemented and writing ray tracing module to show your picture on the wall next to the window may be problematic. Unless games from '90s are realistic, then it is ok. :) On the other hand MMA may be great to set up things for export to dedicated software. $\endgroup$ – Kuba Feb 2 '15 at 8:36

Here's a quick and dirty proof-of-concept:

myMask = ColorConvert[
      .6 - 1 Sin[1.3 (x/1000 - .6) (y/1000 - .3)], {x, 0, 975}, {y, 0,
      ColorFunction -> GrayLevel,
      ColorFunctionScaling -> False, Frame -> False]], {1000, 880}],
      Blur[ImageEffect[boR, "SaltPepperNoise"]],
      {#[[1]] + .002 Cos[
           13 #[[2]] + RandomReal[20]], #[[2]] + .005 Sin[
           10 #[[1]] + RandomReal[3]]} &],
     myMask], "SaltPepperNoise"]], {{0.9, 0.05, 0.}, {0.2, 
    0.9, -0.1}, {0., 0.05, .9}}]

Which will transform this into this:

enter image description here

Much better work can be done, of course, if you have the time.

| improve this answer | |

Another way to make a clean digital photo "realistic" is to give it texture. Here is a way to use Relief Plot as a way of texturizing the surface.

img = Import["http://classconnection.s3.amazonaws.com/341/flashcards/2390341/jpeg/piet_mondrian_3_broadway_boogie_woogie1355246761699.jpeg"];
{r, g, b} = ImageData /@ ColorSeparate[img];
Image[ColorCombine[{ReliefPlot[r], ReliefPlot[g], ReliefPlot[b]}]]

enter image description here

And here is the texturized image "hung on the wall" using bobthechemist's code.

enter image description here

| improve this answer | |
  • 2
    $\begingroup$ How is this "more realistic"? $\endgroup$ – Nit Feb 2 '15 at 9:07
  • 1
    $\begingroup$ Reality isn't HD... $\endgroup$ – Charlie Joey Hadley Feb 2 '15 at 10:52
  • 2
    $\begingroup$ @Nit - The OP wrote "I could print it (or paint it on a canvas)". This is (intended to be) a kind of simulation of such a texturizing process. $\endgroup$ – bill s Feb 2 '15 at 13:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.