{"action":"created","issue":{"url":"https://api.github.com/repos/JuliaImages/Images.jl/issues/765","repository_url":"https://api.github.com/repos/JuliaImages/Images.jl","labels_url":"https://api.github.com/repos/JuliaImages/Images.jl/issues/765/labels{/name}","comments_url":"https://api.github.com/repos/JuliaImages/Images.jl/issues/765/comments","events_url":"https://api.github.com/repos/JuliaImages/Images.jl/issues/765/events","html_url":"https://github.com/JuliaImages/Images.jl/issues/765","id":377123022,"node_id":"MDU6SXNzdWUzNzcxMjMwMjI=","number":765,"title":"move `difftype` to ImageCore","user":{"login":"johnnychen94","id":8684355,"node_id":"MDQ6VXNlcjg2ODQzNTU=","avatar_url":"https://avatars1.githubusercontent.com/u/8684355?v=4","gravatar_id":"","url":"https://api.github.com/users/johnnychen94","html_url":"https://github.com/johnnychen94","followers_url":"https://api.github.com/users/johnnychen94/followers","following_url":"https://api.github.com/users/johnnychen94/following{/other_user}","gists_url":"https://api.github.com/users/johnnychen94/gists{/gist_id}","starred_url":"https://api.github.com/users/johnnychen94/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/johnnychen94/subscriptions","organizations_url":"https://api.github.com/users/johnnychen94/orgs","repos_url":"https://api.github.com/users/johnnychen94/repos","events_url":"https://api.github.com/users/johnnychen94/events{/privacy}","received_events_url":"https://api.github.com/users/johnnychen94/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":6,"created_at":"2018-11-04T05:32:55Z","updated_at":"2018-11-05T13:03:06Z","closed_at":null,"author_association":"NONE","body":"Can we move\r\n`difftype` and etc. in\r\nhttps://github.com/JuliaImages/Images.jl/blob/6b7048a52b8bf9058eefa0b238a4f138c895c983/src/algorithms.jl#L291-L311\r\nto other places such as `ImageCore`\r\n\r\nThese are very basic helpers to handle different value types, seems not belong here.\r\n\r\nI find these really useful to avoid `N0f8` overflow issue (https://github.com/JuliaImages/ImageCore.jl/issues/63) when implement new algorithms. "},"comment":{"url":"https://api.github.com/repos/JuliaImages/Images.jl/issues/comments/435866252","html_url":"https://github.com/JuliaImages/Images.jl/issues/765#issuecomment-435866252","issue_url":"https://api.github.com/repos/JuliaImages/Images.jl/issues/765","id":435866252,"node_id":"MDEyOklzc3VlQ29tbWVudDQzNTg2NjI1Mg==","user":{"login":"johnnychen94","id":8684355,"node_id":"MDQ6VXNlcjg2ODQzNTU=","avatar_url":"https://avatars1.githubusercontent.com/u/8684355?v=4","gravatar_id":"","url":"https://api.github.com/users/johnnychen94","html_url":"https://github.com/johnnychen94","followers_url":"https://api.github.com/users/johnnychen94/followers","following_url":"https://api.github.com/users/johnnychen94/following{/other_user}","gists_url":"https://api.github.com/users/johnnychen94/gists{/gist_id}","starred_url":"https://api.github.com/users/johnnychen94/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/johnnychen94/subscriptions","organizations_url":"https://api.github.com/users/johnnychen94/orgs","repos_url":"https://api.github.com/users/johnnychen94/repos","events_url":"https://api.github.com/users/johnnychen94/events{/privacy}","received_events_url":"https://api.github.com/users/johnnychen94/received_events","type":"User","site_admin":false},"created_at":"2018-11-05T13:03:06Z","updated_at":"2018-11-05T13:03:06Z","author_association":"NONE","body":"I used it in my recent PR [here](https://github.com/JuliaImages/ImageDistances.jl/pull/6)\r\n\r\nThis is useful because according to the nature of `minkowski`, it makes sense to convert everything to `Float` type, so that there's no need to write too many one-line methods to capture all the possible combination of types of input arguments.\r\n\r\n```julia\r\n\"\"\"\r\n    minkowski_p(imgA, imgB, metric::Minkowski)\r\n\r\nminkowski distance to p-th power\r\n\"\"\"\r\nfunction minkowski_p(imgA::AbstractArray, imgB::AbstractArray, metric::Minkowski)\r\n    T = promote_type(difftype(eltype(imgA)), difftype(eltype(imgB))) # Normed -> Float\r\n    imgA = channelview(convert.(T, imgA))\r\n    imgB = channelview(convert.(T, imgB))\r\n    if metric.order == 2\r\n        return reduce(+, abs2.(imgA[:] .- imgB[:]))\r\n    end\r\n    return reduce(+, abs.(imgA[:] .- imgB[:]) .^ metric.order)\r\nend\r\n```\r\n\r\nIn this case, it would be nice to implement a specialized `minkowski_p` that returns a `N0f8`. However, to be honest there's really low priority -- implementation of these do easily makes all the codes a chaos even for a simple algorithm like this.\r\n\r\nPersonally, I want to make my ideas implemented fast by writing a generic function using `channelview` and `difftype`, and then optimize it for `Normed` type if I do have this need."}}
{"actor":{"display_login":"johnnychen94"}}