Review your favorite Linux distribution.
 Home Forums HCL Reviews Tutorials Articles Register Search Today's Posts Mark Forums Read
 LinuxQuestions.org Interlacing two images using numpy
 User Name Remember Me? Password
 Programming This forum is for all programming questions. The question does not have to be directly related to Linux and any language is fair game.

Notices

 03-29-2013, 01:48 PM #1 Nabeel Member   Registered: Nov 2009 Location: Pakistan Distribution: Ubuntu Posts: 294 Rep: Interlacing two images using numpy Well I need help completing this interlacing function that takes two images and alternates their rows into a new image. I tried doing som Code: ```import sys, os import numpy as np import cv2 def interlace(evens, odds): '''Reconstruct the image by alternating rows of evens and odds. evens - a numpy array of shape (rows, columns, 3) containing the even rows of the output image. odds - a numpy array of shape (rows, columns, 3) containing the odd rows of the output image. This function should return an image. Row 0 of the output image should be row 0 of evens. Row 1 of the output image should be row 0 of odds. Then row 1 of evens, then row 1 of odds, and so on. The resulting image will have as many rows as image 1 and 2 combined, equal to both in number of columns, and have 3 channels. ''' i=0 outimg = np.zeros([800,600] , 'uint8') # Implement your function here --------------------------------------------- while i <= (len(evens) + len(odds)): outimg[2*i] = evens[i] outimg[2*i + 1] = odds[i] i+=1 #--------------------------------------------------------------------------- return outimg```
 04-03-2013, 12:05 PM #2 thangqd LQ Newbie   Registered: Apr 2013 Location: Vietnam Posts: 1 Rep: Re: Interlacing two images using numpy Code: ```i = 0 outimg = np.zeros((evens.shape[0]*2,evens.shape[1],3),dtype=np.uint8) while i <(evens.shape[0]): outimg[i*2] = evens[i] outimg[i*2+1] = odds[i] i+=1``` Last edited by thangqd; 04-03-2013 at 12:11 PM.

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is Off HTML code is Off Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post Dsw0002 Linux - Software 2 04-25-2011 07:11 PM JohnLocke Linux - Newbie 0 04-24-2007 11:29 PM khdubya Programming 3 02-03-2007 05:27 PM arw_opencv Linux - Hardware 3 12-03-2006 08:43 AM cultavix Linux - Hardware 0 01-12-2005 08:01 AM

LinuxQuestions.org

All times are GMT -5. The time now is 09:21 PM.

 Contact Us - Advertising Info - Rules - LQ Merchandise - Donations - Contributing Member - LQ Sitemap -