Skip to content

pydemo/overlay

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Overlay of 2 images of different sizes.

bg = r'in\Gergiev_art_helps_putin_to_kill.JPG'
ov = r'in\gergiev_is_war_supporter.JPG'
out = r'out\Gergiev_art_helps_putin_to_kill_gergiev_is_war_supporter.JPG'

Background image

Background

Foreground image

Foreground

Get images width/height

b_h, b_w, b_ch = background.shape

o_h, o_w, o_ch = overlay.shape

Scale background image

    W = 800
    imgScale = W/b_w
    new_b_h,new_b_w = int(b_h*imgScale), int(b_w*imgScale)
    new_background = cv2.resize(background,(new_b_w, new_b_h))

Overlay 2 images

    #OVERLAY
    OPACITY = 0.7
    added_image = cv2.addWeighted(new_background,0.6,square,0.4,0)
    cv2.imshow('adjusted', added_image)  
    cv2.waitKey()
    cv2.imwrite(out, added_image)

Overlay image

test

About

Overlay 2 images using python and OpenCV

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages