Skip to content

Instantly share code, notes, and snippets.

@mgdevereux
Forked from OrganicIrradiation/contrast_s.m
Created March 29, 2022 23:46
Show Gist options
  • Save mgdevereux/1c9743c97ec8a07e1b4d1c42e8b05e02 to your computer and use it in GitHub Desktop.
Save mgdevereux/1c9743c97ec8a07e1b4d1c42e8b05e02 to your computer and use it in GitHub Desktop.

Revisions

  1. @OrganicIrradiation OrganicIrradiation created this gist Mar 23, 2015.
    1 change: 1 addition & 0 deletions contrast_s.m
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    s = (cos(s * pi - pi) + 1) / 2;
    12 changes: 12 additions & 0 deletions noise3D.m
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    function s = noise3D (m,k)
    s = zeros([m,m,m]);
    w = m;
    i = 0;
    while w > 3
    i = i + 1;
    d = smooth3(randn([m,m,m]), 'gaussian',k,i);
    s = s + i * d(1:m, 1:m, 1:m);
    w = w - ceil(w/2 - 1);
    end
    s = (s - min(min(s(:,:)))) ./ (max(max(s(:,:))) - min(min(s(:,:))));
    end
    1 change: 1 addition & 0 deletions norm_s.m
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    s = (s - min(min(s(:,:)))) ./ (max(max(s(:,:))) - min(min(s(:,:))));
    11 changes: 11 additions & 0 deletions perlin.m
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    function s = perlin (m)
    s = zeros(m); # output image
    w = m; # width of current layer
    i = 0; # iterations
    while w > 3
    i = i + 1;
    d = interp2(randn(w), i-1, "spline");
    s = s + i * d(1:m, 1:m);
    w -= ceil(w/2 - 1);
    end
    end
    12 changes: 12 additions & 0 deletions perlin2D.m
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    function s = perlin2D (m)
    s = zeros([m,m]); % Prepare output image (size: m x m)
    w = m;
    i = 0;
    while w > 3
    i = i + 1;
    d = interp2(randn([m,m]), i-1, 'spline');
    s = s + i * d(1:m, 1:m);
    w = w - ceil(w/2 - 1);
    end
    s = (s - min(min(s(:,:)))) ./ (max(max(s(:,:))) - min(min(s(:,:))));
    end
    12 changes: 12 additions & 0 deletions perlin3D.m
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    function s = perlin3D (m)
    s = zeros([m,m,m]); % Prepare output image (size: m x m x m)
    w = m;
    i = 0;
    while w > 3
    i = i + 1;
    d = interp3(randn([m,m,m]), i-1, 'spline');
    s = s + i * d(1:m, 1:m, 1:m);
    w = w - ceil(w/2 - 1);
    end
    s = (s - min(min(s(:,:)))) ./ (max(max(s(:,:))) - min(min(s(:,:))));
    end