Comments (21)
I can do "random cluster nearest neighbor" :))
from neutrallandscapes.jl.
@mkborregaard I think so - exportasciigrid
is something I've done before (readasc
as well) so I'll dig it up.
from neutrallandscapes.jl.
Do you want push access to the org @rafaqz ?
from neutrallandscapes.jl.
Sure. Thanks.
How do you feel about an ImageMorphology.jl dep? It has the label and feature distance methods we need for nearest neighbor algs.
from neutrallandscapes.jl.
Given that this is an end-user-facing package rather than a base package I don't see any issues with taking on deps. It's not exactly lightweight though - does NearestNeighbors.jl not do the trick? - let's continue that discussion under #14
from neutrallandscapes.jl.
@mkborregaard just tried pushing a perlin branch but was denied 🥺
Can someone give me push access?
from neutrallandscapes.jl.
Did you accept the membership invite?
from neutrallandscapes.jl.
You didn't, it seems, it's still listed as "pending"
from neutrallandscapes.jl.
Oops sorry, my github message feed is insane these days
from neutrallandscapes.jl.
What's missing in addition to the algorithms?
- classifyarra0
- blendarrays
- blendclusterarray
- meanofcluster
- exportasciigrid [wontfix]
and that's it, right?
from neutrallandscapes.jl.
ascii
in #26 -- this is exportasciigrid
from neutrallandscapes.jl.
So the last algo remaining is not the most friendly, because we need a sort of image segmentation code for it to work.
from neutrallandscapes.jl.
is that ndimage.measurements.label?
I worked around that function call in _clusterMean
but looking at it I don't think I did it right, so I'll just need to check that code again.
from neutrallandscapes.jl.
It can be solved with a heuristic as a temporary solution. That's nothing more than a constrained label propagation, and this tends to converge in a few iteration. I can try this and see if that performs well.
from neutrallandscapes.jl.
Nice. Yeah I thought it could essentially be done single-pass but maybe I'm not understanding the full complexity of the issue
from neutrallandscapes.jl.
ImageMorphology.jl has this. Maybe just doing that PR to generalise it is less work.
from neutrallandscapes.jl.
So there is very little to it in ImageMorphology... except it uses traits like coords_spatial
from ImageCore.jl. Again not even image related, but lots of image related deps.
It looks like we have to abstract everything not image related out of the Images.jl ecosystem at some stage. I think it's not much work technically and it's even their long-term intention, but getting all the PRs through and package registrations would be a lot of work. But ...someone has to do it some day - these methods are in Numpy, not some python image package.
from neutrallandscapes.jl.
Update: I wasn't understanding the full complexity of the issue.
Anyway, pushing on ImageMorphology sounds like a good idea, if that org catches the ball and start running with it some of us could possibly help? Let's see how responsive they are.
from neutrallandscapes.jl.
I could do most of it honestly, they are really small changes. The main issue is getting agreement on moving the traits out of ImageCore.jl and to somewhere without all those depsendencies.
from neutrallandscapes.jl.
I think the ImageMorphology is the right way to go honestly and it sounds like they are amenable to it. Honestly having them split and then Raf's fast code in Stencils would be a really awesome thing for the ecosystem.
Just because I'm stupid I did find it fun to try and implement a label function myself. I think I succeeded (and that it's OK efficient) - I could put that in a PR for now?
function _label(mat)
rook = ((1, 0), (0, 1))
m, n = size(mat)
(m >= 3 && n >= 3) || error("The label algorithm requires the landscape to be at least 3 cells in each direction")
# initialize objects and fill corners of ret
ret = zeros(Int, m, n)
clusters = Dict{Int, Int}()
label = 0
# run through the matrix and make clusters
for j in axes(mat, 2), i in axes(mat, 1)
same = [i - n[1] > 0 && j - n[2] > 0 && mat[i - n[1], j - n[2]] == mat[i, j] for n in rook]
if count(same) == 0
ret[i, j] = label += 1
clusters[label] = label
else
vals = [ret[i - n[1], j - n[2]] for n in rook[same]]
mi = minimum(vals)
for v in vals
clusters[v] = mi
end
ret[i, j] = mi
end
end
# merge adjacent clusters with same value
ncl = 0
for i in eachindex(ret)
ret[i] = _getval(clusters, ret[i])
ncl = max(ncl, ret[i])
end
ncl, ret
end
function _getval(clusters, val)
while true
val2 = clusters[val]
val2 == val && return val
val = val2
end
end
An example use
a = rand(DistanceGradient(rand(1:100, 3)), 10, 10)
b = classify!(copy(a), ones(4))
nc, c = _label(b)
plot(heatmap(a), heatmap(b), heatmap(c, fillcolor = :picasso), size = (1400, 400), layout = (1,3))
from neutrallandscapes.jl.
that looks like it works - let's PR this and if the ImageMorpho split happens we'll replace it?
from neutrallandscapes.jl.
Related Issues (17)
- Problem with wavesurface
- two abstract types of landscape makers HOT 1
- Euclidean Distance Transform HOT 9
- code organisation HOT 2
- Add voronoi grid HOT 13
- PerlinNoise() requires square matrices? HOT 7
- DiamondSquare and MidpointDisplacement are not rescaled HOT 2
- DiamondSquare warning? HOT 2
- Readme organisation HOT 1
- Tag? HOT 18
- TagBot trigger issue HOT 16
- MethodError: no method matching NearestNeighborCluster(::Float64) HOT 6
- NearestNeighborCluser is broken with :queen HOT 2
- [RFC] adding methods for temporal change in neutral landscapes HOT 3
- `normalize` can't handle NaNs HOT 3
- HaltonSequences is misbehaving HOT 13
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from neutrallandscapes.jl.