Example #1
0
void AppearanceMat::AllCuesMat(InputArray src1, InputArray src2, InputArray src3, OutputArray dst) {

	addWeighted(src1, 0.33, src2, 0.33, 0, dst);
	addWeighted(dst, 1.0, src3, 0.33, 0, dst);
	applyColorMap(dst, dst, COLORMAP_JET);

}
Example #2
0
	void HazeRemove::showTransmissionMap(Mat& dest, bool isPseudoColor)
	{
		Mat temp;
		tmap.convertTo(temp, CV_8U, 255);
		if (!isPseudoColor)cvtColor(temp, dest, CV_GRAY2BGR);
		else applyColorMap(temp, dest, 2);
	}
void GlyphVisualization::visualize(bool blend, const Simulation*, const ColorMap* pColorMap) const
{
  if (blend)
    {
      glEnable(GL_BLEND);
      glBlendFunc(GL_SRC_ALPHA, GL_ONE);
      glDisable(GL_DEPTH_TEST);
    }
  else
    {
      glDisable(GL_BLEND);
      glEnable(GL_DEPTH_TEST);
    }

  assert(pColorMap);

  const std::vector<VectorGridItem>& vectorGrid = _pVectorGrid->getGrid();
  const std::vector<ScalarGridItem>& scalarGrid = _pScalarGrid->getGrid();

  int n = (int)vectorGrid.size();
  for (int i = 0; i < n; i++)
    {
      GlyphTexture* pGlyphTexture = dynamic_cast<GlyphTexture*>(_pGlyph);
      if (pGlyphTexture == NULL)
        {
          float scalar = _pScalarNormalizer->normalize(scalarGrid[i].scalar);
          applyColorMap(pColorMap, scalar);
        }
      else
        {
          pGlyphTexture->setDeltaY(_deltaY);
        }
      const VectorGridItem& item = vectorGrid[i];

      vec2f origin = item.origin;
      origin[0] *= _deltaX;
      origin[0] += .5f * _deltaX;
      origin[1] *= _deltaY;
      origin[1] += .5f * _deltaX;
      vec2f dest = item.vector;
      dest *= _scaleFactor / 2.0f;

      // clamp
      float radius = std::min(_deltaX, _deltaY);
      if (_clamp && dest.magnitude() > radius)
        {
          dest *= (radius / dest.magnitude());
        }

      _pGlyph->draw(origin, dest);
    }

  glDisable(GL_BLEND);
  glEnable(GL_DEPTH_TEST);
}
void VisualContactCatadioptric::computeTTC(){
    // variables initialized in each processing loop, memory management taken care of
    // by itself?
    float f1, f2, f;

    cv_ptr->image.copyTo(gray);

    ttc_matrix_.height = gray.rows;
    ttc_matrix_.width = gray.cols;

    if( !prevgray.empty() )
    {
        cv::calcOpticalFlowFarneback(prevgray, gray, uflow, GF_pyr_scale_, GF_levels_, GF_winsize_, GF_iterations_, GF_poly_n_, GF_poly_s_, 0);

        cv::cvtColor(prevgray, cflow, cv::COLOR_GRAY2BGR);
        uflow.copyTo(flow);
        drawOptFlowMap(cv::Scalar(0, 255, 0));

        for (int ii=0; ii<uflow.rows; ii++){
            for (int jj=0; jj<uflow.cols; jj++){
                f1 = -uflow.at<cv::Vec2f>(ii,jj)[0]/(jj-u0);
                f2 = uflow.at<cv::Vec2f>(ii,jj)[1]/(ii-v0);
                f = 1/(f2+f1);

                if (!( isinf(f) | isnan(f) ) ){
                    ttcMap.at<float>(ii,jj) = abs(f);
                }

                ttc_matrix_.array.push_back(ttcMap.at<float>(ii,jj));

            }
        }

        cv::Mat adjMap;

        ttcMap.convertTo(adjMap, CV_8UC1, 255.0/TTC_disp_scale_);

        applyColorMap(adjMap, falseColorsMap, cv::COLORMAP_JET);
    }
    // why swap, could just copy gray to prevgray, right?
    std::swap(prevgray, gray);
}
inline void argus_depth::debug_detected_user(){
	cv::circle(rect_mat_left,user.left_marker,3,cv::Scalar(0,255,0),-2);
	cv::circle(rect_mat_left,user.right_marker,3,cv::Scalar(0,0,255),-2);
	std::stringstream ss;
	ss<<user.human_position;
	cv::putText(rect_mat_left,ss.str(),user.human_center,1,1,cv::Scalar(255,10,10),2);

	cv::Mat user_frame = cv::Mat::zeros(rect_mat_left.rows, 2*rect_mat_left.cols, CV_8UC3);
	//cv::Mat ROI1 = user_frame(user.body_bounding_rect);
	cv::Mat ROI1 = user_frame(cv::Rect(0,0,rect_mat_left.cols,rect_mat_left.rows));
	cv::Mat ROI2 = user_frame(user.body_bounding_rect + cv::Point(rect_mat_left.cols,0));

	(rect_mat_left).copyTo(ROI1);
	applyColorMap(user.disparity_viewable(user.body_bounding_rect), ROI2, cv::COLORMAP_JET);

	//	cv::Mat test_frame = rect_mat_left.clone();

	//	imshow("test",test_frame);
	imshow("detected user", user_frame);
}
Example #6
0
void LabelView::proc(QString path,QString *fealist)
{
    for(int i=0;i<NUM;i++)
    {
        normalize(images[i],images[i],0,255,NORM_MINMAX,CV_64FC1,Mat());
        // Interpolation
        resize(images[i],images[i],Size(LEN,LEN));

        images[i].convertTo(images[i],CV_8UC1);
        // colormap
        applyColorMap(images[i], colorImg[i], COLORMAP_JET);

//        QString path = "E:/ViewPoint/dragon/"+fealist[i]+".jpg";
        QString path0 = path+fealist[i]+".jpg";
//        cvSaveImage(path.toStdString().c_str(),&(IplImage(colorImg[i])));
        imwrite(path0.toStdString().c_str(),colorImg[i]);

        cvtColor(colorImg[i],colorImg[i],CV_BGR2RGB);
    }

}
int Depth_and_Disparity::do_stereo_match(Mat imgR, Mat imgL , Mat& disp8 )
{
	ready_disparity_result  = false;	// runover current unused previous result. if any.
	/* 
		when calibrated and saving matrices - i calibrated 
			Left camera as img1 , 
			Right camera as img2
	*/
	img1 = imgL.clone();
	img2 = imgR.clone(); 

	// scale if image sizes are different then calibrated images resultion
 /*   if (scale != 1.f)
    {
        Mat temp1, temp2;
        int method = scale < 1 ? INTER_AREA : INTER_CUBIC;
        resize(img1, temp1, Size(), scale, scale, method);
        img1 = temp1;
        resize(img2, temp2, Size(), scale, scale, method);
        img2 = temp2;
    }*/

    Size img_size = img1.size();

    if( intrinsic_filename )
    {
		/* passed to init function
        stereoRectify( M1, D1, M2, D2, img_size, R, T, R1, R2, P1, P2, Q, CALIB_ZERO_DISPARITY, -1, img_size, &roi1, &roi2 );

        initUndistortRectifyMap(M1, D1, R1, P1, img_size, CV_16SC2, map11, map12);
        initUndistortRectifyMap(M2, D2, R2, P2, img_size, CV_16SC2, map21, map22);*/

        remap(img1, img1r, map11, map12, INTER_LINEAR);
        remap(img2, img2r, map21, map22, INTER_LINEAR);

        img1 = img1r;
        img2 = img2r;

		rectification_output_vars.imageSize					= img_size;
		rectification_output_vars.rectR						=	img2;
		rectification_output_vars.rectL						=	img1;
		rectification_output_vars.validROI1					=	roi1;
		rectification_output_vars.validROI2					=	roi2;
		rectification_output_vars.originalyGivenframeCycle	=	relevantframeCycleIndex;
				
    }


    Mat		disp;

    int64	t = getTickCount(); 

    if( alg == STEREO_BM ){
		// connversion not needed because already gray and UINT8
		//img1.convertTo(img1, CV_8UC1+CV_BGR2GRAY);
		//img2.convertTo(img2, CV_8UC1+CV_BGR2GRAY);
		
        bm->compute(img1, img2, disp);
		}
    else if( alg == STEREO_SGBM || alg == STEREO_HH )
        sgbm->compute(img1, img2, disp);

    t = getTickCount() - t;
  ////
	printf("STEREO_BM/STEREO_SGBM Time elapsed: %fms\n\n", t*1000/getTickFrequency());

    //	disp = disp.colRange(numberOfDisparities, img1p.cols);
    if( alg != STEREO_VAR )
        disp.convertTo(disp8, CV_8U, 255/(numberOfDisparities*16.));
    else
        disp.convertTo(disp8, CV_8U);

    if( !no_display )
    {
        namedWindow("disparity", 0);   imshow("disparity", disp8);
		Mat tmpD ;
			applyColorMap(disp8,tmpD, cv::COLORMAP_JET);
			namedWindow("disparity Heat", 1);   imshow("disparity Heat", tmpD); 
       /// fflush(stdout); 
        printf("\n");
    }
	
    if(disparity_filename)
        imwrite(disparity_filename, disp8);

	{
		///http://stackoverflow.com/questions/27374970/q-matrix-for-the-reprojectimageto3d-function-in-opencv
///#ifndef COMPILING_ON_ROBOT
		if (1==2)		
		{
			Mat xyz_again;
			///Q.at<double>(3,2) = Q.at<double>(3,2)       ;////10.0;
			reprojectImageTo3D(disp, xyz_again, Q, true); 
			Vec3f point_middle = xyz_again.at<Vec3f>(xyz_again.rows/2, xyz_again.cols/2);
			printf("\n\n middle point relative coor. are: %f %f %f \n\n", point_middle.val[0],point_middle.val[1],point_middle.val[2]);
		}
///#endif
	}

	ready_disparity_result  = true;

    return 0;
}
Example #8
0
int calc_max_thr (unsigned char * data, int n, int m, int nt, int img_type, int type_size)
{
	Mat img_max_gauss, img_gauss_max, img_max;
	Mat imgc_max_gauss, imgc_gauss_max, imgc_max;

	img_max.create (n, m, CV_8UC1);
	img_max.setTo (0);
	img_gauss_max.create (n, m, CV_8UC1);
	img_gauss_max.setTo (0);

	for (int i = 0; i < nt; i++) {
		Mat img (n, m, img_type, data + i * n * m * type_size);
		img = min (img, 400);
		double minVal, maxVal;
		minMaxLoc (img, &minVal, &maxVal); //find minimum and maximum intensities
		img.convertTo (img, CV_8U, 255.0 / (maxVal - minVal), -minVal * 255.0 / (maxVal - minVal));

		img_max = max (img, img_max);
		GaussianBlur (img, img, cv::Size (3, 3), 1.0, 1.0);
		img_gauss_max = max (img, img_gauss_max);
	}

	GaussianBlur (img_max, img_max_gauss, cv::Size (3, 3), 1.0, 1.0);

	applyColorMap (img_max, imgc_max, COLORMAP_JET);
	applyColorMap (img_max_gauss, imgc_max_gauss, COLORMAP_JET);
	applyColorMap (img_gauss_max, imgc_gauss_max, COLORMAP_JET);

	//int x = (int)string (matfilename).find ('.');
	//string file_name = string (matfilename).substr (0, x);
	//CreateDirectory (file_name.c_str (), 0);
	//CreateDirectory ((file_name + "\\Max").c_str (), 0);

	//string path = matfiledir + "\\" + file_name + "\\Max";

	/*imwrite (path + "\\" + "1_max__" + file_name + ".bmp", img_max);
	imwrite (path + "\\" + "2_max_gauss__" + file_name + ".bmp", img_max_gauss);
	imwrite (path + "\\" + "3_gauss_max__" + file_name + ".bmp", img_gauss_max);

	imwrite (path + "\\" + "1_max_jet__" + file_name + ".bmp", imgc_max);
	imwrite (path + "\\" + "2_max_gauss_jet__" + file_name + ".bmp", imgc_max_gauss);
	imwrite (path + "\\" + "3_gauss_max_jet__" + file_name + ".bmp", imgc_gauss_max);
	*/
	Mat img_max_thr, img_max_gauss_thr, img_gauss_max_thr;

	my_threshold (img_max, img_max_thr);
	my_threshold (img_max_gauss, img_max_gauss_thr);
	my_threshold (img_gauss_max, img_gauss_max_thr);

	/*imwrite (path + "\\" + "1_max_thr_100__" + file_name + ".bmp", img_max_thr);
	imwrite (path + "\\" + "2_max_gauss_thr_100__" + file_name + ".bmp", img_max_gauss_thr);
	imwrite (path + "\\" + "3_gauss_max_thr_100__" + file_name + ".bmp", img_gauss_max_thr);

	my_threshold (img_max, img_max_thr, true);
	my_threshold (img_max_gauss, img_max_gauss_thr, true);
	my_threshold (img_gauss_max, img_gauss_max_thr, true);

	imwrite (path + "\\" + "1_max_thr_otsu__" + file_name + ".bmp", img_max_thr);
	imwrite (path + "\\" + "2_max_gauss_thr_otsu__" + file_name + ".bmp", img_max_gauss_thr);
	imwrite (path + "\\" + "3_gauss_max_thr_otsu__" + file_name + ".bmp", img_gauss_max_thr);*/
	return 0;
}
Example #9
0
int showImages (unsigned char *data, int n, int m, int nt)
{
	Mat img_max_gauss, img_gauss_max, img_max_bm3d, img_max;
	Mat imgc_max_gauss, imgc_gauss_max, imgc_max_bm3d, imgc_max;

	Mat img_max_gauss_canny, img_gauss_max_canny, img_max_bm3d_canny, img_max_canny;
	Mat imgc_max_gauss_canny, imgc_gauss_max_canny, imgc_max_bm3d_canny, imgc_max_canny;

	Mat img_max_gauss_watershed, img_gauss_max_watershed, img_max_bm3d_watershed, img_max_watershed;

	img_max.create (n, m, CV_8UC1);
	img_max.setTo (0);
	img_gauss_max.create (n, m, CV_8UC1);
	img_gauss_max.setTo (0);

	for (int i = 0; i < nt; i++) {
		
		/*Mat img (n, m, imgtype, data + i * n * m), grayImg;
		img = min (img, 400);
		double minVal, maxVal;
		minMaxLoc (img, &minVal, &maxVal); //find minimum and maximum intensities
		img.convertTo (img, CV_8U, 255.0 / (maxVal - minVal), -minVal * 255.0 / (maxVal - minVal));

		img_max = max (img, img_max);
		GaussianBlur (img, img, cv::Size (3, 3), 1.0, 1.0);
		img_gauss_max = max (img, img_gauss_max);*/
	}

	GaussianBlur (img_max, img_max_gauss, cv::Size (3, 3), 1.0, 1.0);

	applyColorMap (img_max, imgc_max, COLORMAP_JET);
	applyColorMap (img_max_gauss, imgc_max_gauss, COLORMAP_JET);
	applyColorMap (img_gauss_max, imgc_gauss_max, COLORMAP_JET);

	//while (true) {
	//scanf ("%lf %lf", &lowThreshold, &uppThreshold);

	//do_canny (img_max, img_max_canny);
	//do_canny (img_gauss_max, img_gauss_max_canny);
	/*img_max_watershed.create (n, m, CV_32SC1);
	img_max_watershed.setTo (0);*/
	//ex_watershed (imgc_max);
	//watershed (img_gauss_max, img_gauss_max_watershed);

	//GaussianBlur (img_max, img_max_gauss, cv::Size (9, 9), 1.0, 1.0);
	//do_canny (img_max_gauss, img_max_gauss_canny);
	//watershed (img_max_gauss, img_max_gauss_watershed);
	/*

	imshow ("0. bm3d 1. max 2. jet", imgc_max);


	imshow ("0. bm3d 1. max 2. gauss: 3. jet", imgc_max_gauss);


	imshow ("0. bm3d 1. gauss 2. max: ", imgc_gauss_max);
	*/

	// Canny view
	/*
	imshow ("1. max 2. canny", img_max_canny);
	imshow ("1. max 2. gauss 3. canny", img_max_gauss_canny);
	imshow ("1. gauss 2. max 3. canny ", img_gauss_max_canny);
	*/
	/*double minVal, maxVal;
	img_max_watershed += 1;
	minMaxLoc (img_max_watershed, &minVal, &maxVal);
	Mat imgc_watershed;
	img_max_watershed.convertTo (imgc_watershed, CV_8U, 255.0 / (maxVal - minVal), -minVal * 255.0 / (maxVal - minVal));*/
	//applyColorMap (imgc_watershed, imgc_watershed, COLORMAP_JET);

	// Watershed view
	//imshow ("1. max 2. watershed", imgc_watershed);
	/*imshow ("1. max 2. gauss 3. watershed", img_max_gauss_watershed);
	imshow ("1. gauss 2. max 3. watershed ", img_gauss_max_watershed);*/
	//int key = waitKey ();
	//}
	//int x = (int)string (matfilename).find ('.');
	//string file_name = string (matfilename).substr (0, x);
	//CreateDirectory (file_name.c_str (), 0);
	//CreateDirectory (, 0);
	//fs::create_directories ((file_name + "\\Max"));

	//string path = matfiledir + "\\" + file_name + "\\Max";
	//file_name = "";
	Mat img_thresh;
	//threshold (img_max, img_thresh, threshold_value, threshold_max_value, THRESH_TOZERO | CV_THRESH_OTSU);
	//imshow ("some", img_max);	
	imshow ("max thr", img_thresh);
	//threshold (img_max_gauss, img_thresh, 0, threshold_max_value, THRESH_TOZERO | CV_THRESH_OTSU);
	imshow ("max gauss thr", img_thresh);
	//threshold (img_gauss_max, img_thresh, 0, threshold_max_value, THRESH_TOZERO | CV_THRESH_OTSU);
	imshow ("gauss max thr", img_thresh);
	/*
	imwrite (path + "\\" + "1_max__" + file_name + ".bmp", img_max);
	imwrite (path + "\\" + "2_max_gauss__" + file_name + ".bmp", img_max_gauss);
	imwrite (path + "\\" + "3_gauss_max__" + file_name + ".bmp", img_gauss_max);

	imwrite (path + "\\" + "1_max_jet__" + file_name + ".bmp", imgc_max);
	imwrite (path + "\\" + "2_max_gauss_jet__" + file_name + ".bmp", imgc_max_gauss);
	imwrite (path + "\\" + "3_gauss_max_jet__" + file_name + ".bmp", imgc_gauss_max);

	Mat img_max_thr, img_max_gauss_thr, img_gauss_max_thr;

	my_threshold (img_max, img_max_thr);
	my_threshold (img_max_gauss, img_max_gauss_thr);
	my_threshold (img_gauss_max, img_gauss_max_thr);

	imwrite (path + "\\" + "1_max_thr__" + file_name + ".bmp", img_max_thr);
	imwrite (path + "\\" + "2_max_gauss_thr__" + file_name + ".bmp", img_max_gauss_thr);
	imwrite (path + "\\" + "3_gauss_max_thr__" + file_name + ".bmp", img_gauss_max_thr);
	*/
	/*// Canny save
	imwrite (path + "\\" + "1_max_canny__" + file_name + ".bmp", img_max_canny);
	imwrite (path + "\\" + "2_max_gauss_canny__" + file_name + ".bmp", img_max_gauss_canny);
	imwrite (path + "\\" + "3_gauss_max_canny__" + file_name + ".bmp", img_gauss_max_canny);*/

	int key = waitKey ();

	destroyAllWindows ();
	return 0;
}
Example #10
0
void CDlgMaxValue::SetInput(const cv::Mat& maxValue, int imageWidth, int imageHeight)
{
	applyColorMap(maxValue, m_maxValue, cv::COLORMAP_JET);
	InvalidateRect(NULL);
}
Example #11
0
	void HazeRemove::showDarkChannel(Mat& dest, bool isPseudoColor)
	{
		if (!isPseudoColor)cvtColor(dark, dest, CV_GRAY2BGR);
		else applyColorMap(dark, dest, 2);
	}