Sign in to follow this  
fir

fractal result by accident

Recommended Posts

alvaro    21265


i dont know how to count a dimension do you know how to count this based on that picture?

 

Fractals are not pretty pictures: They are subsets of R^n with certain self-similarity properties. So you have to start by defining a subset of R^n in some way. A picture doesn't help much.

Share this post


Link to post
Share on other sites
fir    460

See:

 

https://www.google.no/search?q=moire+pattern&espv=210&es_sm=119&source=lnms&tbm=isch&sa=X&ei=4KTzUqDvDOrMygPYhoGIBw&sqi=2&ved=0CAcQ_AUoAQ&biw=1920&bih=898

 

On any of those pictures:

 

Since the TV that I use with my computer has a resolution that doesn't quite match up with the natural resolution of the graphic card, I get Moire patterns exactly like yours when I have zoomed completely out.  When I zoom in, the pattern disappear.  The pictures are static.  (CTRL + mouse scroll on Mac to zoom, or what you have configured.  Not sure how to activate on Windows any more.)

 

You will probably not see the same result, unless you pick a resolution that does not quite match up with the resolution on the screen, but the reason is the same: ALIASING.  Aliasing makes Moire patterns.

 

Aliasing happens when you show high frequency data on a low(er) frequency medium.

 

Have a look here: http://www.svi.nl/AliasingArtifacts

 

Even TV / video producers avoid having certain clothes to avoid aliasing effects.  You don't often see clothes with high contrast horizontal stripes, for instance: http://www.assetmediagroup.com/what-to-wear-for-video-shoot.html

 

so, explain me - you think that underlaying image is something 'less

fractal' and only presenting it on the pixelgrid makes it looking fractal-like?

I do not see the reason to belive that underlying image is something much simpler that the thing you see on the grid (for hihg frequenzy palette I think it is more complex than the thing you see)

so if this is not true i do not get why to force me to belive in this.;\

Share this post


Link to post
Share on other sites
fir    460

I am going to give it another try:

 

Unfortunately it is poor quality, but you get the point.

 

the last didnt work, the third was interesting

 

what point? the difference of opinions was on the topics if

1) this is a fractal

2) if this is a result of an interference (related to 'presentation artifact')

 

above with such moire there was two drawings interfering, in my example  algorithm i just calculate the pixel color with given not

complex function then set pixel and i just doubt (and tend to disagree)

if the resulting  'fractal pattern' comes from the discretization to grid values, imo it seems that underlying 'fluid' function has it implied

 

it may be related to some "inner" interferency of parts of its math formula

but probably is not related to screen presentation artifacts

 

but do not matter i doubt this is worth talking to much, i was interested 

more if this specyfic ball fractal-like moire - like object has a specyfic name

 

(as to moire i was not denying that it may be somewhat related but i said that moire seem to be a whole family not the specyfic one, and maybe there is some specyfic name,

as to being a fractal i am not seeing if this is a worse object to

being fractal that for example 

http://en.wikipedia.org/wiki/Sierpinski_carpet

which seem to be somewhat resemblin this ball i was talking about here)

Edited by fir

Share this post


Link to post
Share on other sites
unbird    8338
This is fun. I think I remember the formula for the last video from aregee. Had copy the link manually, but the resolution is really bad, therefore...

C# code (console app, copy paste, add reference for System.Drawing)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Drawing;
using System.Drawing.Imaging;
using System.Text;

namespace Moire
{
    class Program
    {
        static void Main(string[] args)
        {
            int width = 640;
            int height = 480;
            var scale = 50.0;
            scale /= height; // adjust for resolution
            var xh = width / 2;
            var yh = height / 2;
            var bitmap = new Bitmap(width, height);
            for (int y = 0; y < height; y++)
            {
                var yy = (y - yh) * scale;
                for (int x = 0; x < width; x++)
                {
                    var xx = (x - xh) * scale;
                    var value = xx * xx + yy * yy;  // f(x,y) = x^2 + y ^ 2
                    value = value % 1.0;            // mod, though Hue should actually wrap anyway
                    var color = Hue((float)value);
                    bitmap.SetPixel(x, y, color);
                }
            }
            bitmap.Save("image.png", ImageFormat.Png);
            bitmap.Dispose();
        }

