Αρχείο:ILSMJ.png

Τα περιεχόμενα της σελίδας δεν υποστηρίζονται σε άλλες γλώσσες.
Αυτό το αρχείο προέρχεται από το Wikimedia Commons
Από τη Βικιπαίδεια, την ελεύθερη εγκυκλοπαίδεια

Εικόνα σε υψηλότερη ανάλυση(1.500 × 1.000 εικονοστοιχεία, μέγεθος αρχείου: 226 KB, τύπος MIME: image/png)

Σύνοψη

Περιγραφή
English: Internal Level Sets of filled-in Julia set for fc(z)=z*z+c and c= -0.584895
Ημερομηνία
Πηγή Έργο αυτού που το ανεβάζει
Δημιουργός Adam majewski
Άδεια
(Επαναχρησιμοποίηση αυτού του αρχείου)
Εγώ, ο κάτοχος των πνευματικών δικαιωμάτων αυτού του έργου, το δημοσιεύω δια του παρόντος υπό την εξής άδεια χρήσης:
w:el:Creative Commons
αναφορά προέλευσης παρόμοια διανομή
Είστε ελεύθερος:
  • να μοιραστείτε – να αντιγράψετε, διανέμετε και να μεταδώσετε το έργο
  • να διασκευάσετε – να τροποποιήσετε το έργο
Υπό τις ακόλουθες προϋποθέσεις:
  • αναφορά προέλευσης – Θα πρέπει να κάνετε κατάλληλη αναφορά, να παρέχετε σύνδεσμο για την άδεια και να επισημάνετε εάν έγιναν αλλαγές. Μπορείτε να το κάνετε με οποιοδήποτε αιτιολογήσιμο λόγο, χωρίς όμως να εννοείται με οποιονδήποτε τρόπο ότι εγκρίνουν εσάς ή τη χρήση του έργου από εσάς.
  • παρόμοια διανομή – Εάν αλλάξετε, τροποποιήσετε ή δημιουργήσετε πάνω στο έργο αυτό, μπορείτε να διανείμετε αυτό που θα προκύψει μόνο υπό τους όρους της ίδιας ή συμβατής άδειας με το πρωτότυπο.
άλλες εκδόσεις
c = 0.5*i

Compare with

Links

Αδειοδότηση

The look of leves set depends on :

  • AR
  • C=Cx+Cy*i

Parameter are found by trial and error method to get figure 8 curves.

AR

Maximal attracting radius ( convergence r. ) for c inside main cardioid is  :[1]

AR  = 1-abs(1-sqrt(1-4c))) 

Algorithm

  • create array for 8-bit colors ( shades of gray = numbers from 0 to 255)
  • fill array with data ( dynamical plane of fc(z) = z*z + c with filled Julia set )
  • apply Sobel filter ( result is in another array)
  • merge two arrays
  • save result array to pgm file
  • convert pgm file to png

Computing filled Julia set and internal level sets

  • map array ( integer coordinate ) to dynamical plane ( z-plane) : (iX,iY) --> (Zx,Zy)
  • find attractor ( by forward iteration of critical point )
  • for each point Z compute its External Last Iteration ( Escape Time).
  • if ( IterationMax != eLastIteration ) then mark it as exterir of filled julia set , else it is interior
  • for interior points find internal last iteration for which it is close to attractor and color this point : odd/even number

Compare with

Above image is inspired by these images by T Kawahira[dead link]

C src code

It is c console program. To compile:

 gcc d.c -lm -Wall

To run :

./a.out

It will create 0.000048265.pgm file. To convert it to pgm with Image Magic use :

convert 0.000048265.pgm  -resize 1500x1000 c.png

Code has been formatted in Emacs

/*

  c console program
  -----------------------------------------
  1.ppm file code is  based on the code of Claudio Rocchini
  http://en.wikipedia.org/wiki/Image:Color_complex_plot.jpg
  create 24 bit color graphic file ,  portable pixmap file = PPM 
  see http://en.wikipedia.org/wiki/Portable_pixmap
  to see the file use external application ( graphic viewer)
  I think that creating graphic can't be simpler
  ---------------------------
  2. first it creates data array which is used to store rgb color values of pixels,
  fills tha array with data and after that writes the data from array to pgm file.
  It alows free ( non sequential) acces to "pixels"
    
  -------------------------------------------
  Adam Majewski   fraktal.republika.pl 
 
  Sobel filter 
  Gh = sum of six values ( 3 values of matrix are equal to 0 ). Each value is = pixel_color * filter_coefficients 
 
*/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <complex.h>
#include <string.h>

