May Day card¶
Connect everything you need, upload the base and text.
In [ ]:
Pkg.add(["ImageShow"])
In [ ]:
using FileIO, Images, ImageShow
In [ ]:
basis = load("$(@__DIR__)/basis.png")
Out[0]:
In [ ]:
text = load("$(@__DIR__)/text.png")
Out[0]:
The dimensions don't match. :(
In [ ]:
print(string(size(channelview(text))) * " != " * string(size(channelview(basis))))
Let's make the sizes of the images equal and prepare them for overlaying each other.
In [ ]:
new_basis = channelview(basis)
c_basis = zeros(3,size(new_basis,1),size(new_basis,2))
for i in 1:3
c_basis[i,:,:] = new_basis
end
text_new = imresize(text, ratio=2)
text_new = imresize(text_new, size(channelview(text),2)-150, size(c_basis,3))
x = (size(c_basis,2)-size(channelview(text_new),2))
arr_zero = RGB.(zeros(x,size(c_basis,3)))
text_new = [text_new; arr_zero]
c_text = channelview(text_new)
c_text = c_text[1:3,:,:]
c_text[c_text.>0.999999999].=0.0;
print(string(size(c_text)) * " = " * string(size(c_basis)))
Let's perform the overlay.
In [ ]:
postcard = c_basis*0.75 + c_text*0.25
postcard = RGB.(postcard[1,:,:], postcard[2,:,:], postcard[3,:,:])
Out[0]:
Let's add red colour in the holiday spirit!
In [ ]:
с_postcard = channelview(postcard)
postcard = RGB.(с_postcard[1,:,:]*2,с_postcard[2,:,:],с_postcard[3,:,:])
Out[0]:
Save so you don't lose our cool card!
In [ ]:
save("postcard.jpg", postcard)
Out[0]: