Skip to content

Commit

Permalink
Fix #31: correct graph cut
Browse files Browse the repository at this point in the history
  • Loading branch information
juliohm committed Apr 28, 2022
1 parent df0d798 commit f0aa756
Show file tree
Hide file tree
Showing 7 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/graphcuts.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@ function boykov_kolmogorov_cut(A::AbstractArray{T,N}, B::AbstractArray{T,N}, dim
end

# fill edges from source terminal to left slice
linds = CartesianIndices(ntuple(i -> i == dim ? 1 : (1:sz[i]), N))
linds = CartesianIndices(ntuple(i -> i == dim ? (1:1) : (1:sz[i]), N))
for ind in linds
u = cart2lin(sz, ind)
add_edge!(G, s, u)
C[s,u] = Inf
end

# fill edges from right slice to sink terminal
rinds = CartesianIndices(ntuple(i -> i == dim ? sz[dim] : (1:sz[i]), N))
rinds = CartesianIndices(ntuple(i -> i == dim ? (sz[dim]:sz[dim]) : (1:sz[i]), N))
for ind in rinds
v = cart2lin(sz, ind)
add_edge!(G, v, t)
Expand Down
Binary file modified test/data/GeoStatsAPI.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/data/RealsStoneWall.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/data/RealsStrebelle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/data/VoxelStoneWall.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/data/VoxelWalkerLake.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ datadir = joinpath(@__DIR__,"data")
@test all(C[:,2:end] .== 0)

# TI = geostatsimage("StoneWall")
# img = reshape(TI[:Z], 200, 200)
# img = asarray(TI, :Z)
# A = img[1:50,1:30]
# B = img[1:50,11:40]
# C = ImageQuilting.boykov_kolmogorov_cut(A, B, 1)
Expand Down

0 comments on commit f0aa756

Please sign in to comment.