/* iXmax/iYmax = 3/2 */
#define iXmax 3000 /* height of image in pixels */
#define iYmax 2000
/* fc(z) = z*z + c */
#define Cx -0.5848950 /* C = Cx + Cy*i */
#define Cy  0.0
#define AR  0.000048265 /* PixelWidth/1;  radius of circle around attractor ZA = target set for attracting points */
#define AR2 AR*AR

/* escape time to infinity */
int GiveExtLastIteration(double _Zx0, double _Zy0,double C_x, double C_y, int iMax, double _ER2)
{ 
  int i;
  double Zx, Zy;
  double Zx2, Zy2; /* Zx2=Zx*Zx;  Zy2=Zy*Zy  */
  Zx=_Zx0; /* initial value of orbit  */
  Zy=_Zy0;
  Zx2=Zx*Zx;
  Zy2=Zy*Zy;
  for (i=0;i<iMax && ((Zx2+Zy2)<_ER2);i++)
    {
      Zy=2*Zx*Zy + C_y;
      Zx=Zx2-Zy2 +C_x;
      Zx2=Zx*Zx;
      Zy2=Zy*Zy;
    };
  return i;
}

/* find attractor ZA  using forward iteration of critical point Z = 0  */
/* if period is >1 gives one point from attracting cycle */
double complex GiveAttractor(double _Cx, double _Cy, double ER2, int _IterationMax)
{
  int Iteration;
  double Zx, Zy; /* z = zx+zy*i */
  double Zx2, Zy2; /* Zx2=Zx*Zx;  Zy2=Zy*Zy  */
  /* -- find attractor ZA  using forward iteration of critical point Z = 0  */
  Zx=0.0;
  Zy=0.0;
  Zx2=Zx*Zx;
  Zy2=Zy*Zy;
  for (Iteration=0;Iteration<_IterationMax && ((Zx2+Zy2)<ER2);Iteration++)
    {
      Zy=2*Zx*Zy + _Cy;
      Zx=Zx2-Zy2 + _Cx;
      Zx2=Zx*Zx;
      Zy2=Zy*Zy;
    };
  return Zx+Zy*I;
}

/* attracting time to finite attractor ZA */
int GiveIntLastIteration(double _Zx0, double _Zy0,double C_x, double C_y, int iMax, double _AR2, double _ZAx, double _ZAy )
{ 
  int i;
  double Zx, Zy; /* z = zx+zy*i */
  double Zx2, Zy2; /* Zx2=Zx*Zx;  Zy2=Zy*Zy  */
  double d, dX, dY; /* distance from z to Alpha  */
  Zx=_Zx0; /* initial value of orbit  */
  Zy=_Zy0;
  Zx2=Zx*Zx;
  Zy2=Zy*Zy;
  dX=Zx-_ZAx;
  dY=Zy-_ZAy;
  d=dX*dX+dY*dY;
  for (i=0;i<iMax && (d>_AR2);i++)
    {
      Zy=2*Zx*Zy + C_y;
      Zx=Zx2-Zy2 +C_x;
      Zx2=Zx*Zx;
      Zy2=Zy*Zy;
      dX=Zx-_ZAx;
      dY=Zy-_ZAy;
      d=dX*dX+dY*dY;
    };
  return i;
}

/* gives position of point (iX,iY) in 1D array  ; uses also global variables */
unsigned int f(unsigned int _iX, unsigned int _iY)
{return (_iX + (iYmax-_iY-1)*iXmax );}

/* --------------------------------------------------------------------------------------------------------- */

