| New Reply |
MATLAB - Image Processing - Douday's rabbit fractal |
Share Thread | Thread Tools |
| Aug5-11, 10:16 PM | #52 |
|
Recognitions:
|
MATLAB - Image Processing - Douday's rabbit fractalBack to the question of why greenprint is getting unexpected results. Would you be able to make a quick test for us with that python code to test the conjecture that the direction of the inequality in a = np.where(np.abs(z)<sqrt5) should cause either a multi-level or a two-level map to be produced. In particular could you please test if replacing the above line with, a = np.where(np.abs(z)>sqrt5), causes your program to produce only a two level map (and a corresponding monochrome image). |
| Aug6-11, 08:35 PM | #53 |
|
|
![]() and the almost(?) monochrome image obtained from abs(z)>sqrt(5):
|
| Aug7-11, 06:51 AM | #54 |
|
Recognitions:
|
Anyway I'm currently installing those python packages and am just about to try and reproduce you code. Hopefully I'll be able to get to the bottom of it once I see the results for myself. :) |
| Aug7-11, 07:20 AM | #55 |
|
Recognitions:
|
Mystery solved !!!
Ok once I got the python code running it didn't take long to figure out what was happening. In the end it turned out to be fairly simple, the gnu-Octave I'm using thinks infinity > sqrt(5), as do I, but Matlab and Python think otherwise. Well actually it's the way the respective programs handle numerical overflow. There are regions on the map that begin with |z|>2, so not surprisingly when you keep repetitively squaring this you soon get a numerical overflow, (((2^2)^2)^2)^…, it only takes about 10 iterations to exceed even a double precision floating point capability. When this happens Octave returns "+inf" for the absolute value, while matlab and python return "nan" (not a number). So that's it. All the lovely shading that Greenprint (and his matlab textbook) have been getting in their images have been purely the result of bad programming and a glitch in the way the matlab handles numerical overflow.
|
| Aug7-11, 06:40 PM | #56 |
|
|
Ah, thanks.
Numpy has a hack around for the overflow that (efficiently) forces NaN's to zeros: http://www.scipy.org/Numpy_Example_L...21e560ab316ef3 So that Code:
...
z = z**2 + c
z = np.nan_to_num(z)
a = np.where(np.abs(z)>sqrt5)
map[a] = k
...
|
| Aug11-11, 03:42 PM | #57 |
|
|
Python-Numpy comparison with Matlab:
http://www.scipy.org/NumPy_for_Matlab_Users |
| New Reply |
| Thread Tools | |
Similar Threads for: MATLAB - Image Processing - Douday's rabbit fractal
|
||||
| Thread | Forum | Replies | ||
| Image Processing | Science Textbook Discussion | 2 | ||
| Image Processing | Programming & Comp Sci | 4 | ||
| Matlab Image Processing Help (Image Segmentation) | Math & Science Software | 1 | ||
| Matlab Image Processing. | Math & Science Software | 1 | ||
| image processing matrix image rotation | Engineering, Comp Sci, & Technology Homework | 1 | ||