Skip to content

Commit 0abb4eb

Browse files
committed
Improve linkpair and coverage
1 parent 4d22ee1 commit 0abb4eb

File tree

2 files changed

+25
-15
lines changed

2 files changed

+25
-15
lines changed

ext/CounterMarkingImageViewExt.jl

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,23 @@ using ImageSegmentation
66
using ImageView
77
using Random
88

9-
function colorize(seg, segidxs::AbstractSet{Int}, color::Colorant)
10-
label = seg.image_indexmap
11-
img = similar(label, promote_type(typeof(color), valtype(seg.segment_means)))
12-
fill!(img, zero(eltype(img)))
13-
for idx in eachindex(label)
14-
label[idx] segidxs || continue
15-
img[idx] = color
16-
end
17-
return img
18-
end
9+
# function colorize(seg, segidxs::AbstractSet{Int}, color::Colorant)
10+
# label = seg.image_indexmap
11+
# img = similar(label, promote_type(typeof(color), valtype(seg.segment_means)))
12+
# fill!(img, zero(eltype(img)))
13+
# for idx in eachindex(label)
14+
# label[idx] ∈ segidxs || continue
15+
# img[idx] = color
16+
# end
17+
# return img
18+
# end
1919

2020
function linkpair(img, imgc)
21-
gd = imshow(img)
22-
zr = gd["roi"]["zoomregion"]
23-
slicedata = gd["roi"]["slicedata"]
24-
gdc = imshow(imgc, nothing, zr, slicedata)
25-
return (gd, gdc)
21+
zr, slicedata = roi(img)
22+
gd = imshow_gui((800, 800), (2,1); slicedata=slicedata)
23+
imshow(gd["frame"][1,1], gd["canvas"][1,1], img, nothing, zr, slicedata)
24+
imshow(gd["frame"][2,1], gd["canvas"][2,1], imgc, nothing, zr, slicedata)
25+
return gd
2626
end
2727

2828
# For visualization
@@ -34,4 +34,7 @@ end
3434
CounterMarking.randshow(seg; kwargs...) = imshow(map(i->get_random_color(i), labels_map(seg)); kwargs...)
3535
CounterMarking.meanshow(seg; kwargs...) = imshow(map(i->segment_mean(seg, i), labels_map(seg)); kwargs...)
3636

37+
CounterMarking.randshow(img, seg; kwargs...) = linkpair(img, map(i->get_random_color(i), labels_map(seg)); kwargs...)
38+
CounterMarking.meanshow(img, seg; kwargs...) = linkpair(img, map(i->segment_mean(seg, i), labels_map(seg)); kwargs...)
39+
3740
end

test/runtests.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@ using Test
1414
@eval using ImageView
1515
dct = meanshow(seg)
1616
@test haskey(dct, "gui")
17+
dct = randshow(seg)
18+
@test haskey(dct, "gui")
19+
dct = randshow(img, seg)
20+
@test haskey(dct, "window")
21+
dct = meanshow(img, seg)
22+
@test haskey(dct, "window")
23+
ImageView.closeall()
1724

1825
spotdict, stimulus = spots(seg)
1926
_, stimspot = stimulus

0 commit comments

Comments
 (0)