File:LCMM.jpg
Original file (2,000 × 2,000 pixels, file size: 323 KB, MIME type: image/jpeg)
This is a file from the Wikimedia Commons. The description on its description page there is shown below. |
Contents
Summary
DescriptionLCMM.jpg |
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. |
Source | self-made using C console program |
Author | Adam majewski |
Compare with
-
LCM/J but better algorithm, ER = 2
-
LSM/J B&W; ER = 1000
-
LSM/J colour ( probably made with Fractint ); ER = 2
-
Computed using implicit equations; ER=2
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
- Level curves of Fatou set
- Lemniscates of Mandelbrot set computed using implicit equations
- Other method of edge detection with better results
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;
}
Licensing
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled GNU Free Documentation License.http://www.gnu.org/copyleft/fdl.htmlGFDLGNU Free Documentation Licensetruetrue |
- You are free:
- to share – to copy, distribute and transmit the work
- to remix – to adapt the work
- Under the following conditions:
- attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
- share alike – If you remix, transform, or build upon the material, you must distribute your contributions under the same or compatible license as the original.
References
Items portrayed in this file
depicts
some value
File history
Click on a date/time to view the file as it appeared at that time.
Date/Time | Thumbnail | Dimensions | User | Comment | |
---|---|---|---|---|---|
current | 18:41, 31 March 2008 | 2,000 × 2,000 (323 KB) | Soul windsurfer | {{Information |Description= |Source=self-made using C console program |Date= |Author= Adam majewski |Permission= |other_versions= }} |
File usage
The following 3 pages use this file:
Metadata
This file contains additional information, probably added from the digital camera or scanner used to create or digitize it.
If the file has been modified from its original state, some details may not fully reflect the modified file.
_error | 0 |
---|