        #region Color functions
        public static byte ToByte(float value)
        {
            return (byte)System.Math.Max(0, System.Math.Min(255, System.Math.Round(255f * value)));
        }

        public static Color FromFloat(float r, float g, float b)
        {
            return Color.FromArgb(ToByte(r), ToByte(g), ToByte(b));
        }

        public static Color Hue(float hue)
        {
            float oneSixth = 1f / 6f;
            float h = hue - (int)hue;
            int index = (int)(h / oneSixth);
            h = (h / oneSixth) - index;
            var q = 1f - h;
            switch (index)
            {
                case 0: return FromFloat(1, h, 0);
                case 1: return FromFloat(q, 1, 0);
                case 2: return FromFloat(0, 1, h);
                case 3: return FromFloat(0, q, 1);
                case 4: return FromFloat(h, 0, 1);
                default: return FromFloat(1, 0, q);
            }
        }
        #endregion

    }
}

Playing with the scale:
scale = 10
MoireScale10_zpsf2704063.png
scale = 20
MoireScale20_zpsc4e29252.png
scale = 50
MoireScale50_zps2d1c360c.png

Share this post


Link to post
Share on other sites


Fractals are not pretty pictures: They are subsets of R^n with certain self-similarity properties. So you have to start by defining a subset of R^n in some way. A picture doesn't help much.
It kind of does, to dismiss it as fractal. Even if the term "subsets of R^n" produces a "Huh, WTF?" reaction inside you, you can still very clearly see that the pattern is not self-similar.

 

If this was a fractal, there should be little concentric circles inside the pretty colorful concentric circles. No such thing as even a single odd pixel that doesn't fit into the pretty gradients can be seen in the original picture, nor when you zoom in.

Share this post


Link to post
Share on other sites
fir    460

 


Fractals are not pretty pictures: They are subsets of R^n with certain self-similarity properties. So you have to start by defining a subset of R^n in some way. A picture doesn't help much.
It kind of does, to dismiss it as fractal. Even if the term "subsets of R^n" produces a "Huh, WTF?" reaction inside you, you can still very clearly see that the pattern is not self-similar.

 

If this was a fractal, there should be little concentric circles inside the pretty colorful concentric circles. No such thing as even a single odd pixel that doesn't fit into the pretty gradients can be seen in the original picture, nor when you zoom in.

 

If sierpi?ski carpet is a fractal i see no reazon for this to be not fractal ;\

we should ask some mathematician good in fractals, for answer why  ifsierpi?ski is a fractal this  ball is not ;\

For me it looks like a interferency of circular vaves made by sierpi?ski like raindrop

Share this post


Link to post
Share on other sites
fir    460

As everyone suspected, it's just a Moiré pattern. Here's my attempt at producing it:

#include <cstdio>
#include <cmath>

int main() {
  std::puts("# ImageMagick pixel enumeration: 800,800,255,srgb");

  for (int j=0; j<800; ++j) {
    double y = (400.0 - j) / 360.0;
    for (int i=0; i<800; ++i) {
      double x = (i - 400.0) / 360.0;
      double z2 = 1.0 - x * x - y * y;
      double distance = (z2 >= 0.0) ? std::sqrt(z2) : 0.0;
      double color = std::fmod(1000.0*distance, 1.0);
      int r = 256 * color;
      int g = 256 * color;
      int b = 256 * (1.0 - color);
      r = r > 255 ? 255 : r < 0 ? 0 : r;
      g = g > 255 ? 255 : g < 0 ? 0 : g;
      b = b > 255 ? 255 : b < 0 ? 0 : b;
      std::printf("%d,%d: (%d,%d,%d)  #%02X%02X%02X  srgb(%d,%d,%d)\n",
                  i, j,
                  r, g, b,
                  r, g, b,
                  r, g, b);
    }
  }
}

I compiled that code and then executed it, passing the output through `| convert TXT:- output.png' (`convert' is a command-line utility, part of ImageMagick). The output is this:

output.png

 

 

