I have a python script that reads two tiff images and finds unique combinations, counts the observations and saves the count to a txt file.
You can find the full script in www.spatial-ecology.net
The result is:
tif1
2 2 3
0 0 3
2 3 3
tif2
2 2 3
3 3 4
1 1 1
result
2 2 2
3 3 1
0 3 2
3 4 1
2 1 1
3 1 2
The script works fine. This is how it is implemented.
read line by line (for irows in range(rows):) in order do not load the full image in the memory (eventually a flag option can be insert to read 10 by 10 lines)
go trough the arrays and create a tuple
check if the tuple is already stored in the dic()
My question is: which are the tricks in this case to speed up the process?
I tested to save the results in 2 dimension array rather than dic() but it slow down the process. I check this link and maybe the python map function can improve the speed. Is this the case?
Thanks in advance Giuseppe
numpy. Other than that, you might check out the Python Imaging Library (PIL). Both these libraries are designed to solve these kinds of problems efficiently.