Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add the Chan-Vese Segmentation for Gray #84
base: master
Are you sure you want to change the base?
add the Chan-Vese Segmentation for Gray #84
Changes from 1 commit
96ceac3
982cfc4
9996e09
7e3828d
9e07ebc
6395478
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now I see where you are getting the 3d handling from: it's not actually 3d, it's your color channel. This is almost never needed in JuliaImages; just use the image as provided, and if you've written everything generically it should "just work." That is, for a grayscale image
c₁
will be a number orGray
, but for RGBc₁
will be an RGB. And then you can truly support both 2d and 3d images by writing your code in a manner that generalizes across dimensions. So much easier than how other languages do these things, no?Keep in mind that Python and Julia have reversed "fast axes" for their arrays (Python has its fastest axis last, Julia first), but that in fact the memory layout is the same. Consequently, in Julia if you do call
channelview
on an RGB image, the color channel is first, not last.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you want a raw numerical array, then just:
But generally, we encourage directly handling
Array{<:Colorant}
withoutchannelview
because it permits more generic implementation as Tim said in the previous comment.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would recommend deleting this line and the
minimum
/maximum
standardization unless there is strong reason to keep it. Other languages may have done this just to commonize amongUInt8
images (ranging from 0:255),UInt16
images (ranging from 0:65535), andFloat32
/Float64
images (ranging from 0 to 1). But thanks toN0f8
andN0f16
, we've already done that. I think it's better to accept the image at face value.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this standardization needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
About standardization, I think a standardized image may contribute to a segmentation algorithm since it makes the gray levels of image more dispersive. If the grey levels of image range from 0.2 to 0.8, it seems better to standardize image so that the grey levels will range from 0.0 to 1.0.
The test of
chan_vese
use a resized64*64 cameraman
as the test image, whose grey levels range from 0.02 to 0.988. The standardization has showed that it will cause some difference :Test image shows as following:
We can find that there are some difference. Without standardization, the part between the man's leg can't be segmented well. So maybe we have to maintain the standardization?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can introduce a keyword
normalize=false
to control this behavior. And we can also refer to ImageContrastAdjustment in the docstring for more complicated normalization workflows.By hardcoding the standardization in the implementation we lose some possibilities. In many similar cases, we prefer to let the caller rather than the callee do the work. See also https://docs.julialang.org/en/v1/manual/style-guide/#Handle-excess-argument-diversity-in-the-caller
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Presumably that is easily compensated by changing the values of
λ
. The only place in the mathematics where the image magnitude means anything is theλ*sum(abs2, img[componentmask] .- componentmean)
. So anything you can do by standardizing the image, you can do more quickly by adjustingλ
. Alternatively, you can adjustμ
since only the ratio of the terms really matters for the final result.What does standardization even mean for an image with RGB pixels? Do you take the min & max across channels too? Why does the magnitude of the blue channel scale the magnitude of the red one? Aren't these independent pieces of information? Conversely, if my raw image has almost no diversity in the green channel, I'll be really surprised if standardization on the green channel converts something that is perceptually insignificant into something that drives the segmentation.
Basically, there isn't an answer to such questions. So it's better to the let the user be in charge.