[SOLVED] Calculations, High resolution mandelbrot (working code)
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
first
DO YOU have any exp. working with images in this size range
Quote:
I would like to increase the resolution over 100,000 x 100,000 + (into the millions x millions).
i do working with images that are 32768x16384, 65536x32768 and even a 128k map 131072 x 65536 pix.
a 32k 8 bit rgb image is 1.5 Gig
a 8 bit rgb 64 k image is 6 Gig
a 128 k image rgb will be over 24 gig in size
first
DO YOU have any exp. working with images in this size range
i do working with images that are 32768x16384, 65536x32768 and even a 128k map 131072 x 65536 pix.
a 32k 8 bit rgb image is 1.5 Gig
a 8 bit rgb 64 k image is 6 Gig
a 128 k image rgb will be over 24 gig in size
CAN YOU work with ONE image of this size??????
Gimp WILL not open a 100k image .
I had a 150MB file ,(colour png file 15,000x 10,000) image open on Fireworks. If I didn't have a program to open a file that big, I could always make one. ;P
Quote:
Originally Posted by smeezekitty
A 256 color image of that size is 9 GB.
Who has that kind of ram.
Well 12GB isnt alot of memory anymore, now you can buy 1GB for about £15 (DDR2). "gamers" now have 6-16GB of ram (totally overkill though)
Quote:
Originally Posted by graemef
A single image of that size would be very demanding of memory. Have you considered creating several smaller images that can be joined together?
No i Havent, Thinking about it, thats the easiest way of doing it, simple loop and scale changes.
[slightly offtopic]
I'd like to know too, if it's actually "useful" as well, but even if it isn't really "useful" it sure does generate some neat-o images. When I first saw the thread title, it remembered me back to my C-64 days, where I had entered a Mandelbrot Set image generator program in assembly, from out of Compute! magazine, which you could start from the world view (as shown in the OP's first image attachment) and you could select areas with cross-hairs and zoom in and rebuild the image. After about 3 or 4 zooms, I could watch each raster line being drawn, literally almost pixel by pixel, it was so frikkin slow but that was a 1 MHz processor. I used to let it run overnight, and in the morning, turn on the monitor to see my new image LOL. Really cool pictures.
May I ask where this knowledge is useful? How did you become familiar with this subject?
First of all, with most new discovery there is no real useful application at that time.
However, because of the amount of mathematical work done on fractals (which a mandelbrot is) we can upscale a pixelated picture to a highly accurate one. Check this out:Fractal Image Compression
People asked Faradays ' What is so important about this, all your doing is playing with magnets and wire? '
Chaos theory, you might think that this doesn't apply to everyday life, but actually, it is used alot. For example, the best microwaves will use chaos theory to try to heat the object evenly.
normally, we discover something, play around with it, try to apply it to life, and it's either a flop or not :P
Any sane mandelbrot generator has a fixed image size and you can zoom in and out, you will never find anyone crazy enough to try to display a huge high-resolution image of mandelblot, and have no clue why such a thing would be desired or useful or possible. It isn't possible, it would require too much RAM as people have stated earlier.
Any sane mandelbrot generator has a fixed image size and you can zoom in and out, you will never find anyone crazy enough to try to display a huge high-resolution image of mandelblot, and have no clue why such a thing would be desired or useful or possible. It isn't possible, it would require too much RAM as people have stated earlier.
The reason I want to have a huge res picture, is because I do.. I want a computer to contiunously compute a huge "picture" of a mandelbrot, and on my PS3, I want to make a zoomable high-iteration mandelbrot.
just a warning working with 6 to 24+ Gig. images is NOT easy
an example
using "imagemagick" a tilling opp.( cut into tiles )
cut a 16384x8192 image into 512 px tiles will take about 3 to 4 hours
the same opp. using the " vips" image lib will take 5 Min.
there is a VERY BIG deference in image libs
Gimp,Imagemagick, DevIl , Vips ,IM, CImg.
they all work differently
PS you might want to look at using CImg
there is a tutorial for this
CImg_demo.cpp
Code:
// Item : Mandelbrot/Julia Explorer
//----------------------------------
void* item_mandelbrot_explorer() {
// Define image canvas and corresponding display window.
CImg<unsigned char> img(800,600,1,3,0);
CImgDisplay disp(img);
// Start main explorer loop.
double julia_r = 0, julia_i = 0;
for (bool endflag = false, fractal_type = false, smooth = false, show_help = true; !endflag;) {
bool stopflag = false;
double xmin, xmax, ymin, ymax;
// Init default upper-left/lower-right coordinates of the fractal set.
if (fractal_type) { xmin = -1.5; xmax = 1.5; ymin = -1.5; ymax = 1.5; julia_r = 0.317; julia_i = 0.029; }
else { xmin = -2.25; xmax = 1.0; ymin = -1.5; ymax = 1.5; julia_r = julia_i = 0; }
// Create random palette for displaying the fractal set.
const CImg<unsigned char> palette =
CImg<unsigned char>(256,1,1,3,16+120).noise(119,1).resize(1024,1,1,3,3).fillC(0,0,0,0,0,0);
// Enter event loop for the current fractal set.
for (unsigned int maxiter = 64; !stopflag; ) {
// Draw Mandelbrot or Julia fractal set on the image.
img.resize(disp.resize().set_title("[#7] - %s Set : (%g,%g)-(%g,%g), %s = (%g,%g) (%u iter.)",
fractal_type?"Julia":"Mandelbrot",xmin,ymin,xmax,ymax,
fractal_type?"c":"z0",julia_r,julia_i,maxiter)).
fill(0).draw_mandelbrot(palette,1,xmin,ymin,xmax,ymax,maxiter,smooth,fractal_type,julia_r,julia_i);
// Display help if necessary.
if (show_help) {
const unsigned char white[] = { 255, 255, 255 };
static CImg<unsigned char>
help = CImg<unsigned char>().draw_text(0,0,"\n"
" Use mouse to zoom on desired region. \n"
" H Show/Hide help \n"
" PAD 1...9 Fractal navigation \n"
" PAD +/- Zoom/Unzoom \n"
" SPACE Set/Disable color smoothing \n"
" ENTER Switch Mandelbrot/Julia sets \n"
" Arrows Change set parameterization \n"
" Page UP/DOWN Add/Reduce iteration numbers \n\n",
white);
help.draw_rectangle(2,2,help.width() - 3,help.height() - 3,white,1,~0U);
img.draw_image(img.width() - help.width(),help,0.7f);
}
// Get rectangular shape from the user to define the zoomed region.
const CImg<int> selection = img.get_select(disp,2,0);
const int xs0 = selection[0], ys0 = selection[1], xs1 = selection[3], ys1 = selection[4];
// If the user has selected a region with the mouse, then zoom-in !
if (xs0>=0 && ys0>=0 && xs1>=0 && ys1>=0) {
const double dx =(xmax - xmin)/img.width(), dy =(ymax - ymin)/img.height();
const int dsmax = (ys1 - ys0)/2, xs = (xs0 + xs1)/2, ys = (ys0 + ys1)/2;
// If the region is too small (point) then reset the fractal set position and zoom.
if (dsmax<5) stopflag = true;
xmin+=(xs - dsmax*dy/dx)*dx;
ymin+=(ys - dsmax)*dy;
xmax-=(img.width() - xs - dsmax*dy/dx)*dx;
ymax-=(img.height() - ys - dsmax)*dy;
}
// Also, test if a key has been pressed.
// (moving in the fractal set can be done, using keyboard).
switch (disp.key()) {
// Show/hide help.
case cimg::keyH: show_help = !show_help; break;
// Switch between Julia/Mandelbrot sets.
case cimg::keyENTER: fractal_type = !fractal_type; stopflag = true; break;
// Enable/disable smoothed colors.
case cimg::keySPACE: smooth = !smooth; break;
// Change fractal set parameters.
case cimg::keyARROWLEFT: julia_r-=fractal_type?0.001f:0.05f; break;
case cimg::keyARROWRIGHT: julia_r+=fractal_type?0.001f:0.05f; break;
case cimg::keyARROWUP: julia_i+=fractal_type?0.001f:0.05f; break;
case cimg::keyARROWDOWN: julia_i-=fractal_type?0.001f:0.05f; break;
// Add/remove iterations.
case cimg::keyPAGEDOWN: maxiter-=32; break;
case cimg::keyPAGEUP: maxiter+=16; break;
// Move left, right, up and down in the fractal set.
case cimg::keyPAD4: { const double delta = (xmax - xmin)/10; xmin-=delta; xmax-=delta; } break;
case cimg::keyPAD6: { const double delta = (xmax - xmin)/10; xmin+=delta; xmax+=delta; } break;
case cimg::keyPAD8: { const double delta = (ymax - ymin)/10; ymin-=delta; ymax-=delta; } break;
case cimg::keyPAD2: { const double delta = (ymax - ymin)/10; ymin+=delta; ymax+=delta; } break;
// Allow to zoom in/out in the fractal set.
case cimg::keyPADADD: {
const double xc = 0.5*(xmin + xmax), yc = 0.5*(ymin + ymax), dx = (xmax - xmin)*0.85/2, dy = (ymax - ymin)*0.85/2;
xmin = xc - dx; ymin = yc - dy; xmax = xc + dx; ymax = yc + dy;
} break;
case cimg::keyPADSUB:
const double xc = 0.5*(xmin + xmax), yc = 0.5*(ymin + ymax), dx = (xmax - xmin)*1.15/2, dy = (ymax - ymin)*1.15/2;
xmin = xc - dx; ymin = yc - dy; xmax = xc + dx; ymax = yc + dy;
break;
}
// Do a simple test to check if more/less iterations are necessary for the next step.
const float value = img.get_norm().get_histogram(256,0,255)(0)*3;
if (value>img.size()/6.0f) maxiter+=16;
if (maxiter>1024) maxiter = 1024;
if (value<img.size()/10.0f) maxiter-=4;
if (maxiter<32) maxiter = 32;
// Check if the user want to quit the explorer.
if (disp.is_closed() || disp.is_keyQ() || disp.is_keyESC()) stopflag = endflag = true;
}
}
return 0;
}
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.