I've a closed contour region on an image. How to fill it up with white color? Not sure whats the Julia function for fillpoly(..)? Thanks
black background img with thin white circle, contour=findall(img.>0) img_With_contour_filled_with_white=..
code:
using Images
img = load("img.png")
function fill_poly!(img::Matrix{RGB{N0f8}})
bit_cols = all.(==(RGB(1., 1., 1.)), eachcol(img)) .== 0
idx_cols = findall(bit_cols)
f = findfirst.(!=(RGB(1., 1., 1.)), eachcol(img[:, bit_cols]))
l = findlast.(!=(RGB(1., 1., 1.)), eachcol(img[:, bit_cols]))
foreach(x->img[x[1]:x[2], x[3]].=RGB(0., 0., 0.), zip(f, l, idx_cols))
end;
fill_poly!(img)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.