Ask Your Question
0

Use cv::integral() on multi-channel image?

asked 2018-11-24 09:03:29 -0600

sazr gravatar image

Can you use cv::integral on a BGR Mat? I want to calculate the integral image for each channel. Do I need to split the channels and call cv::integral for each channel or can I just use the function with a 3 channel Mat?

I am currently using this utility class that helps but I'm not sure if its made to handle multichannel Mats?

http://pi-virtualworld.blogspot.com/2...

edit retag flag offensive close merge delete

Comments

what are you trying to achieve here ? what is the context ?

berak gravatar imageberak ( 2018-11-24 09:21:41 -0600 )edit

@berak In a video frame I am sliding a window over a 3 channel image and inspecting the variance under that window. If its above a threshold I perform more operations. Integral images will provide a more efficient and faster way to achieve this than meanStdDev().

sazr gravatar imagesazr ( 2018-11-24 09:23:35 -0600 )edit

do you have to inspect many more than one window ?

checking integral images is cheap, but calculating them is terribly expensive. (do some profiling, you'll see.)

berak gravatar imageberak ( 2018-11-24 09:27:26 -0600 )edit

@berak, thats exactly what I am doing, reimplementing my algorithm using cv::integral instead of meanStdDev() to test if or how much frames per second increase I get.

sazr gravatar imagesazr ( 2018-11-24 09:29:24 -0600 )edit

oh sliding window (i missed that). that's enough checks to justify it, then ;)

berak gravatar imageberak ( 2018-11-24 09:31:31 -0600 )edit

@berak thanks, is that link to an integral image correctly handling/calculating the variance and mean for a 3 channel image? I get some weird results on 3 channel images (like numbers over 100 million).

sazr gravatar imagesazr ( 2018-11-24 09:35:41 -0600 )edit

no idea, how large your image is, and how you check the values

you can also use CV_64F as result type (if you suspect a int32 overflow)

maybe we need to see your code ?

berak gravatar imageberak ( 2018-11-24 09:46:31 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2018-11-24 09:29:29 -0600

berak gravatar image

yes, it is possible to use cv::integral() with multiple channel images, -- the result will have as many channels as the input.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2018-11-24 09:03:29 -0600

Seen: 537 times

Last updated: Nov 24 '18