Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: has anyone tried the side by side function for combining 2 images #2

Open
nitingulati101 opened this issue Jul 23, 2018 · 1 comment

Comments

@nitingulati101
Copy link

I am trying to create the following function but getting an error can someone help
def sidebyside(il,ir):
heightl, widthl = il.shape[:2]
heightr, widthr = ir.shape[:2]

redcl = il[:,:,0]
greencl = il[:,:,1]
bluecl = il[:,:,2]

redcr = ir[:,:,0]
greencr = ir[:,:,1]
bluecr = ir[:,:,2]

newimheight=heightl + heightr
newimwidth=widthl + widthr
newim = zeros((newimheight, newimwidth),uint8)

newim[:,:,0]=redcl
newim[:,:,1]=greencl
newim[:,:,2]=bluecl

return newim
@nitingulati101
Copy link
Author

I was able to solve it but I think there can be a simpler solution. Please suggest you anyone has tried a different approach
def sidebyside(il,ir):
heightl, widthl = il.shape[:2]
heightr, widthr = ir.shape[:2]

redcl = il[:,:,0]
greencl = il[:,:,1]
bluecl = il[:,:,2]

redcr = ir[:,:,0]
greencr = ir[:,:,1]
bluecr = ir[:,:,2]


newimheight=heightl + heightr
newimwidth=widthl + widthr


newim = zeros((newimheight, newimwidth, 3),uint8)
x1=0
y1=0    
newim[x1:heightl,y1:widthl,0]=redcl 
newim[x1:heightl,y1:widthl,1]=greencl
newim[x1:heightl,y1:widthl,2]=bluecl

newim[x1:heightr,widthl:newimwidth,0]=redcr
newim[x1:heightr,widthl:newimwidth,1]=greencr
newim[x1:heightr,widthl:newimwidth,2]=bluecr

 
return newim

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant