[英]How to fill polygon in image
我在圖像上有一個封閉的輪廓區域。 如何用白色填充它? 不確定 fillpoly(..) 的 Julia function 是什么? 謝謝
帶有細白色圓圈的黑色背景 img,contour=findall(img.>0) img_With_contour_filled_with_white=..
代碼:
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)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.