可否通过编程为《秘密花园》填充出和谐的颜色?

代码党 10行代码来个糙的。

其实secret garden随便怎么填,只要认真,都挺好看的。

不信?你看!





代码在此。

thresh = threshold_otsu(img)
bw = closing(img > thresh, square(1))
cleared = bw.copy()
clear_border(cleared)
label_image = label(cleared)  # label image regions
borders = np.logical_xor(bw, cleared)
label_image[borders] = -1
colors = np.random.rand(300, 3);
image_label_overlay = label2rgb(label_image, image=img, colors=colors, bg_color=np.random.rand(3))

完整代码:

gist.github.com/haojian
编辑于 2015-12-28 08:45

Published

Category

Zhihu

Tags