JuliaImages / ImageDistances.jl

Distances between N-dimensional images
https://github.com/JuliaImages/Images.jl
Other
15 stars 8 forks source link

Add Color support (fixes #16) #19

Closed johnnychen94 closed 5 years ago

johnnychen94 commented 5 years ago

The following distances supports Color3 image input:

By default, each pixel is treated as a 3d point. If we want to calculate the channelwise distances, we can channelview(a) first.

As for other distances:

juliohm commented 5 years ago

Thank you Johnny for the improvements. Just make sure that hausdorff supports N dimensional images. It is not restricted to 2D.

Best,

On Sat, May 4, 2019, 08:55 Johnny Chen notifications@github.com wrote:

The following distances supports Color3 image input:

  • SqEuclidean
  • Euclidean
  • Cityblock
  • Minkowski
  • Hamming
  • TotalVariation

By default, each pixel is treated as a 3d point. If we want to calculate the channelwise distances, we can channelview(a) first.

  • Hausdorff distance supports Gray2dimage{Bool}
  • CIEDE distance for AbstractArray{<:Number} type inputs is restricted to 2d array, which is regarded as Gray image.

You can view, comment on, or merge this pull request online at:

https://github.com/JuliaImages/ImageDistances.jl/pull/19 Commit Summary

  • rename gray image test references
  • add Color support

File Changes

Patch Links:

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/JuliaImages/ImageDistances.jl/pull/19, or mute the thread https://github.com/notifications/unsubscribe-auth/AAZQW3OYSIUPPGAUEMJGLP3PTV2TLANCNFSM4HKYXNZA .

codecov[bot] commented 5 years ago

Codecov Report

Merging #19 into master will decrease coverage by 1.71%. The diff coverage is 52.94%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #19      +/-   ##
==========================================
- Coverage   65.26%   63.55%   -1.72%     
==========================================
  Files           5        5              
  Lines          95      107      +12     
==========================================
+ Hits           62       68       +6     
- Misses         33       39       +6
Impacted Files Coverage Δ
src/ImageDistances.jl 50% <ø> (ø) :arrow_up:
src/generic.jl 87.8% <0%> (-6.94%) :arrow_down:
src/ciede2000.jl 90% <100%> (+18.57%) :arrow_up:
src/metrics.jl 55.55% <50%> (-44.45%) :arrow_down:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update ebb962d...0f68eff. Read the comment docs.

johnnychen94 commented 5 years ago

Hausdorff distance is quite generic as a distance between sets, but will that makes sense to images? My question is: how do we interpret 3d Gray{Bool} Images?

juliohm commented 5 years ago

It is defined for point sets in N dimensions. In 2D the points are the black pixels. In 3D the points are the black voxels. Makes sense?

On Sat, May 4, 2019, 09:11 Johnny Chen notifications@github.com wrote:

Hausdorff distance is quite generic as a distance between sets, but will that makes sense to images? My question is: how do we interpret 3d Gray{Bool} Images?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/JuliaImages/ImageDistances.jl/pull/19#issuecomment-489321452, or mute the thread https://github.com/notifications/unsubscribe-auth/AAZQW3MUV6MQ7UQ3ETXYF2LPTV4NTANCNFSM4HKYXNZA .

juliohm commented 5 years ago

If you are asking about the image type then we need to use a type that supports the idea of 3 axes and then each entry is a bool value. I'm not up to date with the image types at the moment.

On Sat, May 4, 2019, 09:22 Júlio Hoffimann julio.hoffimann@gmail.com wrote:

It is defined for point sets in N dimensions. In 2D the points are the black pixels. In 3D the points are the black voxels. Makes sense?

On Sat, May 4, 2019, 09:11 Johnny Chen notifications@github.com wrote:

Hausdorff distance is quite generic as a distance between sets, but will that makes sense to images? My question is: how do we interpret 3d Gray{Bool} Images?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/JuliaImages/ImageDistances.jl/pull/19#issuecomment-489321452, or mute the thread https://github.com/notifications/unsubscribe-auth/AAZQW3MUV6MQ7UQ3ETXYF2LPTV4NTANCNFSM4HKYXNZA .

johnnychen94 commented 5 years ago

my concern is that the third channel of AbstractArray{Gray{Bool}, 3} can have any of the following meanings:

So I think it's better to let potential 3D-image-processing packages to do this job. How do you think?

juliohm commented 5 years ago

I need hausdorff in 3D in my use cases. Please do not constrain the algorithm at this point. If there is an issue regarding the image types we need to fix it first. I don't see how the semantics would affect the application of the distance. The user will know when it makes sense to call a distance on a 3D image. If any of the axes means something different that is not a spatial coordinate he/she should not call the distance at this point.

On Sat, May 4, 2019, 09:36 Johnny Chen notifications@github.com wrote:

my concern is that the third channel of AbstractArray{Gray{Bool}, 3} can have any of the following meanings:

  • time
  • literally 3D image of 3D object -- Only this makes sense to Hausdorff
  • sample: Vector{Array{Bool, 2}}

So I think it's better to let potential 3D-image-processing packages to do this job. How do you think?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/JuliaImages/ImageDistances.jl/pull/19#issuecomment-489323178, or mute the thread https://github.com/notifications/unsubscribe-auth/AAZQW3IMYDVSPLWISDP6SC3PTV7NLANCNFSM4HKYXNZA .

johnnychen94 commented 5 years ago

Good point. Other distances have the same issues.

Bad news is these restrictions are made in the last redesign PR (not this one), and it's already tagged a release (v0.2.2)

I'll fix it later and bump a release.

juliohm commented 5 years ago

Thank you. For future reference, it is always a good idea to ask before removing features. I've noticed that you are cleaning up the code which is great. But sometimes it is good to check to see if people need the feature before committing changes.

Cheers

On Sat, May 4, 2019, 09:47 Johnny Chen notifications@github.com wrote:

Good point. Other distances have the same issues.

Bad news is these restrictions are made in the last redesign PR (not this one), and it's already tagged a release (v0.2.2)

I'll fix it later and bump a release.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/JuliaImages/ImageDistances.jl/pull/19#issuecomment-489323961, or mute the thread https://github.com/notifications/unsubscribe-auth/AAZQW3PRLKCOLGTS2XKDGADPTWAW7ANCNFSM4HKYXNZA .

johnnychen94 commented 5 years ago

Sorry for bringing the trouble, didn't notice it.

Another big change is the removal of ImagePreMetric, ImageSemiMetric and ImageMetric.

timholy commented 5 years ago

my concern is that the third channel of AbstractArray{Gray{Bool}, 3} can have any of the following meanings:

We have mechanisms in place for this already:

johnnychen94 commented 5 years ago

Thanks for the explanation,

Vector{Array{Bool, 2}} is just a random collection(batch) of Array{Bool,2} images. Most deep learning frameworks interpret 4-D array with WHCB (width, height, channel, batch) convention.

johnnychen94 commented 5 years ago

I'd like to merge this PR if there's no further feedback since the numerical test says it's good. Then fixes the 3D problem in the next PR.

timholy commented 5 years ago

Vector{Array{Bool, 2}} is just a random collection(batch) of Array{Bool,2} images.

Right. Just saying, that's not really ambiguous because as far as Julia is concerned it's not the same as a 3d array.

Most deep learning frameworks interpret 4-D array with WHCB (width, height, channel, batch) convention.

It would be fine to have a whcb(img) function which puts it in this form, but hard-coded interpretations for specific dimensionalities (or dimensions with particular sizes, as in Matlab's "anything of size 3 must be a color dimension") feels like a 1980s-era hack. GPU programming---which drives deep learning frameworks---is still pretty much using 1980s-era constructs (e.g., native 4D arrays on the GPU, anyone?), though it has improved a lot lately.