Ask Your Question
-1

adding several images

asked Dec 19 '13

mahsa gravatar image

updated Dec 20 '13

is there any way to add several images two each other using opencv?

thanks in advance...

after editing:

 int N;
     cin >> N;
     for(int i=0; i<sen; i++){
        Nframes.push_back(pClose); //pclose is a float pointer which points to the current frame
        if(Nframes.size() == N){
            for(int i=N; i>0; i--){
               Nframes.pop_front();

             //  addWeighted(src1, alpha, src2, beta, gamma, dst, -1);

           }
        }
     }
Preview: (hide)

1 answer

Sort by » oldest newest most voted
1

answered Dec 19 '13

Here's an answer as short as your question

Mat A, B, C;

C= A + B;
Preview: (hide)

Comments

really? so, what is addweighted function?!!

mahsa gravatar imagemahsa (Dec 19 '13)edit

I want to apply medianblur function into a sequence of frames...So, is it possible two add some frames the same as yours, then get the average of them and give it as an input to the medianBlur function?

mahsa gravatar imagemahsa (Dec 19 '13)edit
1

You don't need to add frames before applying the medianBlur function. It works on each frame by assigning each pixel a value which is equal to the median of the values of the neighboring pixels. The number of neighboring pixels considered is based on the kernel size that you pass as a parameter. More details and example code here: http://docs.opencv.org/doc/tutorials/imgproc/gausian_median_blur_bilateral_filter/gausian_median_blur_bilateral_filter.html

pyro gravatar imagepyro (Dec 20 '13)edit

thanks for the comment but what I mean is using some kind of Temporal Filtering..I want to use medianBlur function in temporal domain

mahsa gravatar imagemahsa (Dec 20 '13)edit
1

In that case, you may add the n number of frames and take an average (assuming this is your logic) using the above answer. cv::addWeighted() helps to assign different weights while adding. For example, assigning equal weights of 0.5 to two frames will result in a typical average, whereas weighing one frame higher than another (say 0.3 for Frame1 and 0.7 for Frame 2) would give you a weighted average with 70% of the content in frame 2 appearing in the result. (http://docs.opencv.org/modules/core/doc/operations_on_arrays.html#addweighted)

pyro gravatar imagepyro (Dec 20 '13)edit

Thanks a lot for your help...what I am doing is difficult for me since I am completely newbie. I edited the code, it would be appreciated if you give me some hints on what I am doing..

mahsa gravatar imagemahsa (Dec 20 '13)edit

Question Tools

Stats

Asked: Dec 19 '13

Seen: 323 times

Last updated: Dec 20 '13