Skip to main content
added 655 characters in body
Source Link
Alexey Popkov
  • 62.3k
  • 7
  • 154
  • 375

Update

Here is a non-hackish way to reproduce the Heike's style of torn edges using ImageEffect of version 10.2 with even higher irregularity (irregular steps):

i = ExampleData[{"TestImage", "Mandrill"}];

t = Module[{step = 10, if, n = 2 Total[ImageDimensions[i]], k = 0}, 
 if = Interpolation[
   Transpose[{Accumulate[Prepend[RandomInteger[{step, 2 step}, n], 0]], 
     RandomReal[1, n + 1]}], InterpolationOrder -> 1]; 
 ImageEffect[i, {"Frame", if[++k] &, 15, {Right, Bottom}}]]

image


Original answer

An extension of the answer by Vitaliy. We can reproduce the Heike's style of torn edges with ImageEffect of version 10.2 by Blocking the Accumulate function:

i = ExampleData[{"TestImage", "Mandrill"}];

t = Block[{Accumulate = RandomReal[1, Length[#]] &}, 
  ImageEffect[i, {"TornFrame", Scaled[1/15], {Right, Bottom}, .08}]]

image

(the hack is found by tracing the evaluation of ImageEffect).

Here is how to add a semi-transparent shadow:

offset = 10;
blur = 5;
shadowTone = .5;
ImageCompose[SetAlphaChannel[ColorNegate@#, #] &@Blur[
   ImageMultiply[ImagePad[AlphaChannel[t], {{offset, blur/2}, {blur/2, offset}}],
    shadowTone], blur],
 ImagePad[t, {{0, offset + blur/2}, {offset + blur/2, 0}}]]

image

Sometimes it is desirable to highlight the boundary:

boundaryLigntness = .4;
ImageCompose[
 SetAlphaChannel[ColorNegate@#, #] &@Blur[
   ImageMultiply[ImagePad[AlphaChannel[t], {{offset, blur/2}, {blur/2, offset}}], 
    shadowTone], blur],
 ImagePad[ImageMultiply[t, 
   ColorNegate@ImageMultiply[MorphologicalPerimeter@AlphaChannel[t], boundaryLigntness]],
  {{0, offset + blur/2}, {offset + blur/2, 0}}]]

enter image description here

An extension of the answer by Vitaliy. We can reproduce the Heike's style of torn edges with ImageEffect of version 10.2 by Blocking the Accumulate function:

i = ExampleData[{"TestImage", "Mandrill"}];

t = Block[{Accumulate = RandomReal[1, Length[#]] &}, 
  ImageEffect[i, {"TornFrame", Scaled[1/15], {Right, Bottom}, .08}]]

image

(the hack is found by tracing the evaluation of ImageEffect).

Here is how to add a semi-transparent shadow:

offset = 10;
blur = 5;
shadowTone = .5;
ImageCompose[SetAlphaChannel[ColorNegate@#, #] &@Blur[
   ImageMultiply[ImagePad[AlphaChannel[t], {{offset, blur/2}, {blur/2, offset}}],
    shadowTone], blur],
 ImagePad[t, {{0, offset + blur/2}, {offset + blur/2, 0}}]]

image

Sometimes it is desirable to highlight the boundary:

boundaryLigntness = .4;
ImageCompose[
 SetAlphaChannel[ColorNegate@#, #] &@Blur[
   ImageMultiply[ImagePad[AlphaChannel[t], {{offset, blur/2}, {blur/2, offset}}], 
    shadowTone], blur],
 ImagePad[ImageMultiply[t, 
   ColorNegate@ImageMultiply[MorphologicalPerimeter@AlphaChannel[t], boundaryLigntness]],
  {{0, offset + blur/2}, {offset + blur/2, 0}}]]

enter image description here

Update

Here is a non-hackish way to reproduce the Heike's style of torn edges using ImageEffect of version 10.2 with even higher irregularity (irregular steps):

i = ExampleData[{"TestImage", "Mandrill"}];

t = Module[{step = 10, if, n = 2 Total[ImageDimensions[i]], k = 0}, 
 if = Interpolation[
   Transpose[{Accumulate[Prepend[RandomInteger[{step, 2 step}, n], 0]], 
     RandomReal[1, n + 1]}], InterpolationOrder -> 1]; 
 ImageEffect[i, {"Frame", if[++k] &, 15, {Right, Bottom}}]]

image


Original answer

An extension of the answer by Vitaliy. We can reproduce the Heike's style of torn edges with ImageEffect of version 10.2 by Blocking the Accumulate function:

i = ExampleData[{"TestImage", "Mandrill"}];

t = Block[{Accumulate = RandomReal[1, Length[#]] &}, 
  ImageEffect[i, {"TornFrame", Scaled[1/15], {Right, Bottom}, .08}]]

image

(the hack is found by tracing the evaluation of ImageEffect).

Here is how to add a semi-transparent shadow:

offset = 10;
blur = 5;
shadowTone = .5;
ImageCompose[SetAlphaChannel[ColorNegate@#, #] &@Blur[
   ImageMultiply[ImagePad[AlphaChannel[t], {{offset, blur/2}, {blur/2, offset}}],
    shadowTone], blur],
 ImagePad[t, {{0, offset + blur/2}, {offset + blur/2, 0}}]]

image

Sometimes it is desirable to highlight the boundary:

boundaryLigntness = .4;
ImageCompose[
 SetAlphaChannel[ColorNegate@#, #] &@Blur[
   ImageMultiply[ImagePad[AlphaChannel[t], {{offset, blur/2}, {blur/2, offset}}], 
    shadowTone], blur],
 ImagePad[ImageMultiply[t, 
   ColorNegate@ImageMultiply[MorphologicalPerimeter@AlphaChannel[t], boundaryLigntness]],
  {{0, offset + blur/2}, {offset + blur/2, 0}}]]

enter image description here

added 158 characters in body
Source Link
Alexey Popkov
  • 62.3k
  • 7
  • 154
  • 375

An extension of the answer by Vitaliy. We can reproduce the Heike's style of torn edges with ImageEffect of version 10.2 by Blocking the Accumulate function:

i = ExampleData[{"TestImage", "Mandrill"}];

t = Block[{Accumulate = RandomReal[1, Length[#]] &}, 
  ImageEffect[i, {"TornFrame", Scaled[1/15], {Right, Bottom}, .08}]]

image

(the hack is found by tracing the evaluation of ImageEffect).

Here is how to add a semi-transparent shadow:

offset = 10;
blur = 5;
shadowTone = .5;
ImageCompose[SetAlphaChannel[ColorNegate@#, #] &@Blur[
   ImageMultiply[ImagePad[AlphaChannel[t], {{offset, blur/2}, {blur/2, offset}}],
    shadowTone], blur],
 ImagePad[t, {{0, offset + blur/2}, {offset + blur/2, 0}}]]

image

Sometimes it is desirable to highlight the boundary:

boundaryLigntness = .4;
ImageMultiply[t2ImageCompose[
 SetAlphaChannel[ColorNegate@#, 
 #] ColorNegate@&@Blur[
  ImageMultiply[ ImageMultiply[ImagePad[AlphaChannel[t], {{offset, blur/2}, {blur/2, offset}}], 
   MorphologicalPerimeter@ shadowTone], blur],
 ImagePad[ImageMultiply[t,  
  ImagePad[AlphaChannel[t] ColorNegate@ImageMultiply[MorphologicalPerimeter@AlphaChannel[t], boundaryLigntness]],
  {{0, offset + blur/2}, {offset + blur/2, 0}}], 
   boundaryLigntness]]]]

enter image description here

An extension of the answer by Vitaliy. We can reproduce the Heike's style of torn edges with ImageEffect of version 10.2 by Blocking the Accumulate function:

i = ExampleData[{"TestImage", "Mandrill"}];

t = Block[{Accumulate = RandomReal[1, Length[#]] &}, 
  ImageEffect[i, {"TornFrame", Scaled[1/15], {Right, Bottom}, .08}]]

image

(the hack is found by tracing the evaluation of ImageEffect).

Here is how to add a semi-transparent shadow:

offset = 10;
blur = 5;
shadowTone = .5;
ImageCompose[SetAlphaChannel[ColorNegate@#, #] &@Blur[
   ImageMultiply[ImagePad[AlphaChannel[t], {{offset, blur/2}, {blur/2, offset}}],
    shadowTone], blur],
 ImagePad[t, {{0, offset + blur/2}, {offset + blur/2, 0}}]]

image

Sometimes it is desirable to highlight the boundary:

boundaryLigntness = .4;
ImageMultiply[t2, 
  ColorNegate@
  ImageMultiply[
   MorphologicalPerimeter@
    ImagePad[AlphaChannel[t], {{0, offset + blur/2}, {offset + blur/2, 0}}], 
   boundaryLigntness]]

enter image description here

An extension of the answer by Vitaliy. We can reproduce the Heike's style of torn edges with ImageEffect of version 10.2 by Blocking the Accumulate function:

i = ExampleData[{"TestImage", "Mandrill"}];

t = Block[{Accumulate = RandomReal[1, Length[#]] &}, 
  ImageEffect[i, {"TornFrame", Scaled[1/15], {Right, Bottom}, .08}]]

image

(the hack is found by tracing the evaluation of ImageEffect).

Here is how to add a semi-transparent shadow:

offset = 10;
blur = 5;
shadowTone = .5;
ImageCompose[SetAlphaChannel[ColorNegate@#, #] &@Blur[
   ImageMultiply[ImagePad[AlphaChannel[t], {{offset, blur/2}, {blur/2, offset}}],
    shadowTone], blur],
 ImagePad[t, {{0, offset + blur/2}, {offset + blur/2, 0}}]]

image

Sometimes it is desirable to highlight the boundary:

boundaryLigntness = .4;
ImageCompose[
 SetAlphaChannel[ColorNegate@#, #] &@Blur[
   ImageMultiply[ImagePad[AlphaChannel[t], {{offset, blur/2}, {blur/2, offset}}], 
    shadowTone], blur],
 ImagePad[ImageMultiply[t,  
   ColorNegate@ImageMultiply[MorphologicalPerimeter@AlphaChannel[t], boundaryLigntness]],
  {{0, offset + blur/2}, {offset + blur/2, 0}}]]

enter image description here

better implementation
Source Link
Alexey Popkov
  • 62.3k
  • 7
  • 154
  • 375

Just an addition toAn extension of the answer by Vitaliy. We can reproduce the Heike's style of torn edges with ImageEffect of version 10.2 by Blocking the Accumulate function:

i = ExampleData[{"TestImage", "Mandrill"}];

t = Block[{Accumulate = RandomReal[1, Length[#]] &}, 
  ImageEffect[i, {"TornFrame", Scaled[1/15], {Right, Bottom}, .08}]]

imageimage

(foundthe hack is found by tracing the evaluation of ImageEffect).

ItHere is not difficulthow to add thea semi-transparent shadow too:

ImageCompose[Blur[ColorNegate@Binarize[ImagePad[toffset = 10;
blur = 5;
shadowTone = .5;
ImageCompose[SetAlphaChannel[ColorNegate@#, #] &@Blur[
   ImageMultiply[ImagePad[AlphaChannel[t], {{10offset, 0blur/2}, {0blur/2, 10offset}}], 
 0], 5]  shadowTone], blur],
 ImagePad[t, {{0, 10offset + blur/2}, {10offset + blur/2, 0}}]]

imageimage

A modification with semi-transparencySometimes it is desirable to highlight the boundary:

ImageCompose[
boundaryLigntness SetAlphaChannel[#,= ColorNegate@#].4;
ImageMultiply[t2, &@
 ColorNegate@
 Blur[ColorNegate@Binarize[ImagePad[t, {{10,ImageMultiply[
 0}, {0, 10}}],MorphologicalPerimeter@
 0], 5], 
  ImagePad[tImagePad[AlphaChannel[t], {{0, 10offset + blur/2}, {10offset + blur/2, 0}}]]], 
   boundaryLigntness]]

imageenter image description here

Just an addition to the answer by Vitaliy. We can reproduce the Heike's style of torn edges with ImageEffect of version 10.2 by Blocking the Accumulate function:

t = Block[{Accumulate = RandomReal[1, Length[#]] &}, 
  ImageEffect[i, {"TornFrame", Scaled[1/15], {Right, Bottom}, .08}]]

image

(found by tracing the evaluation of ImageEffect).

It is not difficult to add the shadow too:

ImageCompose[Blur[ColorNegate@Binarize[ImagePad[t, {{10, 0}, {0, 10}}], 0], 5], 
 ImagePad[t, {{0, 10}, {10, 0}}]]

image

A modification with semi-transparency:

ImageCompose[
 SetAlphaChannel[#, ColorNegate@#] &@
  Blur[ColorNegate@Binarize[ImagePad[t, {{10, 0}, {0, 10}}], 0], 5], 
  ImagePad[t, {{0, 10}, {10, 0}}]]

image

An extension of the answer by Vitaliy. We can reproduce the Heike's style of torn edges with ImageEffect of version 10.2 by Blocking the Accumulate function:

i = ExampleData[{"TestImage", "Mandrill"}];

t = Block[{Accumulate = RandomReal[1, Length[#]] &}, 
  ImageEffect[i, {"TornFrame", Scaled[1/15], {Right, Bottom}, .08}]]

image

(the hack is found by tracing the evaluation of ImageEffect).

Here is how to add a semi-transparent shadow:

offset = 10;
blur = 5;
shadowTone = .5;
ImageCompose[SetAlphaChannel[ColorNegate@#, #] &@Blur[
   ImageMultiply[ImagePad[AlphaChannel[t], {{offset, blur/2}, {blur/2, offset}}], 
    shadowTone], blur],
 ImagePad[t, {{0, offset + blur/2}, {offset + blur/2, 0}}]]

image

Sometimes it is desirable to highlight the boundary:

boundaryLigntness = .4;
ImageMultiply[t2, 
 ColorNegate@
  ImageMultiply[
   MorphologicalPerimeter@
    ImagePad[AlphaChannel[t], {{0, offset + blur/2}, {offset + blur/2, 0}}], 
   boundaryLigntness]]

enter image description here

added 282 characters in body
Source Link
Alexey Popkov
  • 62.3k
  • 7
  • 154
  • 375
Loading
Source Link
Alexey Popkov
  • 62.3k
  • 7
  • 154
  • 375
Loading