JuliaImages / ImageSegmentation.jl

Partitioning images into meaningful regions
Other
47 stars 23 forks source link

Active contours level sets #67

Open Dale-Black opened 3 years ago

Dale-Black commented 3 years ago

I am extremely new to this area but I would like to create a fully automatic image segmentation technique using active contours. The goal is that this could later be used in conjunction with some of the techniques in the realm of SciML to improve on the segmentation given some labeled images. Would this be a good library to start with?

johnnychen94 commented 3 years ago

For the record, @zygmuntszpak has replied in slack:

The ImageSegmentation package currently doesn't have any active contour methods implemented. It might be best to start a separate package. One of the reasons is that we want to move to a more unified API for the Julia Images ecosystem and the ImageSegmentation package kinda still needs to be revamped and updated. It might therefore be cleaner to start a new package focusing on the active contours...

ashwani-rathee commented 3 years ago

@Dale-Black I am also working in medical image segmentation(brain tumor segmentation), would sure like to help in active contour techniques and medical image analysis methods implementations.

Dale-Black commented 3 years ago

Great, let’s connect on the Julia zulip chat!

feanor12 commented 3 years ago

Maybe something like morphsnakes from python would be nice to have. I also think all base functions should be available. I would really like a method which includes a balloon force/term.

johnnychen94 commented 2 years ago

One of the reasons is that we want to move to a more unified API for the Julia Images ecosystem and the ImageSegmentation package kinda still needs to be revamped and updated.

If it helps, the idea is to provide a unified API (e.g., segment) with various implementations wrapped by different structures. For example:

abstract type AbstractSegmentationAlgorithm end
struct ActiveContour <: ABstractSegmentationAlgorithm
    ...
end

alg = ActiveContour(args...)

segs = segment(img, alg)

This design has been adopted by quite a lot of new packages in JuliaImages, including ImageQualityIndexes, ImageBinarization, and ImageContrastAdjustment. And we find it quite clear to implement, explain, and use.

Another question is how do we store the result types and how do we display them. Currently it uses SegmentedImage to store everything you might need, and use segment_* function to display.

I kind of like the terminology of analyze(decomposite) and synthesize(composite) in dictionary learning or signal processing. And this triggers my redesign of SegmentedImage type in my early experiment on SLIC but to be honest I'm not very satisfied with that so it's still a WIP project. Mostly because I don't do segmentation research.

JKay0327 commented 2 years ago

Hello guys, I'm a student from OSPP and glad to find this issue . As a part of my project, I have already implemented the Chan-Vese Segmentation which is a model for active contours in Julia. I've put the demo in my repo: https://github.com/JKay0327/Chan-Vese. Here is a preview for my work: preview

However, as @johnnychen94 has said:

Another question is how do we store the result types and how do we display them. Currently it uses Segmented Image to store everything you might need, and use segment_* function to display.

I'm confused about the result type of the Chan-Vese Segmentation. Curent type SegmentedImage seems not suitable for these active contours algorithms whose results are binary images.

Redesign the ImageSegmentation package seems to be a good idea to solve the problem because maybe we can sperate image segmentation technique using active contours and other algorithms into two parts. But, since I'm not familiar with segmentation tasks, I don't know how much work I can do. However, if there is some suggestions for me, I'll try my best to take a try.

timholy commented 2 years ago

Great to see this!

Curent type SegmentedImage seems not suitable

There's a sense in which Chan-Vese is a "pre-segmentation" technique, in the sense that it may identify multiple disconnected objects. One could call ImageMorphology.label_components (which itself needs modernizing) to create the SegmentedImage.

IMO when the output is boolean/binary, then a boolean-valued array rather than a SegmentedImage is appropriate. I'm about to submit a PR for a flood-fill algorithm that faces the same issue.

the ImageSegmentation package kinda still needs to be revamped and updated

Much of that is underway. Already #73 has done much of it, but there's still more to do.

Dale-Black commented 2 years ago

Hey @JKay0327, this is kind of a side topic but I also reimplemented the exact same algorithm from scikit image in Julia and I had some questions regarding the calculate_variation function. Are you on the Julia Zulip or Slack chat perhaps so I could ping you over there?

JKay0327 commented 2 years ago

@Dale-Black We can chat on Slack :) My id: Yifan Chen

johnnychen94 commented 2 years ago

https://github.com/JuliaImages/juliaimages.github.io/issues/220 A performance note for anyone who tries to migrate codes from MATLAB or Python: in Julia, we don't need to write explicit vectorized codes because the intermediate results are stored as arrays and arrays require memory allocations, which can often become a big overhead.

For this specific example, every line in https://github.com/JKay0327/Chan-Vese/blob/0f165fe7654e0b0fc83d1a94262432077d8379a5/chan_vese.jl#L53-L73 allocates a new memory of size size(𝚽ⁿ).

timholy commented 2 years ago

It also appears to claim to support arbitrary-dimensional arrays, but it looks like it's really only 2d? It does look like a very

Of interest, I'm starting to compare some of our implementations to skimage and Matlab, and in the few I've checked we are blowing everyone out of the water :smile:. (It's not even close...) OpenCV is likely to be a much bigger challenge, but I haven't checked yet.