Ejemplo n.º 1
0
void guiTools::on_checkbutton_median3D_clicked() {
	m_CheckButton_Median.set_active(false);
	m_CheckButton_Bilateral.set_active(false);
	m_CheckButton_Morphological.set_active(false);
	m_medianFiter3D = !m_medianFiter3D;
	if(m_medianFiter3D)	{
		m_CheckButton_Median3D.set_active(true);
	}
	setSpatialFilter();
}
Ejemplo n.º 2
0
void guiTools::on_checkbutton_morphological_clicked() {
	m_CheckButton_Median.set_active(false);
	m_CheckButton_Gauss.set_active(false);
	m_CheckButton_Bilateral.set_active(false);
	m_morphologicalFilter = !m_morphologicalFilter;
	if(m_morphologicalFilter) {
		m_CheckButton_Morphological.set_active(true);
	}
	setSpatialFilter();
}
Ejemplo n.º 3
0
void guiTools::on_checkbutton_gauss_auto_sigma_clicked() {
	bool manualSigma = m_CheckButton_Gauss_Auto_Sigma.get_active();
	if(manualSigma) {
		m_sigmaGauss = frameProcessor->calcGaussianSigma(m_kernelRadiusGauss);
		m_HScale_Gauss_Sigma.set_value(m_sigmaGauss);
		m_HScale_Gauss_Sigma.set_sensitive(true);
		m_Label_Gauss_Auto_Sigma.set_sensitive(true);
	} else {
		m_sigmaGauss = -1.0;
		m_HScale_Gauss_Sigma.set_value(frameProcessor->calcGaussianSigma(m_kernelRadiusGauss));
		m_HScale_Gauss_Sigma.set_sensitive(false);
		m_Label_Gauss_Auto_Sigma.set_sensitive(false);
	}
	setSpatialFilter();
}
Ejemplo n.º 4
0
/**
 * colorMagnify	-	color magnification
 *
 */
void VideoProcessor::colorMagnify()
{
    // set filter
    setSpatialFilter(GAUSSIAN);
    setTemporalFilter(IDEAL);

    // create a temp file
    createTemp();

    // current frame
    cv::Mat input;
    // output frame
    cv::Mat output;
    // motion image

    cv::Mat motion;
    // temp image
    cv::Mat temp;

    // video frames
    std::vector<cv::Mat> frames;
    // down-sampled frames
    std::vector<cv::Mat> downSampledFrames;
    // filtered frames
    std::vector<cv::Mat> filteredFrames;

    // concatenate image of all the down-sample frames
    cv::Mat videoMat;
    // concatenate filtered image
    cv::Mat filtered;

    // if no capture device has been set
    if (!isOpened())
        return;

    // set the modify flag to be true
    modify = true;

    // is processing
    stop = false;

    // save the current position
    long pos = curPos;

    // jump to the first frame
    jumpTo(0);

    // 1. spatial filtering
    while (getNextFrame(input) && !isStop()) {
        input.convertTo(temp, CV_32FC3);
        frames.push_back(temp.clone());
        // spatial filtering
        std::vector<cv::Mat> pyramid;
        spatialFilter(temp, pyramid);
        downSampledFrames.push_back(pyramid.at(levels-1));
        // update process
        std::string msg= "Spatial Filtering...";
        emit updateProcessProgress(msg, floor((fnumber++) * 100.0 / length));
    }
    if (isStop()){
        emit closeProgressDialog();
        fnumber = 0;
        return;
    }
    emit closeProgressDialog();

    // 2. concat all the frames into a single large Mat
    // where each column is a reshaped single frame
    // (for processing convenience)
    concat(downSampledFrames, videoMat);

    // 3. temporal filtering
    temporalFilter(videoMat, filtered);

    // 4. amplify color motion
    amplify(filtered, filtered);

    // 5. de-concat the filtered image into filtered frames
    deConcat(filtered, downSampledFrames.at(0).size(), filteredFrames);

    // 6. amplify each frame
    // by adding frame image and motions
    // and write into video
    fnumber = 0;
    for (int i=0; i<length-1 && !isStop(); ++i) {
        // up-sample the motion image        
        upsamplingFromGaussianPyramid(filteredFrames.at(i), levels, motion);
	resize(motion, motion, frames.at(i).size());
        temp = frames.at(i) + motion;
        output = temp.clone();
        double minVal, maxVal;
        minMaxLoc(output, &minVal, &maxVal); //find minimum and maximum intensities
        output.convertTo(output, CV_8UC3, 255.0/(maxVal - minVal),
                  -minVal * 255.0/(maxVal - minVal));
        tempWriter.write(output);
        std::string msg= "Amplifying...";
        emit updateProcessProgress(msg, floor((fnumber++) * 100.0 / length));
    }
    if (!isStop()) {
        emit revert();
    }
    emit closeProgressDialog();

    // release the temp writer
    tempWriter.release();

    // change the video to the processed video
    setInput(tempFile);

    // jump back to the original position
    jumpTo(pos);
}
Ejemplo n.º 5
0
/** 
 * motionMagnify	-	eulerian motion magnification
 *
 */
