Images are represented as matrices. Is there a practical way to make sort of frame around the content of the image? (in a monoton color)
CodePudding user response:
using Images, TestImages, Colors
img = testimage("mandrill")
padarray(img, Fill(colorant"magenta", (40, 40), (40, 40)))
Update
I don't understand your comment - but you might be asking how you can use this padded image as a normal image? One way is 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