RGBA to grayscale + (Optical Flow)

7 views
Skip to first unread message

Virginia Rutten

unread,
Jan 19, 2019, 5:43:25 PM1/19/19
to Bonsai
Dear Goncalo and Bonsai Users, 

Please please help if you have a second.

In short I am trying to find the region in a film which exhibits the largest 'motion' (e.g.: lungs/heart when you're standing still).

My plan was to get the dense optical flow of the image sequence then threshold and then do 'region of interest identification'.
The dense optical flow returns a CV32_S of same size to the original image. I would like first to grayscale it however it is a RGBA image and thus 'grayscale' doesn't work. I tried to write my own python script (see below), however I don't know how to import cvCvtColor. Any ideas?
It would be great to have a toggle on the grayscale option to be able to convert RGBA images. 

Also, I would only like to caculate this region based on e.g.: the first 100 frames. And then just use this region as calculating a dense flow is very expensive it seems (a sparse flow here is not an option).

I would be hugely grateful for any help or advice,

Many thanks,

Virginia


import clr
clr.AddReference("OpenCV.Net")
from OpenCV.Net import *
from math import isnan
from math import pi
from System import Array


@returns(IplImage)
def process(input):
    imHSV = cvCreateImage(cvGetSize(input), IPL_DEPTH_8U,4)
    HSVimage = cvCvtColor(input, imHSV, CV_BGRA2HSV)
    return HSVimage
Reply all
Reply to author
Forward
0 new messages