void VideoProcessor::motionMagnify()
{
    // set filter
    setSpatialFilter(LAPLACIAN);
    setTemporalFilter(IIR);

    // create a temp file
    createTemp();

    // current frame
    cv::Mat input;
    // output frame
    cv::Mat output;

    // motion image
    cv::Mat motion;

    std::vector<cv::Mat> pyramid;
    std::vector<cv::Mat> filtered;

    // if no capture device has been set
    if (!isOpened())
        return;

    // set the modify flag to be true
    modify = true;

    // is processing
    stop = false;

    // save the current position
    long pos = curPos;
    // jump to the first frame
    jumpTo(0);

    while (!isStop()) {

        // read next frame if any
        if (!getNextFrame(input))
            break;

        input.convertTo(input, CV_32FC3, 1.0/255.0f);

        // 1. convert to Lab color space
        cv::cvtColor(input, input, CV_BGR2Lab);

        // 2. spatial filtering one frame
        cv::Mat s = input.clone();
        spatialFilter(s, pyramid);

        // 3. temporal filtering one frame's pyramid
        // and amplify the motion
        if (fnumber == 0){      // is first frame
            lowpass1 = pyramid;
            lowpass2 = pyramid;
            filtered = pyramid;
        } else {
            for (int i=0; i<levels; ++i) {
                curLevel = i;
                temporalFilter(pyramid.at(i), filtered.at(i));
            }

            // amplify each spatial frequency bands
            // according to Figure 6 of paper            
            cv::Size filterSize = filtered.at(0).size();
            int w = filterSize.width;
            int h = filterSize.height;

            delta = lambda_c/8.0/(1.0+alpha);
            // the factor to boost alpha above the bound
            // (for better visualization)
            exaggeration_factor = 2.0;

            // compute the representative wavelength lambda
            // for the lowest spatial frequency band of Laplacian pyramid
            lambda = sqrt(w*w + h*h)/3;  // 3 is experimental constant

            for (int i=levels; i>=0; i--) {
                curLevel = i;

                amplify(filtered.at(i), filtered.at(i));

                // go one level down on pyramid
                // representative lambda will reduce by factor of 2
                lambda /= 2.0;
            }
        }

        // 4. reconstruct motion image from filtered pyramid
        reconImgFromLaplacianPyramid(filtered, levels, motion);

        // 5. attenuate I, Q channels
        attenuate(motion, motion);

        // 6. combine source frame and motion image
        if (fnumber > 0)    // don't amplify first frame
            s += motion;

        // 7. convert back to rgb color space and CV_8UC3
        output = s.clone();
        cv::cvtColor(output, output, CV_Lab2BGR);
        output.convertTo(output, CV_8UC3, 255.0, 1.0/255.0);

        // write the frame to the temp file
        tempWriter.write(output);

        // update process
        std::string msg= "Processing...";
        emit updateProcessProgress(msg, floor((fnumber++) * 100.0 / length));
    }
    if (!isStop()){
        emit revert();
    }
    emit closeProgressDialog();

    // release the temp writer
    tempWriter.release();

    // change the video to the processed video 
    setInput(tempFile);

    // jump back to the original position
    jumpTo(pos);
}
Ejemplo n.º 6
0
void guiTools::on_combo_morphological_kerneltype_changed() {
	m_kernelTypeMorphological = m_Combo_Morphological_Kerneltype.get_active_row_number();
	setSpatialFilter();
}
Ejemplo n.º 7
0
void guiTools::on_spinbutton_morphological_radius_value_changed() {
	m_kernelRadiusMorphological = m_SpinButton_Morphological_Radius.get_value_as_int();
	setSpatialFilter();
}
Ejemplo n.º 8
0
void guiTools::on_checkbutton_morphological_masked_clicked() {
	setSpatialFilter();
}
Ejemplo n.º 9
0
bool guiTools::on_slider_bilateral_sigma_space_change_value(Gtk::ScrollType type, double value) {
	m_sigmaBilateralColor = value;
	setSpatialFilter();
	return true;
}
Ejemplo n.º 10
0
void guiTools::on_spinbutton_bilateral_radius_value_changed() {
	m_kernelRadiusBilateral = m_SpinButton_Bilateral_Radius.get_value_as_int();
	setSpatialFilter();
}
Ejemplo n.º 11
0
bool guiTools::on_slider_gauss_sigma_change_value(Gtk::ScrollType type, double value) {
	m_sigmaGauss = value;
	setSpatialFilter();
	return true;
}
Ejemplo n.º 12
0
void guiTools::on_spinbutton_gauss_radius_value_changed() {
	m_kernelRadiusGauss = m_SpinButton_Gauss_Radius.get_value_as_int();
	m_HScale_Gauss_Sigma.set_value(frameProcessor->calcGaussianSigma(m_kernelRadiusGauss));
	setSpatialFilter();
}
Ejemplo n.º 13
0
void guiTools::on_checkbutton_median3D_masked_clicked() {
	setSpatialFilter();
}
Ejemplo n.º 14
0
void guiTools::on_spinbutton_median_radius_value_changed() {
	m_kernelRadiusMedian = m_SpinButton_Median_Radius.get_value_as_int();
	setSpatialFilter();
}