MATLAB: How to convert newton basin into a binary image.

box countingcodefractals

I've recently made a newton basin using this program and slight variations of it. How do i take it a step further and convert the color map into a binary image, so that I can run box counting programs on them.

Best Answer

near_z1 = c(:,:,2) > 0;
near_z2 = c(:,:,1) > 0 & ~near_z1;
near_z3 = c(:,:,3) > 0;
Note: in theory these can overlap -- after all, your roots might be very close to each other. However, because you set the red plane for both z1 and z2, in order to not have the z2 map include the z1 values unnecessarily, you have to exclude the places z1 was found. That is a problem because your code does not give any way to figure out the places where z1 and z2 should both be set.
If your code for z1 did not set the red plane as well as the green plane, it would be easy.