Counting islands in a matrix with periodic boundary conditions

41 Views Asked by At

I am trying to implement a Kinetic Monte Carlo simulation with periodic boundary conditions on Python. I was successful but now I am trying to process the results I've got.

The idea is to create an histogram of the number of the islands with respect to the size of the island. And that's the struggle.

I tried to use skimage.measure.label but it is not taking the periodicity of the image into account. Is there any ways to solve that?

I add as an explanation of what I mean by periodic boundary condition a picture where each islands have different colors and also the result of one of my simulations.

Periodic image with islands of different colors

Result of one of my simulations

I tried to overcome the issue by creating an image where I extended the cells in the two direction but the issue is that an island on a border is counted twice less than an island inside the image. Thinking about it, it makes sense...

I know there is a function dedicated to it in Mathematica (MorphologicalComponents) but I'd rather stay on python.

0

There are 0 best solutions below