Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I attempted to produce a kind of miniature faking look from a street scene photo. I tried to shift the perspective lines close to parallel to each other to obtain such effect. However, the result looks ugly. Is there a better way to do it?

This is the original photo.

This is the original photo.

This is the result from the code below.

enter image description here

im = Import["http://i.stack.imgur.com/AkqJW.jpg"]

pts = {{0, 0}, {0, 1}, {0.25, 0},  {0.25, 1}, {0.5, 0}, {0.5,1}, {1, 0}, {1, 1} };
imgcol = BSplineFunction[ImageData[im ], SplineDegree -> 1];
Manipulate[
  Module[{f},
   f = BSplineFunction[Partition[pts, 2], SplineDegree -> 1, 
    Method -> {"Extrapolation" -> "Clamp"}]; 

  ParametricPlot[
   f[u, v], {u, 0, 1}, {v, 0, 1},
   ColorFunction -> (imgcol[1 - #4, #3] &),
   MaxRecursion -> 0,
   PlotPoints -> ControlActive[20, 100],
   Mesh -> None, 
   Epilog -> { Gray, Opacity[.7], Line[Partition[pts, 2]]}, 
   ImageSize -> {300, 300},
   PlotRange -> {{0, 1}, {0, 1}},
   PlotRangePadding -> Scaled[0.01],
   FrameTicks -> None
   ] 
  ],
 {{pts, {{0, 0}, {0, 1}, {0.25, 0},  {0.25, 1}, {0.5, 0},  {0.5, 1}, 
   {1, 0}, {1, 1} }}, {0, 0}, {1, 1}, Locator },
 TrackedSymbols :> {pts}
 ]
share|improve this question

2 Answers 2

“Tilt-shift” effect depends on the mask. Here is a full blown app with downloadable source code:

Digital Tilt-Shift Photography

enter image description here

share|improve this answer

I was always under the impression that a tilt-shift effect was achieved by blurring the top and bottom of a picture. This is supposed to imitate a shallow depth of field.

mask = Image @ Table[With[{c = 150 - 50 x/300}, Abs[y - c]/c], {y, 300}, {x, 300}];
ImageFilter[Mean@Flatten@# &, image, 5, Masking -> mask]

tilt

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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