在 Julia 中为图像制作框架

Make a frame to an image in Julia

图像表示为矩阵。有没有一种实用的方法可以围绕图像的内容制作某种框架? (单色)

using Images, TestImages, Colors

img = testimage("mandrill")

padarray(img, Fill(colorant"magenta", (40, 40), (40, 40)))

更新

我不明白您的评论 - 但您可能会问如何将此填充图像用作普通图像?一种方法是 parent.

img_with_pretty_frame = 
    padarray(img, Fill(colorant"magenta", (40, 40), (40, 40)))

w, h = size(img_with_pretty_frame)

img2 = parent(img_with_pretty_frame)

img2[w ÷ 2 - 100:w ÷ 2 + 100, h÷2 - 200:h÷2 + 200] .= colorant"blue"

img2