Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Getting the std deviation of multiple pictures using Opencv

I'm trying to get the standard deviationof multiple pictures using, OpenCV, here what I've done :

 #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 =273;
const int width  = 1920;
const int height = 1080;
cv::Mat resultframe = cv::Mat::zeros(height,width,CV_32FC3);
cv::Mat deviationframe = cv::Mat ::zeros(height,width,CV_32FC3);
for(int i = 1 ; i<= count; i++){
//int i = 3;
sprintf(filename,"d:\\BMdvideos\\images\\image%d.tiff",i);
frame = imread(filename,CV_LOAD_IMAGE_COLOR);
frame.convertTo(frame32f,CV_32FC3 );

// cout << " frame type " << frame.type() << endl; //imshow(" frame32f" , frame32f); resultframe +=frame32f; //cout<< "rows number " << frame.rows<< std::endl; //cout<<"column number " << frame.cols<<std::endl; cout="" &lt;&lt;="" "="" i=" &lt;&lt; i&lt;&lt;endl; frame.release(); } resultframe *= (1.0/count/255); for(int j =1; j&lt; count; j++){ sprintf(filename," d:\bmdvideos\images\image%d.tiff",j);="" frame="imread(filename,CV_LOAD_IMAGE_COLOR);" frame.convertto(frame32f,cv_32fc3);="" deviationframe="(frame32f" -="" resultframe);="" deviationframe="deviationframe.mul(deviationframe);" }="" deviationframe="deviationframe" (count="" -1="" );<="" p="">

cv::sqrt(deviationframe,deviationframe);
//deviationframe *= (1.0/255); doesn't change anything ? ? 
imshow("mean ",resultframe);
imshow("deviation frame ",deviationframe);
waitKey(0);
return 0;

}

when I see what I get the resultframe"mean value " is correct but the std deviation is just wrong. any idea what I'm doing wrong, thanks in advance for help

Getting the std deviation of multiple pictures using Opencv

I'm trying to get the standard deviationof deviation of multiple pictures using, OpenCV, here what I've done :

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

using namespace std;
 using namespace cv;

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

// cout //cout << " frame type " << frame.type() << endl; //imshow(" frame32f" , frame32f); resultframe +=frame32f; //cout<< "rows number " << frame.rows<< std::endl; //cout<<"column number " << frame.cols<<std::endl; cout="" &lt;&lt;="" "="" i=" &lt;&lt; i&lt;&lt;endl; frame.cols<<std::endl; cout << " i = " << i<<endl; frame.release(); } resultframe *= (1.0/count/255); for(int j =1; j&lt; j< count; j++){ sprintf(filename," d:\bmdvideos\images\image%d.tiff",j);="" frame="imread(filename,CV_LOAD_IMAGE_COLOR);" frame.convertto(frame32f,cv_32fc3);="" deviationframe="(frame32f" -="" resultframe);="" deviationframe="deviationframe.mul(deviationframe);" }="" deviationframe="deviationframe" (count="" -1="" );<="" p="">

sprintf(filename,"d:\\BMdvideos\\images\\image%d.tiff",j);
        frame = imread(filename,CV_LOAD_IMAGE_COLOR);
        frame.convertTo(frame32f,CV_32FC3);
        deviationframe =(frame32f - resultframe);
        deviationframe= deviationframe.mul(deviationframe);
    }
    deviationframe = deviationframe /(count -1 );

    cv::sqrt(deviationframe,deviationframe);
 //deviationframe *= (1.0/255); doesn't change anything ? ? 
 imshow("mean ",resultframe);
 imshow("deviation frame ",deviationframe);
 waitKey(0);
 return 0;
}

}

when I see what I get the resultframe"mean value " result frame "mean value" is correct but the std deviation is just wrong. any idea what I'm doing wrong, thanks in advance for helphelp.