Local averaging with custom neighbourhood

Local averaging with custom neighbourhood preview image

1 collaborator

Tags

local averaging with noise 

Tagged by Oleksii Ignatenko about 1 year ago

Visible to everyone | Changeable by the author
Model was written in NetLogo 6.3.0 • Viewed 63 times • Downloaded 4 times • Run 0 times
Download the 'Local averaging with custom neighbourhood' modelDownload this modelEmbed this model

Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)


Comments and Questions

Please start the discussion about this model! (You'll first need to log in.)

Click to Run Model

patches-own [ c ]

to setup
  clear-all
  ask patches [
    set c 0
    set pcolor white
  ]
    reset-ticks
end 

to go
  my-diffuse
  colour-patches
  tick
end 

to my-diffuse
  ask patches [
    let level 0
    let n 0
    if x-1y-1 = 1 [
      set n n + 1
      set level level + [c] of patch-at -1 -1]

    if x-1y = 1 [
      set n n + 1
      set level level + [c] of patch-at -1 0]

    if x-1y+1 = 1 [
      set n n + 1
      set level level + [c] of patch-at -1 1]

    if xy-1 = 1 [
      set n n + 1
      set level level + [c] of patch-at 0 -1]

    if xy+1 = 1 [
      set n n + 1
      set level level + [c] of patch-at 0 1]

    if x+1y-1 = 1 [
      set n n + 1
      set level level + [c] of patch-at 1 -1]

    if x+1y = 1 [
      set n n + 1
      set level level + [c] of patch-at 1 0]

    if x+1y+1 = 1 [
      set n n + 1
      set level level + [c] of patch-at 1 1]

    if x-2y-2 = 1 [
      set n n + 1
      set level level + [c] of patch-at -2 -2]

    if x+2y+2 = 1 [
      set n n + 1
      set level level + [c] of patch-at 2 2]


    set c (1 - weight-w) * c + weight-w * level / n + noise-level * one-of [-1 1]
  ]
end 

to colour-patches
  ask patches with [pcolor != black][
    ifelse c > threshold [set pcolor black][ set pcolor scale-color red c threshold 0]]
end 

There is only one version of this model, created about 1 year ago by Oleksii Ignatenko.

Attached files

File Type Description Last updated
Local averaging with custom neighbourhood.png preview Preview for 'Local averaging with custom neighbourhood' about 1 year ago, by Oleksii Ignatenko Download

This model does not have any ancestors.

This model does not have any descendants.