Plik:Mandelbrot set - Stripe Average Coloring.png
Treść strony nie jest dostępna w innych językach.
Z Wikibooks, biblioteki wolnych podręczników.
Rozmiar podglądu – 600 × 600 pikseli. Inne rozdzielczości: 240 × 240 pikseli | 480 × 480 pikseli | 768 × 768 pikseli | 1024 × 1024 pikseli | 2000 × 2000 pikseli.
Rozmiar pierwotny (2000 × 2000 pikseli, rozmiar pliku: 2,18 MB, typ MIME: image/png)
Ten plik znajduje się w Wikimedia Commons i może być używany w innych projektach. Poniżej znajdują się informacje ze strony opisu tego pliku.
Spis treści
Opis
OpisMandelbrot set - Stripe Average Coloring.png |
English: Mandelbrot set - Stripe Average Coloring |
Data | |
Źródło | Made with code and help by Alex Simes and Syntopia |
Autor | Adam majewski |
Inne wersje |
|
Licencja
Ja, właściciel praw autorskich do tego dzieła, udostępniam je na poniższej licencji
Ten plik udostępniony jest na licencji Creative Commons Uznanie autorstwa – Na tych samych warunkach 4.0 Międzynarodowe.
- Wolno:
- dzielić się – kopiować, rozpowszechniać, odtwarzać i wykonywać utwór
- modyfikować – tworzyć utwory zależne
- Na następujących warunkach:
- uznanie autorstwa – musisz określić autorstwo utworu, podać link do licencji, a także wskazać czy utwór został zmieniony. Możesz to zrobić w każdy rozsądny sposób, o ile nie będzie to sugerować, że licencjodawca popiera Ciebie lub Twoje użycie utworu.
- na tych samych warunkach – Jeśli zmienia się lub przekształca niniejszy utwór, lub tworzy inny na jego podstawie, można rozpowszechniać powstały w ten sposób nowy utwór tylko na podstawie tej samej lub podobnej licencji.
Processing source code
// http://www.fractalforums.com/general-discussion/stripe-average-coloring/
// code by asimes
float xmin = -2.5;
float ymin = -2.0;
float wh = 4;
float stripes = 5.0;
int maxIterations = 1000;
void setup() {
size(10000, 10000, P2D);
}
void draw() {
loadPixels();
float xmax = xmin+wh;
float ymax = ymin+wh;
float dx = (xmax-xmin)/width;
float dy = (ymax-ymin)/height;
float x = xmin;
for (int i = 0; i < width; i++) {
float y = ymin;
for (int j = 0; j < height; j++) {
float zr = x;
float zi = y;
float lastzr = x;
float lastzi = y;
float orbitCount = 0;
int n = 0;
while (n < maxIterations) {
float zrr = zr*zr;
float zii = zi*zi;
float twori = 2*zr*zi;
zr = zrr-zii+x;
zi = twori+y;
if (zrr+zii > 10000) break;
orbitCount += 0.5+0.5*sin(stripes*atan2(zi, zr));
lastzr = zr;
lastzi = zi;
n++;
}
if (n == maxIterations) pixels[i+j*width] = 0;
else {
float lastOrbit = 0.5+0.5*sin(stripes*atan2(lastzi, lastzr));
float smallCount = orbitCount-lastOrbit;
orbitCount /= n;
smallCount /= n-1;
float frac = -1+log(2.0*log(10000))/log(2)-log(0.5*log(lastzr*lastzr+lastzi*lastzi))/log(2);
float mix = frac*orbitCount+(1-frac)*smallCount;
float orbitColor = mix*255;
pixels[i+j*width] = color(orbitColor);
}
y += dy;
}
x += dx;
}
updatePixels();
noLoop();
}
void mousePressed(){
save("a10000.png");
}
Downsizing with Image Magic:
convert a10000.png -resize 2000x2000 a2000.png
C source code
/*
c program: console, 1-file
samm.c
samm = Stripe Average Method
with :
- skipping first (i_skip+1) points from average
- linear interpolation
https://en.wikibooks.org/wiki/Fractals/Iterations_in_the_complex_plane/stripeAC
--------------------------------
1. draws Mandelbrot set for complex quadratic polynomial
Fc(z)=z*z +c
using samm = Stripe Average Method
-------------------------------
2. technique of creating ppm file 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)
-----
it is example for :
https://www.math.univ-toulouse.fr/~cheritat/wiki-draw/index.php/Mandelbrot_set
-------------
compile :
gcc samm.c -lm -Wall
./a.out
-------- git --------
cd existing_folder
git init
git remote add origin git@gitlab.com:adammajewski/mandelbrot_wiki_ACh.git
git add samm.c
git commit -m "samm + linear interpolation "
git push -u origin master
*/
#include <stdio.h>
#include <math.h> // M_LN2;
#include <complex.h> // https://stackoverflow.com/questions/6418807/how-to-work-with-complex-numbers-in-c
#define M_PI 3.14159265358979323846 /* pi */
/* screen ( integer) coordinate */
int iX,iY;
const int iXmax = 1200;
const int iYmax = 1000;
/* world ( double) coordinate = parameter plane*/
double Cx,Cy;
const double CxMin=-2.5;
const double CxMax=1.5;
const double CyMin=-5.0/3.0;
const double CyMax= 5.0/3.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="samm_i.ppm"; // https://commons.wikimedia.org/wiki/File:Mandelbrot_set_-_Stripe_Average_Coloring.png
char *comment="# ";/* comment should start with # */
static unsigned char color[3]; // 24-bit rgb color
unsigned char s = 5; // stripe density
const int IterationMax=1000; // N in wiki
int i_skip = 1; // exclude (i_skip+1) elements from average
/* bail-out value for the bailout test for exaping points
radius of circle centered ad the origin, exterior of such circle is a target set */
const double EscapeRadius=10000; // = ER big !!!!
double lnER; // ln(ER)
double complex give_c(int iX, int iY){
double Cx,Cy;
Cy=CyMin + iY*PixelHeight;
if (fabs(Cy)< PixelHeight/2) Cy=0.0; /* Main antenna */
Cx=CxMin + iX*PixelWidth;
return Cx+Cy*I;
}
// the addend function
// input : complex number z
// output : double number t
double Give_t(double complex z){
return 0.5+0.5*sin(s*carg(z));
}
/*
input :
- complex number
- intege
output = average
*/
double Give_Arg(double complex C , int iMax)
{
int i=0; // iteration
double complex Z= 0.0; // initial value for iteration Z0
double A = 0.0; // A(n)
double prevA = 0.0; // A(n-1)
double R; // =radius = cabs(Z)
double d; // smooth iteration count
// iteration = computing the orbit
for(i=0;i<iMax;i++)
{
Z=Z*Z+C; // https://en.wikibooks.org/wiki/Fractals/Iterations_in_the_complex_plane/qpolynomials
if (i>i_skip) A += Give_t(Z); //
R = cabs(Z);
if(R > EscapeRadius) break; // exterior of M set
prevA = A; // save value for interpolation
} // for(i=0
if (i == iMax)
A = -1.0; // interior
else { // exterior
// computing interpolated average
A /= (i - i_skip) ; // A(n)
prevA /= (i - i_skip - 1) ; // A(n-1)
// smooth iteration count
d = i + 1 + log(lnER/log(R))/M_LN2;
d = d - (int)d; // only fractional part = interpolation coefficient
// linear interpolation
A = d*A + (1.0-d)*prevA;
}
return A;
}
/*
input = complex number
output
- color array as Formal parameters
- int = return code
*/
int compute_color(complex double c, unsigned char color[3]){
double arg;
unsigned char b;
// compute
arg = Give_Arg( c, IterationMax);
//
if (arg < 0.0)
{ /* interior of Mandelbrot set = inside_color = */
color[0]=191; //
color[1]=191;
color[2]=191;
}
else // exterior of Mandelbrot set = CPM
{
// gray gradient
b = (unsigned char) (255 - 255*arg );
color[0]= b; /* Red*/
color[1]= b; /* Green */
color[2]= b; /* Blue */
};
return 0;
}
void setup(){
//
PixelWidth=(CxMax-CxMin)/iXmax;
PixelHeight=(CyMax-CyMin)/iYmax;
lnER = log(EscapeRadius); // ln(ER)
/*create new file,give it a name and open it in binary mode */
fp= fopen(filename,"wb"); /* b - binary mode */
/*write ASCII header to the file*/
fprintf(fp,"P6\n %s\n %d\n %d\n %d\n",comment,iXmax,iYmax,MaxColorComponentValue);
}
void info(){
double distortion;
// widt/height
double PixelsAspectRatio = (double)iXmax/iYmax; // https://en.wikipedia.org/wiki/Aspect_ratio_(image)
double WorldAspectRatio = (CxMax-CxMin)/(CyMax-CyMin);
printf("PixelsAspectRatio = %.16f \n", PixelsAspectRatio );
printf("WorldAspectRatio = %.16f \n", WorldAspectRatio );
distortion = PixelsAspectRatio - WorldAspectRatio;
printf("distortion = %.16f ( it should be zero !)\n", distortion );
printf("\n");
printf("bailut value = Escape Radius = %.0f \n", EscapeRadius);
printf("IterationMax = %d \n", IterationMax);
printf("i_skip = %d = number of skipped elements ( including t0 )= %d \n", i_skip, i_skip+1);
// file
printf("file %s saved. It is called .... in A Cheritat wiki\n", filename);
}
void close(){
fclose(fp);
info();
}
// ************************************* main *************************
int main()
{
complex double c;
setup();
printf(" render = compute and write image data bytes to the file \n");
for(iY=0;iY<iYmax;iY++)
for(iX=0;iX<iXmax;iX++)
{ // compute pixel coordinate
c = give_c(iX, iY);
/* compute pixel color (24 bit = 3 bytes) */
compute_color(c,color);
/*write color to the file*/
fwrite(color,1,3,fp);
}
close();
return 0;
}
New code with DEM/M
/*
c program: console, 1-file
samm.c
algorithms:
- escape time
- DEM/M = distance estimation
- SAC/M = SAM/M
samm = Stripe Average Method =
Stripe Average coloring = sac
with :
- skipping first (i_skip+1) points from average
- linear interpolation
https://en.wikibooks.org/wiki/Fractals/Iterations_in_the_complex_plane/stripeAC
--------------------------------
1. draws Mandelbrot set for complex quadratic polynomial
Fc(z)=z*z +c
using samm = Stripe Average Method/Coloring
-------------------------------
2. technique of creating ppm file 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)
-----
it is example for :
https://www.math.univ-toulouse.fr/~cheritat/wiki-draw/index.php/Mandelbrot_set
-------------
compile :
gcc samm.c -lm -Wall
./a.out
convert samm.ppm -resize 800x800 samm.png
-------- git --------
cd existing_folder
git init
git remote add origin git@gitlab.com:adammajewski/mandelbrot_wiki_ACh.git
git add samm.c
git commit -m "samm + linear interpolation "
git push -u origin master
*/
#include <stdio.h>
#include <math.h>
#include <complex.h> // https://stackoverflow.com/questions/6418807/how-to-work-with-complex-numbers-in-c
#include <omp.h> //OpenM
#define M_PI 3.14159265358979323846 /* pi */
/* screen ( integer) coordinate */
int iX,iY;
const int iXmax = 8000;
const int iYmax = 8000;
/* world ( double) coordinate = parameter plane*/
double Cx,Cy;
// c = -0.355298979690605 +1.178016112830515 i period = 0
// c = 0.213487557597331 +0.604701020309395 i period = 0
const double CxMin=-2.25;
const double CxMax=0.75;
const double CyMin=1.5;
const double CyMax= -1.5;
/* */
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="samm.ppm"; // https://commons.wikimedia.org/wiki/File:Mandelbrot_set_-_Stripe_Average_Coloring.png
char *comment="# ";/* comment should start with # */
static unsigned char color[3]; // 24-bit rgb color
unsigned char s = 7; // stripe density
const int IterationMax=2500; // N in wiki
int i_skip = 2; // exclude (i_skip+1) elements from average
/* bail-out value for the bailout test for exaping points
radius of circle centered ad the origin, exterior of such circle is a target set */
const double EscapeRadius=1000000; // = ER big !!!!
double lnER; // ln(ER)
double complex give_c(int iX, int iY){
double Cx,Cy;
Cy=CyMax - iY*PixelHeight;
//if (fabs(Cy)< PixelHeight/3.0) Cy=0.0; /* Main antenna */
Cx=CxMin + iX*PixelWidth;
return Cx+Cy*I;
}
// the addend function
// input : complex number z
// output : double number t
double Give_t(double complex z){
return 0.5+0.5*sin(s*carg(z));
}
/*
input :
- complex number
- intege
output = average or other estimators, like distance or interior
*/
double Give_Arg(double complex C , int iMax)
{
int i=0; // iteration
double complex Z= 0.0; // initial value for iteration Z0
double A = 0.0; // A(n)
double prevA = 0.0; // A(n-1)
double R; // =radius = cabs(Z)
double d; // smooth iteration count
double complex dC = 0; // derivative
double de; // = 2 * z * log(cabs(z)) / dc;
// iteration = computing the orbit
for(i=0;i<iMax;i++)
{
dC = 2 * Z * dC + 1;
Z=Z*Z+C; // https://en.wikibooks.org/wiki/Fractals/Iterations_in_the_complex_plane/qpolynomials
if (i>i_skip) A += Give_t(Z); //
R = cabs(Z);
if(R > EscapeRadius) break; // exterior of M set
prevA = A; // save value for interpolation
} // for(i=0
if (i == iMax)
A = -1.0; // interior
else { // exterior
de = 2 * R * log(R) / cabs(dC);
if (de < PixelWidth) A = FP_ZERO; // boundary
else {
// computing interpolated average
A /= (i - i_skip) ; // A(n)
prevA /= (i - i_skip - 1) ; // A(n-1)
// smooth iteration count
d = i + 1 + log(lnER/log(R))/M_LN2;
d = d - (int)d; // only fractional part = interpolation coefficient
// linear interpolation
A = d*A + (1.0-d)*prevA;
}
}
return A;
}
/*
input = complex number
output
- color array as Formal parameters
- int = return code
*/
int compute_color(complex double c, unsigned char color[3]){
double arg;
unsigned char b;
// compute
arg = Give_Arg( c, IterationMax);
//
if (arg < 0.0)
/* interior of Mandelbrot set = inside_color = */
b = 0;
else // exterior of Mandelbrot set = CPM
{
if (arg == FP_ZERO) b= 255; // boundary
else b = (unsigned char) (255 - 255*arg );
};
// gray gradient
color[0]= b; /* Red*/
color[1]= b; /* Green */
color[2]= b; /* Blue */
return 0;
}
void setup(){
//
PixelWidth=(CxMax-CxMin)/iXmax;
PixelHeight=(CyMax-CyMin)/iYmax;
lnER = log(EscapeRadius); // ln(ER)
/*create new file,give it a name and open it in binary mode */
fp= fopen(filename,"wb"); /* b - binary mode */
/*write ASCII header to the file*/
fprintf(fp,"P6\n %s\n %d\n %d\n %d\n",comment,iXmax,iYmax,MaxColorComponentValue);
}
void info(){
double distortion;
// widt/height
double PixelsAspectRatio = (double)iXmax/iYmax; // https://en.wikipedia.org/wiki/Aspect_ratio_(image)
double WorldAspectRatio = (CxMax-CxMin)/(CyMax-CyMin);
printf("PixelsAspectRatio = %.16f \n", PixelsAspectRatio );
printf("WorldAspectRatio = %.16f \n", WorldAspectRatio );
distortion = PixelsAspectRatio - WorldAspectRatio;
printf("distortion = %.16f ( it should be zero !)\n", distortion );
printf("\n");
printf("bailut value = Escape Radius = %.0f \n", EscapeRadius);
printf("IterationMax = %d \n", IterationMax);
printf("i_skip = %d = number of skipped elements ( including t0 )= %d \n", i_skip, i_skip+1);
// file
printf("file %s saved. It is called .... in A Cheritat wiki\n", filename);
}
void close(){
fclose(fp);
info();
}
// ************************************* main *************************
int main()
{
complex double c;
setup();
printf(" render = compute and write image data bytes to the file \n");
//#pragma omp parallel for schedule(static) private(iY, iX, c, color)
for(iY=0;iY<iYmax;iY++)
for(iX=0;iX<iXmax;iX++)
{ // compute pixel coordinate
c = give_c(iX, iY);
/* compute pixel color (24 bit = 3 bytes) */
compute_color(c,color);
/*write color to the file*/
fwrite(color,1,3,fp);
}
close();
return 0;
}
Obiekty przedstawione na tym zdjęciu
przedstawia
Jakaś wartość bez elementu Wikidanych
20 wrz 2017
image/png
Historia pliku
Kliknij na datę/czas, aby zobaczyć, jak plik wyglądał w tym czasie.
Data i czas | Miniatura | Wymiary | Użytkownik | Opis | |
---|---|---|---|---|---|
aktualny | 17:39, 26 wrz 2017 | 2000 × 2000 (2,18 MB) | Soul windsurfer | smaller size, 8000 is loading slow | |
17:36, 26 wrz 2017 | 8000 × 8000 (19,25 MB) | Soul windsurfer | better image, + DEM | ||
17:21, 20 wrz 2017 | 2000 × 2000 (1,1 MB) | Soul windsurfer | User created page with UploadWizard |
Lokalne wykorzystanie pliku
Poniższa strona korzysta z tego pliku:
Globalne wykorzystanie pliku
Ten plik jest wykorzystywany także w innych projektach wiki:
- Wykorzystanie na en.wikibooks.org
Metadane
Niniejszy plik zawiera dodatkowe informacje, prawdopodobnie dodane przez aparat cyfrowy lub skaner użyte do wygenerowania tego pliku.
Jeśli plik był modyfikowany, dane mogą być częściowo niezgodne z parametrami zmodyfikowanego pliku.
Komentarz pliku w formacie PNG | |
---|---|
Data i czas modyfikacji pliku | 15:37, 26 wrz 2017 |