TransWikia.com

How to make a smooth highly contrasted image from a Blur, without affecting the sides?

Mathematica Asked on February 24, 2021

I’m generating a random texture using the code above, by blurring random tiles:

randomTiles = 
  Table[{RandomReal[], RandomReal[], RandomInteger[{1, 2}]}, {n, 1, 
    1500}];

Sharpen[Blur[ListDensityPlot[
   randomTiles,
   ColorFunction -> "IslandColors",
   InterpolationOrder -> 0,
   Frame -> False,
   ImageSize -> {500, 500}
   ], 10], 2]

Preview of what this code is doing:

enter image description here

Currently, the Blur is also changing the sides of the picture, and the Sharpen isn’t doing what I need. So here’s what I would like to achieve:

  1. Transforming the image without any blur or other effects to the sides, which need to stay sharp. Cropping the picture should be avoided, if possible.

  2. Transforming the blurred texture to a very sharpened and contrasting texture, with smooth edges everywhere, so I get two color regions only without any gradient.

How can I do this?

One Answer

PlotRangePadding to deal with edges, Binarize to unblur, and then Colorize to get your colors back

Colorize[Binarize[
  Blur[ListDensityPlot[randomTiles, ColorFunction -> "IslandColors", 
    InterpolationOrder -> 0, Frame -> False, PlotRangePadding -> 0, 
    ImageSize -> {500, 500}], 10], .6 ], 
    ColorRules -> {0 -> Orange, 1 -> Green}]

Output Sample

Correct answer by Rudy Potter on February 24, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP