# Question:Pixel Counting with Fractals

## Question:Pixel Counting with Fractals

Maple

Below is the code found on this site for generating the mandelbrot set.

with(ImageTools):

MyMandel := proc(pt)

local i,z,c;

c := pt;

if abs(c) > 2 then

return 1;

else

z := c;

for i from 2 to 100 do

z := z^2 + c;

if abs(z) > 2 then

return i;

end if;  end do:

return 0;

end if; end proc;

GenerateComplex := proc(pts,X1,X2,Y1,Y2)

option evalhf;

local X::Vector, Y::Vector, f1::Vector, Z::Vector;

X := Vector(pts, i -> X1+(X2-X1)*(i-1)/(pts-1), datatype=float[8]):

Y := Vector(pts, i -> Y1+(Y2-Y1)*(i-1)/(pts-1), datatype=float[8]):

f1 := (i,j) -> X[j] + Y[i]*I:

Z := Matrix(pts,f1,datatype=complex[8]):

return Z:

end proc:

Zc := GenerateComplex(400, -2, 1, -1.35, 1.35):

sol := LinearAlgebra[Map](MyMandel, Zc):

img := Create(sol):

View(FitIntensity(img));

Now what I would like to do is modify this a bit so that It will only turn pixels that stay below 2 (that is, absolute value below 2) after how many iterations I specify in the "for i from 2 to 100" part (where 100 is the amount of iterations) turn black and the rest are white.

I think this can somewhat be found by looking at the Matrix Zc and seeing where 0 (i think) occurs. If this is so can someone just confirm this?

Basically I'm trying to count the pixels that make up the Mandelbrot set to see what area comes out!

﻿