0
$\begingroup$

Im exploring possibility to apply a CA to a portion of a region in an image.

Think that I can process an image to identify a region, as an example, a green area. I would like to confine that area, and apply a cellular automaton to it.

I am trying to help myself with demonstration (E.g. https://demonstrations.wolfram.com/2DCellularAutomatonOnATriangulatedSurface/ )

but instead of a complex manipulation, I would like to understand how could you "confine" the boundary of a region to map the automaton - and stay only in it.

In CellularAutomaton[] Options BoxMatrix[] is mentioned, but there is not an example of how to use BoxMatrix with CellularAutomaton: not clear where to start.

Should "pixelate" a region with a box matrix first?

How would you apply a Rule to the green area in this Satellite image ?


Conceptually, I tried something like:

img =[(* img in attachment*)];

MorphologicalTransform[Binarize[img],184,2]

but I don't want to apply a rule to a 3x3 neighborhood (MorphologicalTransform) - I want to apply a rule to a subregion I can extract from the image.

I thought about:

(* img color distance from the green areas *) cd = ColorDistance[img, RGBColor[1/255 {79, 93, 56}]]

(* binarize the img *) RegionBinarize[img, Binarize[cd, 0.3], 0]

Now that I "isolated" the green areas, how could I apply a CA rule to it?

(Comments about better ways to handle color isolations are welcome, although focus is on applying CA to them).

thank you and have a nice.. Christmas Holidays!


enter image description here

$\endgroup$
2
$\begingroup$

I think this problem was already solved generally, - take a look at the project done in 2018 Wolfram Summer School:

Implementing Arbitrary Regions for Cellular Automata

They even have a specific application similar to yours, when you run a CA on a geo-image (forest fire propagation):

enter image description here

The general idea there is that any CA can be run in arbitrary region by specifying a special additional set of rules for that region. CellularAutomaton functions was not explicitly used but CAs were developed from scratch.

If you want to use CellularAutomaton, there is a general approach too.

  1. Run 1 step of CellularAutomaton on the whole plane
  2. Rewrite static regions back to their static values
  3. Repeat from (1)

In this way you can even introduce various complex boundary conditions at the region border, for example, the values at the region border can oscillate or follow some timed dependent function, instead of just being static. This is just a concept, and not very efficient when non-CA regions are too large.

Simple example of the last idea is a Game of Life CA running on torus that is split into 2 independent regions by a ring. Define a ring:

ring = DiskMatrix[100] - ArrayPad[DiskMatrix[90], 10];
ring // Dimensions

{201, 201}

Define single iterator that applies GoL CA and then rewrites / keeps the ring values at 1:

iter[ic_]:=ring+(1-ring)CellularAutomaton["GameOfLife"][ic]

Build evolution:

evo=NestList[iter,RandomInteger[1,{201,201}],100];

Visualize:

Export["caring.gif",Image[1-#]&/@evo]
Manipulate[Image[1-evo[[k]]],{k,1,100,1}]

enter image description here

So evolutions inside and outside the ring are completely independent.

Before you dig through that Wolfram Summer School project, I recommend that you gain some clarity on how CAs work. It is obvious that you have some confusion, at least in the way you write things in your question, quoting:

but I don't want to apply a rule to a 3x3 neighborhood (MorphologicalTransform) - I want to apply a rule to a subregion I can extract from the image.

This is quite confusing, because CAs are always applied to a specific neighborhood - von Neumann or Moore, for example, - which is completely independent from the fact that you want to run a CA in some image subregion. That subregion will still consist of a lot of such local neighborhoods to which the CA is applied. BoxMatrix[...] in CellularAutomaton refers exactly to the local neighborhood setup (Moore) and is independent from the setup of your "green area", - these two things should be set up separately in your code.

To gain better understanding of CAs I recommend A New Kind of Science.

$\endgroup$
  • $\begingroup$ thank you so much for dedicating time for your answer, A new kind of science is on my willing read and thank you to suggest it. I actually wanted to explore artistic (aesthetic) implementations for obtaining patterns, and use a satellite image as an example - could be any image, and missed clarity in how to define subregions in an image (could be bounding box or other techniques) and apply CA to it. I will mark as answer for you gave a link to a similar case. $\endgroup$ – user305883 Dec 28 '18 at 11:28

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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