[EDIT: If you replace 1000.0 with something like 250.0, you'll get an image much closer to the original in this thread.]

 

Very good work! I see the central part is probably

 

distance = sqrt(1-(x*x+y*y))

 

do you know maybe what klind of function it is id drawed z=f(x,y)

of just z=f(x,0); ?

 

Im rarely doing mathematics so i forgot the thing

 

As to moire pattern I suspect this could be treated set of infinite number of moire interferentions - but those interferentions are purely mathematical not 'presentation aliasing' artifacts

Edited by fir

Share this post


Link to post
Share on other sites
fir    460

This is fun. I think I remember the formula for the last video from aregee. Had copy the link manually, but the resolution is really bad, therefore...

C# code (console app, copy paste, add reference for System.Drawing)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Drawing;
using System.Drawing.Imaging;
using System.Text;

namespace Moire
{
    class Program
    {
        static void Main(string[] args)
        {
            int width = 640;
            int height = 480;
            var scale = 50.0;
            scale /= height; // adjust for resolution
            var xh = width / 2;
            var yh = height / 2;
            var bitmap = new Bitmap(width, height);
            for (int y = 0; y < height; y++)
            {
                var yy = (y - yh) * scale;
                for (int x = 0; x < width; x++)
                {
                    var xx = (x - xh) * scale;
                    var value = xx * xx + yy * yy;  // f(x,y) = x^2 + y ^ 2
                    value = value % 1.0;            // mod, though Hue should actually wrap anyway
                    var color = Hue((float)value);
                    bitmap.SetPixel(x, y, color);
                }
            }
            bitmap.Save("image.png", ImageFormat.Png);
            bitmap.Dispose();
        }

        #region Color functions
        public static byte ToByte(float value)
        {
            return (byte)System.Math.Max(0, System.Math.Min(255, System.Math.Round(255f * value)));
        }

        public static Color FromFloat(float r, float g, float b)
        {
            return Color.FromArgb(ToByte(r), ToByte(g), ToByte(b));
        }

        public static Color Hue(float hue)
        {
            float oneSixth = 1f / 6f;
            float h = hue - (int)hue;
            int index = (int)(h / oneSixth);
            h = (h / oneSixth) - index;
            var q = 1f - h;
            switch (index)
            {
                case 0: return FromFloat(1, h, 0);
                case 1: return FromFloat(q, 1, 0);
                case 2: return FromFloat(0, 1, h);
                case 3: return FromFloat(0, q, 1);
                case 4: return FromFloat(h, 0, 1);
                default: return FromFloat(1, 0, q);
            }
        }
        #endregion

    }
}

Playing with the scale:
scale = 10
MoireScale10_zpsf2704063.png
scale = 20
MoireScale20_zpsc4e29252.png
scale = 50
MoireScale50_zps2d1c360c.png

 

nice, good work

Share this post


Link to post
Share on other sites
If sierpi?ski carpet is a fractal i see no reazon for this to be not fractal ;\

That is like saying: If a circle is round, I see no reason why a square should not be.

 

A Sierpinski carpet (or triangle) has the "stereotypical look" of a fractal, which your image just doesn't have. Note that looking like a fractal doesn't make an image a fractal, but not looking like one at all rules it out pretty safely.

 

If you look at a Sierpinski triangle starting at level 1, it has the look of a filled triangle where an upside-down triangle has been cut out (it works if you start with the level-0 triangle too, but I find the similarity more striking if you start at one subdivision). That exact same pattern is visible in each of the three smaller filled triangles around that cut-out triangle, and in each of the three even smaller triangles inside these, and so on. You can repeat this ad infinitum, and it will always look the same.

 

If you look at your image, there are circles and rings, and yes they are somewhat similar, arranged in a somewhat repeating texture. But that's where it stops. If you zoom into one of the circles, it doesn't turn out being an orb with many smaller circles and rings. It's just a circle.

 

This, too, is a regular, repeating pattern, but it is not fractal:

 

XceBm.png
 

we should ask some mathematician good in fractals, for answer why  ifsierpi?ski is a fractal this  ball is not ;\

Well, one mathematician already gave an explanation a dozen or so posts above.

Edited by samoth

Share this post


Link to post
Share on other sites
fir    460

 

If sierpi?ski carpet is a fractal i see no reazon for this to be not fractal ;\

That is like saying: If a circle is round, I see no reason why a square should not be.

 

A Sierpinski carpet (or triangle) has the "stereotypical look" of a fractal, which your image just doesn't have. Note that looking like a fractal doesn't make an image a fractal, but not looking like one at all rules it out pretty safely.

 

If you look at a Sierpinski triangle starting at level 1, it has the look of a filled triangle where an upside-down triangle has been cut out (it works if you start with the level-0 triangle too, but I find the similarity more striking if you start at one subdivision). That exact same pattern is visible in each of the three smaller filled triangles around that cut-out triangle, and in each of the three even smaller triangles inside these, and so on. You can repeat this ad infinitum, and it will always look the same.

 

If you look at your image, there are circles and rings, and yes they are somewhat similar, arranged in a somewhat repeating texture. But that's where it stops. If you zoom into one of the circles, it doesn't turn out being an orb with many smaller circles and rings. It's just a circle.

 

This, too, is a regular, repeating pattern, but it is not fractal:

 

XceBm.png
 

 

Probably when increasing the palette frequency inifinitely you will get infinite level of depth in such circle patterns - you ignore this thing or you do not understand? Im not sure but maybe there can be stated that if you will get any small rectangle area you will find a circles in it (though maybe some vaves may be much  smaller than dominant one

 

for me i may repeat it seem this is not worse fractal than sierpi?ski carpet

 

I wonder if 3d version of it could be obtained? maybe someone will know? (this is maybe more 2d than 3d and i wonder if real spheric 

3d versiion surface is obtainable and which formula?)

 

PS Alvaro could ypu maybe rise up the visuals by inventing more colorfull palette here (more like unbird did)? (I cannot work on this today but would be curious if this could be more colorfull)

Edited by fir

Share this post


Link to post
Share on other sites
alvaro    21265

for me i may repeat it seem this is not worse fractal than sierpi?ski carpet


Take a square. If you scale it up by a factor of 3 in every direction, you get a figure composed of 9 copies of the original square. We can then define the dimension of the square as log(9)/log(3)=2 (that is, what power of the scaling factor gives you the number of copies).

If you scale the Sierpinski carpet up by a factor of 3 in every direction, you get a figure composed of 8 copies of the original Sierpinski carpet. Therefore its dimension is log(8)/log(3) = 1.89278926071437231130... That's why we call that a fractal.

I have no idea why you still think your image is a fractal. The way I see it, what you plotted is a couple of hundred concentric circles, which when sampled with a regular grid result in a spectacular moiré pattern. It's not like we are saying your image isn't pretty: It just has little to do with fractals.

I found this link: http://www.nahee.com/spanky/www/fractint/circle_type.html (Notice the "not a fractal" part.)

Share this post


Link to post
Share on other sites
fir    460

 

for me i may repeat it seem this is not worse fractal than sierpi?ski carpet


I have no idea why you still think your image is a fractal. The way I see it, what you plotted is a couple of hundred concentric circles, which when sampled with a regular grid result in a spectacular moiré pattern. It's not like we are saying your image isn't pretty: It just has little to do with fractals.

I found this link: http://www.nahee.com/spanky/www/fractint/circle_type.html (Notice the "not a fractal" part.)

 

 

I think it is unrelated to sampling on the grid- all in all this is well defined 

F(x,y) function for x,y are real,  - so sampling to a grid is not important imo, it just blurs the details, dont you think?

 

Very good info in this link, (i was searching for such references) though here is written ". The resulting image is not a fractal because all detail is lost after zooming in too far. "

Im not sure if this is true, if one will raise the frequenzy of palette

i think the detail depth will probably increase to infinity - so it probably depends how you  define this construct 

Share this post


Link to post
Share on other sites
Brother Bob    10344

 

 

for me i may repeat it seem this is not worse fractal than sierpi?ski carpet


I have no idea why you still think your image is a fractal. The way I see it, what you plotted is a couple of hundred concentric circles, which when sampled with a regular grid result in a spectacular moiré pattern. It's not like we are saying your image isn't pretty: It just has little to do with fractals.

I found this link: http://www.nahee.com/spanky/www/fractint/circle_type.html (Notice the "not a fractal" part.)

 

 

I think it is unrelated to sampling on the grid- all in all this is well defined 

F(x,y) function for x,y are real,  - so sampling to a grid is not important imo, it just blurs the details, dont you think?

 

Very good info in this link, (i was searching for such references) though here is written ". The resulting image is not a fractal because all detail is lost after zooming in too far. "

Im not sure if this is true, if one will raise the frequenzy of palette

i think the detail depth will probably increase to infinity - so it probably depends how you  define this construct 

 

Your function F(x,y) is a continuous function, but when you create your image you sample F(x,y) at discrete points. Each pixel in the image is a sample point of the function. In your first post, for example, you sample F(x,y) at roughly 950 discrete points along both the X and the Y axis. The interference is not in F(x,y) itself, but comes from sampling it at discrete points.

Share this post


Link to post
Share on other sites
fir    460

OK. Here's my last attempt at trying to explain why this isn't a fractal. This is an image similar to what you posted:

 

output1.png

 

This is what happened after I zoomed in a bit and I used anti-aliasing:

 

output-1.png

 

You got to low frequenzy paltette (*)- I was saing about this, (more than once i think and I see some ignore it ;\ - ) the details will appear if you increase it - if you will ignore this we will not agree here

(same thing with sierpi?ski on mandelbrot if you do only 5 iteration steps

you will get finite complexity)

 

(*) and maybe to low sampling frequenzy too, if this pattern vanishes

indeed maybe the grid sampling is needed - i dont know if this distortion to circles are so small that this grid sampling shows it

 

 

 

anyway this is strange - do antyaliasing destroyed most of the pattern but leaved some horizontal and vertical line ones? if the rest vanished why the vertical horizontal are still visible?

 

what way this antyaliasing works here? average of many subsamples per pixel?

 

on the other way this not changes too much:

if underlying shape is such smooth, indeed the grid sampling should be included in algorith - but this do not change to much only adds some module to formula - sample the result with rectangle grid

 

 you think infinite complexity is not obtainable this way?

Edited by fir

Share this post


Link to post
Share on other sites
fir    460

Your function F(x,y) is a continuous function, but when you create your image you sample F(x,y) at discrete points. Each pixel in the image is a sample point of the function. In your first post, for example, you sample F(x,y) at roughly 950 discrete points along both the X and the Y axis. The interference is not in F(x,y) itself, but comes from sampling it at discrete points.

 

 

Dont think so, Could you explain this, lets say that you are taking

some point x, y = 0.1776527, 0.23876 You say that color value of this point depends on the grid resolution? IMO F(x,y) values are grid independant

Share this post


Link to post
Share on other sites
Brother Bob    10344

Your function F(x,y) is a continuous function, but when you create your image you sample F(x,y) at discrete points. Each pixel in the image is a sample point of the function. In your first post, for example, you sample F(x,y) at roughly 950 discrete points along both the X and the Y axis. The interference is not in F(x,y) itself, but comes from sampling it at discrete points.

 
Dont think so, Could you explain this, lets say that you are taking
some point x, y = 0.1776527, 0.23876 You say that color value of this point depends on the grid resolution? IMO F(x,y) values are grid independant
Interference does not happen in one single sample point. It is the interaction between neighboring sample points. You cannot say anything about interference in one point. It is irrelevant what the value is in one point of the function.

Share this post


Link to post
Share on other sites
unbird    8338

Another proof it's a sampling artifact: Zoom in and out on Álvaro's anti-aliased image with your browser (IE,Firefox, Opera: CTRL + mouse wheel) and watch these circles come and go. One can sometimes  even notice a second Moiré effect in a checkerboard fashion probably due to a box filter for the images.

Share this post


Link to post
Share on other sites
Bacterius    13165

Another example of moire pattern. If you have an LCD monitor, scroll slowly across Alvaro's second image above. You get an interference pattern as well, and the scrolling speed changes the frequency of the fringes. I don't know if this will work with a CRT monitor since they use electron beams instead of a discrete crystal lattice.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this