python openCV debayer -


i want debayer 16bit raw still image opencv, have problems cvtcolor function. color gray gives correct result this:

import cv2 import numpy np     infile = '/media/rainer/img_2806.jpg'  img = cv2.imread(infile,1) bw = cv2.cvtcolor(img, cv2.color_bgr2gray) resized = cv2.resize(bw, (0,0), fx=0.3, fy=0.3) cv2.imshow('image',resized) cv2.waitkey(0) cv2.destroyallwindows() 

so how debayer in python 2.7? not working:

infile = '/media/rainer/test.raw'  img = cv2.imread(infile,0) debayer = cv2.cvtcolor(img, cv2.cv_bayerbg2bgr) resized = cv2.resize(debayer, (0,0), fx=0.3, fy=0.3) cv2.imshow('image',resized) cv2.waitkey(0) cv2.destroyallwindows() 

thx lot help....

the problem opencv doesn't know data type , size of raw image trying load. have specify through numpy, since opencv arrays numpy arrays in python. try this: import numpy np imsize = imrows*imcols open(infile, "rb") rawimage: img = np.fromfile(rawimage, np.dtype('u1'), imsize).reshape((imrows, imcols)) colour = cv2.cvtcolor(img, cv2.color_bayer_bg2bgr)

use np.dtype('u2') 16 bpp images. note need cv2.color_bayer_bg2bgr instead of cv2.cv_bayerbg2bgr.


Comments

Popular posts from this blog

php - SPIP: From Tag directly to an article -

jquery - isAjaxRequest always return false -

ruby on rails - In a controller spec, how to find a specific tag in the generated view? -