1 year ago

#250666

test-img

Dark_Soul07

How to calculate mean and standard deviation of an image file

I'm new to coding environment, I'm working in an imaging processing project - I have a video file of n size and I'm trying to find a mean and standard deviation of (Height, width and number of frames)that file . the image file(imgfile_500) is in MAT

here is my code

public class Image_conv {

public static void main(String[] args) {

    System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
    String filePath = "C:\\Video_500.h264";
   
    if (!Paths.get(filePath).toFile().exists()){
        System.out.println("File " + filePath + " does not exist!");
        return;
    }

    VideoCapture video500 = new VideoCapture(filePath);


    if (!video500.isOpened()) {
        System.out.println("Error! video500 can't be opened!");
        return;
    }


    int ntime=20;
    int fps= 60;
    int ds_fac=4;
    int nf = (ntime*fps);

    int wd_ds = 480/ds_fac;
    int hg_ds = 640/ds_fac;
  

    int vsize = wd_ds*hg_ds*nf;


    Mat frame = new Mat(480,640,CvType.CV_64FC3);
    Mat frame500 = new Mat(480,640,CvType.CV_64FC3);
    Mat imgfile_500 = new Mat();

    if (video500.isOpened()) {
    while(true){
        if (video500.read(frame))
        {
            Imgproc.cvtColor(frame, frame500, Imgproc.COLOR_RGB2GRAY);
            //System.out.println(frame500.size());

            Imgproc.pyrDown( frame500, frame500, new Size( frame500.cols()/2, frame500.rows()/2 ) );
            Imgproc.pyrDown( frame500, frame500, new Size( frame500.cols()/2, frame500.rows()/2 ) );
          // Imgcodecs.imwrite(i+"led500.jpg", frame500);
          


        // Push a Mat back into MatVector
            imgfile_500.push_back(frame500);
        }else break;
    }
    }

    //System.out.println(imgfile_500.size());

   }

}

java

image-processing

mean

standard-deviation

0 Answers

Your Answer

Accepted video resources