Skip to content

Instantly share code, notes, and snippets.

@lmendo
Last active July 30, 2024 07:21
Show Gist options
  • Save lmendo/56efd119e6e9b7886156c50f84a9a5fd to your computer and use it in GitHub Desktop.
Save lmendo/56efd119e6e9b7886156c50f84a9a5fd to your computer and use it in GitHub Desktop.
clear
%close all
% CHOOSE input parameters:
num_iter = 250; % number of iterations
lim = inf; % value at which we declare the sequence as "unbounded"
num_pix_real = 1080; % number of pixels in x
num_pix_imag = 1920;
%c_lims = [ -.8401 -.8391 .2224 ];
%c_lims = [ -.84008 -.83895 .2224 ];
%c_lims = [ -0.839534 -0.839122 0.223537 ];
c_lims = [ -0.839534 -0.8391 0.2236 ]; % min x, max x, min y
% Computations:
c_lims(end+1) = (c_lims(2)-c_lims(1))/num_pix_real*num_pix_imag + c_lims(3); % (max y is implied by specified numbers of pixels in x and y)
c_real_min = c_lims(1);
c_real_max = c_lims(2);
c_imag_min = c_lims(3);
c_imag_max = c_lims(4);
c_real = linspace(c_real_min,c_real_max,num_pix_real);
c_imag = linspace(c_imag_min,c_imag_max,num_pix_imag);
c = c_real + 1j*c_imag.';
% Actual computations
z = zeros(size(c));
cont_lim = zeros(size(c)); % de momento
for cont_iter = 1:num_iter
disp(cont_iter)%%%%%
z(~cont_lim) = z(~cont_lim).^2 + c(~cont_lim);
cont_lim = cont_lim + (abs(z)>=lim);
end %for
v = 1-cont_lim/max(cont_lim(:));
%imagesc(c_real, c_imag, (1-v).^4), axis equal, axis ij, colormap(flipud(parula(256)))
%imagesc(c_real, c_imag, exp(v.^.6).^1), axis equal, axis ij, colormap((inferno(2048)))
E = .4; % TWEAK as desired
w = exp(v.^E);
figure, imagesc(c_real, c_imag, w); axis equal, axis xy, colormap((inferno(2048)))
w = w - min(w(:));
w = w./max(w(:))*256;
w = uint8(w);
% TWEAK values and colormap type as desired:
%r = 1.35; cm = colormap(inferno(ceil(256^r+200))); ind = 200+round((1:256).^r); cm = cm(ind,:); colormap(cm)
%r = 5; F = 10; cm = colormap(inferno(256*F+1)); ind = atan(linspace(-r,r,256)); ind = ind-ind(1); ind = ind./ind(end)*F*256; ind = 1+round(ind); cm = cm(ind,:); colormap(cm)
%r = 10; F = 10; A = 550; cm = colormap(hsv(256*F+1+A)).*linspace(0,1,256*F+1+A).^.1.'; ind = atan(linspace(-r,r,256)); ind = ind-ind(1); ind = ind./ind(end)*F*256; ind = 1+round(ind); cm = cm(ind,:); colormap(cm)
%r = 7; F = 10; cm = colormap(inferno(256*F+1+00)); cm = cm(:,[3 2 1]).*[.6 .8 1]; ind = atan(linspace(-r,r,256)); ind = ind-ind(1); ind = ind./ind(end)*F*256; ind = 1+round(ind); cm = cm(ind,:); colormap(cm)
%r = 4.5; F = 10; cm = colormap(hot(256*F+1+500)); cm = cm(:,[1 2 3]).*[1 1 1] + [0 0 1].*linspace(.35,.05,size(cm,1)).'; ind = atan(linspace(-r,r,256)); ind = ind-ind(1); ind = ind./ind(end)*F*256; ind = 1+round(ind); cm = cm(ind,:); colormap(cm)
%r = 10; F = 10; A = 550; cm = colormap(cool(256*F+1+A)).*linspace(0,1,256*F+1+A).^.1.'; ind = atan(linspace(-r,r,256)); ind = ind-ind(1); ind = ind./ind(end)*F*256; ind = 1+round(ind); cm = cm(ind,:); colormap(cm)
r = 4.5; F = 10; cm = colormap(hot(256*F+1+500)); cm = cm(:,[1 2 3]).*[1 1 1] + [0 0 1].*linspace(.22,.0,size(cm,1)).'; ind = atan(linspace(-r,r,256)); ind = ind-ind(1); ind = ind./ind(end)*F*256; ind = 1+round(ind); cm = cm(ind,:); colormap(cm)
imwrite(flipud(w), cm, 'image.png', 'png')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment