לדלג לתוכן

קובץ:LCMM.jpg

תוכן הדף אינו נתמך בשפות אחרות.
מתוך ויקיפדיה, האנציקלופדיה החופשית

לקובץ המקורי(2,000 × 2,000 פיקסלים, גודל הקובץ: 323 ק"ב, סוג MIME‏: image/jpeg)

ויקישיתוף זהו קובץ שמקורו במיזם ויקישיתוף. תיאורו בדף תיאור הקובץ המקורי (בעברית) מוצג למטה.

תקציר

תיאור
English: Level curves of Mandelbrot set. The Julia set boundary itself is not drawn: we see it as the locus of points where the boundaries of level curves are especially close to each other.
מקור self-made using C console program
יוצר Adam majewski

Compare with

Long description

This is C console program.

It creates 24 bit color ( RGB ) ppm file in program directory. technic of creating ppm file is based on the code of Claudio Rocchini.

  • First dynamic 1D array for 24-bit color values is created.
  • Color of points is saved in array
  • array is saved to the file

To see the file use external application ( image viewer). File was converted from ppm to jpg.

Image is created by:

  • creating Level Sets of Escape time of Mandelbrot set ( see image Level Sets )
  • edge detection of Level sets. Algorithm is based on paper by M. Romera et al[1]

See also

C source code

It is a console C program ( one file) It can be compiled under :

  • windows ( gcc thru Dev-C++ )
  • linux and mac using gcc :
gcc main.c -lm

it creates a.out file. Then run it :

./a.out

It creates ppm file in program directory. Use file viewer to see it.

 #include <stdio.h>
 #include <math.h>
 int main()
 {
  /* screen ( integer) coordinate */
  int iX,iY;
  const int iXmax = 2000, iXmin=0; 
  const int iYmax = 2000, iYmin=0;
  int iWidth=iXmax-iXmin+1,
  iHeight=iYmax-iYmin+1,
  /* number of bytes = number of pixels of image * number of bytes of color */
  iLength=iWidth*iHeight*3,/* 3 bytes of color  */
  index; /* of array */
  /* world ( double) coordinate = parameter plane*/
  double Cx,Cy;
  const double CxMin=-2.5;
  const double CxMax=1.5;
  const double CyMin=-2.0;
  const double CyMax=2.0;
  /* */
  double PixelWidth=(CxMax-CxMin)/iXmax;
  double PixelHeight=(CyMax-CyMin)/iYmax;
  /* color component ( R or G or B) is coded from 0 to 255 */
  /* it is 24 bit color RGB file */
  const int MaxColorComponentValue=255; 
  FILE * fp;
  char *filename="LCMM.ppm";
  char *comment="# ";/* comment should start with # */
  /* Z=Zx+Zy*i  ;   Z0 = 0 */
  double Zx, Zy;
  double Zx2, Zy2; /* Zx2=Zx*Zx;  Zy2=Zy*Zy  */
  /*  */
  int Iteration, PreviousIter;
  const int IterationMax=2000;
  /* bail-out value , radius of circle ;  */
  const double EscapeRadius=1000;
  double ER2=EscapeRadius*EscapeRadius;
  /* dynamic 1D array for 24-bit color values */    
  unsigned char *array;
  /*-------------------------------------------------------------------*/
  array = malloc( iLength * sizeof(unsigned char) );
  if (array == NULL)
    {
    fprintf(stderr,"Could not allocate memory");
    getchar();
    return 1;
    }
    else 
     {   fprintf(stderr,"I'm working. Please wait (:-))\n ");
         /* fill the data array with white points */       
         for(index=0;index<iLength-1;++index) array[index]=255;
     }
  /* ---------------------------------------------------------------*/
  /* first coat of paint */
  for(iY=0;iY<iYmax;iY++)
    {
    Cy=CyMin + iY*PixelHeight;
    if (fabs(Cy)< PixelHeight/2) Cy=0.0; /* Main antenna */
    for(iX=0;iX<iXmax;iX++)
      {         
       Cx=CxMin + iX*PixelWidth;
       /* initial value of orbit = 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;
        };
       /* plot point of Level Curve */
       if (iX!=0 && Iteration!=PreviousIter)
       { 
         array[((iYmax-iY-1)*iXmax+iX)*3]=0;
         array[((iYmax-iY-1)*iXmax+iX)*3+1]=0;
         array[((iYmax-iY-1)*iXmax+iX)*3+2]=0;
         PreviousIter=Iteration;                       
       }
     }
    }
   /* second coat of paint */
   for(iX=0;iX<iXmax;iX++)
   {         
     Cx=CxMin + iX*PixelWidth;
     for(iY=0;iY<iYmax;iY++)
     {
      Cy=CyMin + iY*PixelHeight;
      if (fabs(Cy)< PixelHeight/2) Cy=0.0; /* Main antenna */
      /* initial value of orbit = 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;
       };
       /* plot point of Level Curve */
       if (iX!=0 && Iteration!=PreviousIter)
        { 
         array[((iYmax-iY-1)*iXmax+iX)*3]=0;
         array[((iYmax-iY-1)*iXmax+iX)*3+1]=0;
         array[((iYmax-iY-1)*iXmax+iX)*3+2]=0;
         PreviousIter=Iteration;                       
        }
       }
      }
   /* write the whole data array to ppm file in one step */      
   /*create new file,give it a name and open it in binary mode  */
   fp= fopen(filename,"wb"); /* b -  binary mode */
   if (fp == NULL){ fprintf(stderr,"file error"); }
     else
      {
       /*write ASCII header to the file*/
      fprintf(fp,"P6\n %s\n %d\n %d\n %d\n",comment,iXmax,iYmax,MaxColorComponentValue);
      /*write image data bytes to the file*/
      fwrite(array,iLength ,1,fp);
      fclose(fp);
      fprintf(stderr,"file saved\n");
      getchar();
     }
    free(array);
    getchar();
    return 0;
 }

רישיון

אני, בעל זכויות היוצרים על היצירה הזאת, מפרסם אותה בזאת תחת הרישיונות הבאים:
GNU head מוענקת בכך הרשות להעתיק, להפיץ או לשנות את המסמך הזה, לפי תנאי הרישיון לשימוש חופשי במסמכים של גנו, גרסה 1.2 או כל גרסה מאוחרת יותר שתפורסם על־ידי המוסד לתוכנה חופשית; ללא פרקים קבועים, ללא טקסט עטיפה קדמית וללא טקסט עטיפה אחורית. עותק של הרישיון כלול בפרק שכותרתו הרישיון לשימוש חופשי במסמכים של גנו.
w:he:Creative Commons
ייחוס שיתוף זהה
הנכם רשאים:
  • לשתף – להעתיק, להפיץ ולהעביר את העבודה
  • לערבב בין עבודות – להתאים את העבודה
תחת התנאים הבאים:
  • ייחוס – יש לתת ייחוס הולם, לתת קישור לרישיון, ולציין אם נעשו שינויים. אפשר לעשות את זה בכל צורה סבירה, אבל לא בשום צורה שמשתמע ממנה שמעניק הרישיון תומך בך או בשימוש שלך.
  • שיתוף זהה – אם תיצרו רמיקס, תשנו, או תבנו על החומר, חובה עליכם להפיץ את התרומות שלך לפי תנאי רישיון זהה או תואם למקור.
הנכם מוזמנים לבחור את הרישיון הרצוי בעיניכם.

References

  1. Drawing the Mandelbrot set by the method of escape lines. M. Romera et al.

כיתובים

נא להוסיף משפט שמסביר מה הקובץ מייצג

פריטים שמוצגים בקובץ הזה

מוצג

היסטוריית הקובץ

ניתן ללחוץ על תאריך/שעה כדי לראות את הקובץ כפי שנראה באותו זמן.

תאריך/שעהתמונה ממוזערתממדיםמשתמשהערה
נוכחית21:41, 31 במרץ 2008תמונה ממוזערת לגרסה מ־21:41, 31 במרץ 2008‪2,000 × 2,000‬ (323 ק"ב)Soul windsurfer{{Information |Description= |Source=self-made using C console program |Date= |Author= Adam majewski |Permission= |other_versions= }}

אין בוויקיפדיה דפים המשתמשים בקובץ זה.

שימוש גלובלי בקובץ

אתרי הוויקי השונים הבאים משתמשים בקובץ זה:

מטא־נתונים