int main(){
  
 
    
  unsigned int iX,iY, /* indices of 2D virtual array (image) = integer coordinate */
    i, /* index of 1D array  */
    iLength = iXmax*iYmax;/* length of array in bytes = number of bytes = number of pixels of image * number of bytes of color */
  /* world ( double) coordinate = parameter plane*/
  const double ZxMin=-1.5;
  const double ZxMax=1.5;
  const double ZyMin=-1.0;
  const double ZyMax=1.0;
  double PixelWidth=(ZxMax-ZxMin)/iXmax;
  double PixelHeight=(ZyMax-ZyMin)/iYmax;
  /* */
  double Zx, Zy;    /* Z=Zx+Zy*i   */
  double complex ZA;  /* atractor ZA = ZAx + ZAy*i */
  /* */
  
  const double EscapeRadius=80.0; /* radius of circle around origin; its complement is a target set for escaping points */
  double ER2=EscapeRadius*EscapeRadius;
  
  const int IterationMax=60,
    IterationMaxBig= 1000001;
  int eLastIteration, iLastIteration;
  /* sobel filter */
  unsigned char G, Gh, Gv; 
  /* color */
  unsigned char color[]={255,230,180};
  const unsigned int MaxColorComponentValue=255; /* color component is coded from 0 to 255 ;  it is 8 bit color file */
  

  /* dynamic 1D arrays for colors ( shades of gray ) */
  unsigned char *data, *edge;
  data = malloc( iLength * sizeof(unsigned char) );
  edge = malloc( iLength * sizeof(unsigned char) );
  if (data == NULL || edge==NULL)
    {
      fprintf(stderr,"Could not allocate memory");
      getchar(); 
      return 1;
    }
  else printf("memory is OK\n");

  ZA = GiveAttractor( Cx, Cy, ER2, IterationMaxBig); /* find attractor ZA  using forward iteration of critical point Z = 0  */

  /* fill the data array */
  for(iY=0;iY<iYmax;++iY){ 
    Zy=ZyMin + iY*PixelHeight; /*  */
    if (fabs(Zy)<PixelHeight/2) Zy=0.0; /*  */    
    for(iX=0;iX<iXmax;++iX){ 
      Zx=ZxMin + iX*PixelWidth;
      eLastIteration = GiveExtLastIteration(Zx, Zy, Cx, Cy, IterationMax, ER2 );
      i= f(iX,iY); /* compute index of 1D array from indices of 2D array */
      if ( IterationMax != eLastIteration ) 
	{data[i]=245;} /* exterior */
      else /* interior */
	{ iLastIteration = GiveIntLastIteration(Zx, Zy, Cx, Cy, IterationMaxBig, AR2, creal(ZA), cimag(ZA));
          data[i]=color[iLastIteration % 2];} /*  level sets of attraction time */
      /*  if (Zx>0 && Zy>0) data[i]=255-data[i];    check the orientation of Z-plane by marking first quadrant */
    }
  }

  /* find boundaries in data array using  Sobel filter  */
  for(iY=1;iY<iYmax-1;++iY){ 
    for(iX=1;iX<iXmax-1;++iX){ 
      Gv= data[f(iX-1,iY+1)] + 2*data[f(iX,iY+1)] + data[f(iX-1,iY+1)] - data[f(iX-1,iY-1)] - 2*data[f(iX-1,iY)] - data[f(iX+1,iY-1)];
      Gh= data[f(iX+1,iY+1)] + 2*data[f(iX+1,iY)] + data[f(iX-1,iY-1)] - data[f(iX+1,iY-1)] - 2*data[f(iX-1,iY)] - data[f(iX-1,iY-1)];
      G = sqrt(Gh*Gh + Gv*Gv);
      i= f(iX,iY); /* compute index of 1D array from indices of 2D array */
      if (G==0) {edge[i]=255;} /* background */
      else {edge[i]=0;}  /* boundary */
    }
  }

  /* copy boundaries from edge to data array */
  for(iY=1;iY<iYmax-1;++iY){ 
    for(iX=1;iX<iXmax-1;++iX)
      {i= f(iX,iY); /* compute index of 1D array from indices of 2D array */
	if (edge[i]==0) data[i]=0;}}
  /* ---------- file  -------------------------------------*/
  FILE * fp;
  char name [10]; /* name of file */
  i = sprintf(name,"%2.9f",AR); /* result (is saved in i) but is not used */
  char *filename =strcat(name,".pgm");
  char *comment="# this is binary pgm  file";/* comment should start with # */
  /* save image to the pgm file  */      
  fp= fopen(filename,"wb"); /*create new file,give it a name and open it in binary mode  */
  fprintf(fp,"P5\n %s\n %u\n %u\n %u\n",comment,iXmax,iYmax,MaxColorComponentValue);  /*write header to the file*/
  fwrite(data,iLength,1,fp);  /*write image data bytes to the file in one step */
  printf("File %s saved. \n", filename);
  /* --------------free memory ---------------------*/
  free(data);
  free(edge);
  free(fp);
  return 0;
}

references

  1. JJulia Sets of Complex Polynomials and Their Implementation on the Computer by Christoph Martin Stroh

Λεζάντες

Δεν ορίστηκε λεζάντα

Items portrayed in this file

απεικονίζει

Ιστορικό αρχείου

Κλικάρετε σε μια ημερομηνία/ώρα για να δείτε το αρχείο όπως εμφανιζόταν εκείνη τη στιγμή.

Ώρα/Ημερομ.ΜικρογραφίαΔιαστάσειςΧρήστηςΣχόλια
τελευταία10:35, 16 Ιουλίου 2011Μικρογραφία για την έκδοση της 10:35, 16 Ιουλίου 20111.500 × 1.000 (226 KB)Soul windsurfer

Τα παρακάτω λήμματα συνδέουν σε αυτό το αρχείο:

Καθολική χρήση αρχείου

Τα ακόλουθα άλλα wiki χρησιμοποιούν αυτό το αρχείο: