Ask Your Question
1

how to calculate the mean value of multiple pictures

asked 2013-02-13 09:36:17 -0600

engine gravatar image

updated 2013-02-13 09:48:25 -0600

Hi !

I'm trying to get the mean value of multiple pictures with opencv, here is my code :

 #include <opencv2\core\core.hpp>
 #include <opencv2\highgui\highgui.hpp>
 #include <opencv2\opencv.hpp>

  using namespace std;
  using namespace cv;

int main(){
cv::Mat frame,frame32f;
char filename[40];
cv::Mat mean;
const int count =10;
const int width  = 1920;
const int height = 1080;
cv::Mat resultframe = cv::Mat::zeros(height,width,CV_32FC3);
for(int i = 1 ; i<= count; i++){
sprintf(filename,"d:\\BMdvideos\\images\\image%d.tiff",i);
frame = imread(filename,CV_LOAD_IMAGE_COLOR);
frame.convertTo(frame32f,CV_32FC3);
resultframe +=frame32f;
    cout << " i = " << i<<endl;
//frame.release();
}
resultframe *= (1.0/count);

imshow("",resultframe);
waitKey(0);
return 0;
  }

I get a always a white frame in imshow, any idea why do I get this. thanks in advance for your help !

edit retag flag offensive close merge delete

Comments

I think what you meant was "How can I BLEND 10 images". You want the mean value across the 10 images for each pixel.

Antonio gravatar imageAntonio ( 2015-01-08 07:24:22 -0600 )edit

2 answers

Sort by ยป oldest newest most voted
0

answered 2013-02-13 13:54:24 -0600

updated 2013-02-13 13:58:24 -0600

For display float image have to normalize to [0,1].

normalize(resultframe,resultframe,0,1,CV_MINMAX);
edit flag offensive delete link more
0

answered 2013-02-13 10:59:07 -0600

Mahdi gravatar image

Hi,

You should convert your resultframe to a CV_8UC3 before imshow!

edit flag offensive delete link more

Question Tools

Stats

Asked: 2013-02-13 09:36:17 -0600

Seen: 8,155 times

Last updated: Feb 13 '13