D. Sukhov
D. Sukhov

Reputation: 361

Make a frame to an image in Julia

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)

Upvotes: 2

Views: 121

Answers (1)

daycaster
daycaster

Reputation: 2707

using Images, TestImages, Colors

img = testimage("mandrill")

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

magenta mandrill1

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

mod mandrill

Upvotes: 1

Related Questions