Code Monkey home page Code Monkey logo

autocracks's Introduction

AutoCracks

My solution of AutoCracks Marathon Match.

Information

Solution

1. Independent processing for each z-level.

  1. Extract skeleton using skimage.morphology.skeletonize function. Initial image Blurred image Binarized blurred image Skeleton
  2. Find joints between cracks as pixels with 3 or more neighbors. Skeleton with joint areas
  3. Build a graph of cracks connected by joints. Separate skeleton parts
  4. Merge cracks adjacent to each joint by a greedy algorithm. We repeatedly find a pair of cracks with the biggest angle until there are no more cracks that we can join Direction vectors for cracks adjacent to the joints Skeleton parts after merging lined cracks
  5. Assign a label to each pixel from the initial images as the label of the nearest non-joint point of the skeleton. Final result for the layer

2. Merging results for all z-levels.

After the previous step each layer has its own independent set of crack labels. I describe a procedure of merging labels for two layers and then we apply this procedure sequentially to all layers.
Clearly background pixels are always labeled as 0 and their labels do not need to be merged.
I will operate with two layers: the previous and the current one. I assume that the previous layer already has the final labels and we need to assign this labels to the current layer. We will process each labeled area from the current layer separately.
I considered 3 possible options:

  1. A high percentage (let’s say 90%) of points with the new label had the same label on the previous layer. In this case I mark all pixels with this label on the current layer by the label from the previous layer.
  2. Most of the points (let’s say 50%) in the area had some label at the previous layer but there is no clear majority. In this case I assigned labels to a pixel from the area as a label of the closest labeled pixel on the previous layer.
  3. Otherwise we need to create new unique clack label that was not used in the previous layer and assign this label to all pixels from the area.

3. Additional tricks.

  1. Described earlier procedure of merging layers is prone to the bad labeling of the first layer so I used averaged first 50 layers as the initial layer.
  2. skimage.morphology.skeletonize yields weird curves near joints so it’s better to ignore some area around joints for calculating crack direction vectors.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.