user3131037
user3131037

Reputation: 473

algorithm, image processing, flood fill

I am trying to process an X-ray image.

canny filter + erosion

The task is to paint each bone to a different color. I've used canny filter,otsu binarization and Morphological Image Processing such as erosion, to get this effect:

canny filter + erosion

Now I need to find an algorithm to color each bone. I was thinking about using connected-component labeling or flood fill but these algorithms requires closed area which will be filled with a color, but in my image there are also "almost closed" area to color. I was trying to "close each bone" with Dilation but it doesn't work.

And now I completely do not know what to do with it and how to color bones.

Upvotes: 4

Views: 966

Answers (2)

FatherOfGold
FatherOfGold

Reputation: 68

While this might not be the exact thing you're looking for, I would recommend a simple edge-finding algorithm. The way I would do this (which may not be the best of the most efficient) is to extract the image into a 2D array of pixels. What you can do is compare the RGB values of each pixel to it's neighboring pixel and then color it a brighter color if the difference is higher. To calculate the difference you can use the 3D version of the 2D pythagorean distance formula. Finding the 'distance' between the RGB values and multiplying it by something to keep the values between 0 and 255, then replacing the pixel which you are comparing to it's surrounding pixels with a pixel with the average of this number for the 8 surrounding pixels.

If this is done correctly, it should produce a result similar to, if not identical to the one you present here.

Upvotes: 0

Martin Perry
Martin Perry

Reputation: 9527

You can try to vectorize your image. I have done something similar and after running simple vectorization, connected components were easy to fill.

You can vectorize directly your input by eg. running Marching Squares on it. It will also create edge image.

Upvotes: 0

Related Questions