void ImageProcessSystem::sharpEffect()
{
	BasisOperation::sharpEffect(srcMat.get(),resultMat.get());
	updateMat();
	updateToolBar();
	updateDisplayImage();
}
void ImageProcessSystem::interactiveLacalEnhencementActionTriggered()
{
	if(interactiveStatus&INTERACTIVE_LOCAL_ENHENCEMENT_SELECTED)
		return;
	if(interactiveHasProduceResult)
	{
		interactiveHasProduceResult=false;
		updateMat();
	}
	interactiveStatus=0;
	interactiveStatus|=INTERACTIVE_LOCAL_ENHENCEMENT_SELECTED;
	delete ImageLabel;
	ImageLabel=new LocalEnhencementLabel(ui.centralWidget);
	initImageLabel();
	((LocalEnhencementLabel *)(ImageLabel))->setParameters(&srcImage,ui.pixelValueLabel,&regionMask.get(),&srcMat.get(),tolerance,featherRadius);
	connect(ImageLabel,SIGNAL(interactiveLocalEnhencementFinished()),this,SLOT(interactiveLocalEnhencementFinishSignalEmit()));
	interactiveOptionWidgetHasInit=true;
	delete interactiveOptionWidget;
	interactiveOptionWidget=new InteractiveLocalEnhencementWidget(ui.centralWidget,(LocalEnhencementLabel *)ImageLabel);
	interactiveOptionWidget->setGeometry(ImageLabel->x()+ImageLabel->width()+10,ImageLabel->y(),240,ImageLabel->height());
	interactiveOptionWidget->setVisible(true);
	interactiveLocalEnhencementConnecting();
	updateToolBar();
	updateDisplayImage();
}
void ImageProcessSystem::automaticLocalEnhencement()
{
	BasisOperation::colorLevel(srcMat.get(),resultMat.get(),0,255,2);
	updateMat();
	updateToolBar();
	updateDisplayImage();
}
void ImageProcessSystem::interactiveColorLevelTriggered()
{
	if(interactiveStatus&INTERACTIVE_COLOR_LEVEL_SELECTED)
		return;
	if(interactiveHasProduceResult)
	{
		interactiveHasProduceResult=false;
		updateMat();
	}
	interactiveStatus=0;
	interactiveStatus|=INTERACTIVE_COLOR_LEVEL_SELECTED;
	delete ImageLabel;
	ImageLabel=new OriginalImageLabel(ui.centralWidget);
	initImageLabel();
	interactiveOptionWidgetHasInit=true;
	delete interactiveOptionWidget;
	interactiveOptionWidget=new InteractiveColorLevelWidget(ui.centralWidget);
	interactiveOptionWidget->setGeometry(ImageLabel->x()+ImageLabel->width()+10,ImageLabel->y(),240,ImageLabel->height());
	interactiveOptionWidget->setVisible(true);
	connect(((InteractiveColorLevelWidget *)interactiveOptionWidget)->redSlider.get(),SIGNAL(valueChanged(int)),this,SLOT(interactiveColorLevelParametersChanged(int)));
	connect(((InteractiveColorLevelWidget *)interactiveOptionWidget)->lightnessSlider.get(),SIGNAL(valueChanged(int)),this,SLOT(interactiveColorLevelParametersChanged(int)));
	connect(((InteractiveColorLevelWidget *)interactiveOptionWidget)->saturationSlider.get(),SIGNAL(valueChanged(int)),this,SLOT(interactiveColorLevelParametersChanged(int)));
	connect(((InteractiveColorLevelWidget *)interactiveOptionWidget)->contrastSlider.get(),SIGNAL(valueChanged(int)),this,SLOT(interactiveColorLevelParametersChanged(int)));
	srcHSVMat.get()=Mat(srcMat->rows,srcMat->cols,CV_32FC3);
	ColorSpaceTransition::rgb2Hsv(srcMat.get(),srcHSVMat.get());
	updateToolBar();
	updateDisplayImage();
}
void ImageProcessSystem::automaticColorCorrection()
{
	if(colorCorrection())
	{
		updateMat();
		updateToolBar();
#ifdef DEBUG
		imshow("result",resultMat.get());
#else
		updateDisplayImage();
#endif
	}
}
void ImageProcessSystem::automaticHighlightRemoval()
{
	highlightDetection();
	srcMat.get().copyTo(resultMat.get());
	HighLightRemoval::removal(srcMat.get(),resultMat.get(),highlightMask.get(),face,HIGHLIGHT_REMOVAL_POSSION_MATHOD);
	updateMat();
	updateToolBar();
#ifdef DEBUG
	imshow("result",resultMat.get());
#else
	updateDisplayImage();
#endif
}
void ImageProcessSystem::interactiveLocalEnhencementFinishSignalEmit()
{
	BasisOperation::qimage2OneChannelMat(((LocalEnhencementLabel *)ImageLabel)->paintMask,INTERACTIVE_PIXEL_VALUE,regionMask.get(),PIXEL_SELECTED_VALUE);
	blur(regionMask.get(),regionMask.get(),Size(featherRadius,featherRadius));
	double x=0.5,y;
	if(((InteractiveLocalEnhencementWidget *)interactiveOptionWidget)->dodgeRadioButton->isChecked())
	{
		y=0.45;
	}
	else
		y=0.55;
	srcMat.get().copyTo(resultMat.get());
	BasisOperation::localEnhencementUsingMappingMethod(resultMat.get(),&regionMask.get(),x,y);
	updateMat();
	updateToolBar();
	updateDisplayImage();
}
void ImageProcessSystem::interactiveTriangleActionTriggered()
{
	if(interactiveStatus&INTERACTIVE_TRIANGLE_SELECTED)
		return;
	if(interactiveHasProduceResult)
	{
		interactiveHasProduceResult=false;
		updateMat();
	}
	interactiveStatus=INTERACTIVE_TRIANGLE_SELECTED;
	delete ImageLabel;
	ImageLabel=new InteractiveTriangleLabel(pointX,pointY,ui.centralWidget);
	initImageLabel();
	((InteractiveTriangleLabel *)ImageLabel)->initDrawingImage();
	updateToolBar();
	updateDisplayImage();
}
void ImageProcessSystem::interactiveMeshEditingActionTriggered()
{
	if(interactiveStatus&INTERACTIVE_MESH_EDITING)
		return;
	if(interactiveHasProduceResult)
	{
		interactiveHasProduceResult=false;
		updateMat();
	}
	interactiveStatus=INTERACTIVE_MESH_EDITING;
	interactiveOptionWidgetHasInit=true;
	delete ImageLabel;
	ImageLabel=new InteractiveMeshEditingLabel(io,symmIO,ui.centralWidget);
	initImageLabel();
	((InteractiveMeshEditingLabel *)ImageLabel)->displayTriangle();
	updateToolBar();
	//updateDisplayImage();
}
void ImageProcessSystem::interactiveFaceActionTriggered()
{
	if(interactiveStatus&INTERACTIVE_FACE_SELECTED)
		return;
	if(interactiveHasProduceResult)
	{
		interactiveHasProduceResult=false;
		updateMat();
		updateDisplayImage();
	}
	interactiveStatus=0;
	interactiveStatus|=INTERACTIVE_FACE_SELECTED;
	delete ImageLabel;
	ImageLabel=new InteractiveFaceLabel(ui.centralWidget);
	initImageLabel();
	((InteractiveFaceLabel *)ImageLabel)->setParameters(&srcImage,ui.pixelValueLabel,&face);
	delete interactiveOptionWidget;
	interactiveOptionWidget=NULL;
	interactiveOptionWidgetHasInit=false;
	updateToolBar();
}
void ImageProcessSystem::interactiveHighlightFinishSignalEmit()
{
	memset(highlightMask.get().data,NOTHIGHLIGHT_PIXEL_VALUE,sizeof(uchar)*highlightMask->rows*highlightMask->cols);
	BasisOperation::qimage2OneChannelMat(((HighLightLabel *)ImageLabel)->paintMask,INTERACTIVE_PIXEL_VALUE,highlightMask.get(),HIGHLIGHT_PIXEL_VALUE);
	unsigned char mode=0;
	if(((InteractiveHighlightWidget *)interactiveOptionWidget)->possionMethodIsChecked())
	{
		//detect face is time-consuming
		face=Rect(1,1,srcMat->cols-1,srcMat->rows-1);
		mode=HIGHLIGHT_REMOVAL_POSSION_MATHOD;
	}
	else
	{
		faceDetectingCombined();
		srcMat.get().copyTo(resultMat.get());
		mode=HIGHLIGHT_REMOVAL_INPAINTING_MATHOD;
	}
	HighLightRemoval::removal(srcMat.get(),resultMat.get(),highlightMask.get(),face,mode);
	updateMat();
	updateToolBar();
	updateDisplayImage();
}
void ImageProcessSystem::interactiveSwitchActionTriggered()
{
	if(interactiveStatus&INTERACTIVE_FACE_SELECTED)
	{
		if(((InteractiveFaceLabel *)ImageLabel)->getFaceStatus())
		{
			memset(faceMask.get().data,NOTFACE_PIXEL_VALUE,srcImage.width()*srcImage.height()*sizeof(uchar));
			faceDetector::detectingFace(srcMat.get(),faceMask.get(),FACE_COLORMODEL,face);
			processStatus|=FACE_DETECTION_DONE;
		}
	}
	interactiveStatus=0;
	delete ImageLabel;
	ImageLabel=new OriginalImageLabel(ui.centralWidget);
	initImageLabel();
	if(interactiveHasProduceResult)
	{
		updateMat();
		interactiveHasProduceResult=false;
	}
	updateToolBar();
	updateDisplayImage();
}
void ImageProcessSystem::interactiveColorCorrectionActionTriggered()
{
	if(interactiveStatus&INTERACTIVE_COLOR_CORRECTION_SELECTED)
		return;
	if(interactiveHasProduceResult)
	{
		interactiveHasProduceResult=false;
		updateMat();
	}
	interactiveStatus=0;
	interactiveStatus|=INTERACTIVE_COLOR_CORRECTION_SELECTED;
	delete ImageLabel;
	ImageLabel=new OriginalImageLabel(ui.centralWidget);
	initImageLabel();
	interactiveOptionWidgetHasInit=true;
	delete interactiveOptionWidget;
	interactiveOptionWidget=new InteractiveColorCorrectionWidget(ui.centralWidget);
	interactiveOptionWidget->setGeometry(ImageLabel->x()+ImageLabel->width()+10,ImageLabel->y(),240,ImageLabel->height());
	interactiveOptionWidget->setVisible(true);
	interactiveColorCorrectionConnecting();
	updateDisplayImage();
	updateToolBar();
}
void ImageProcessSystem::intercativeHighlightActionTriggered()
{
	if(interactiveStatus&INTERACTIVE_HIGHLIGHT_SELECTED)
		return;
	if(interactiveHasProduceResult)
	{
		interactiveHasProduceResult=false;
		updateMat();
		updateDisplayImage();
	}
	interactiveStatus=0;
	interactiveStatus|=INTERACTIVE_HIGHLIGHT_SELECTED;
	delete ImageLabel;
	ImageLabel=new HighLightLabel(ui.centralWidget);
	initImageLabel();
	ImageLabel->setParameters(&srcImage,ui.pixelValueLabel);
	connect(ImageLabel,SIGNAL(interactiveHighlightFinished()),this,SLOT(interactiveHighlightFinishSignalEmit()));
	interactiveOptionWidgetHasInit=true;
	delete interactiveOptionWidget;
	interactiveOptionWidget=new InteractiveHighlightWidget(ui.centralWidget);
	interactiveOptionWidget->setGeometry(ImageLabel->x()+ImageLabel->width()+10,ImageLabel->y(),240,ImageLabel->height());
	interactiveOptionWidget->setVisible(true);
	updateToolBar();
}
void ImageProcessSystem::interacitveColorBalanceTriggered()
{
	if(interactiveStatus&INTERACTIVE_COLOR_BALANCE_SELECTED)
		return ;
	if(interactiveHasProduceResult)
	{
		interactiveHasProduceResult=false;
		updateMat();
	}
	interactiveStatus=INTERACTIVE_COLOR_BALANCE_SELECTED;
	interactiveOptionWidgetHasInit=true;
	delete ImageLabel;
	ImageLabel=new OriginalImageLabel(ui.centralWidget);
	initImageLabel();
	delete interactiveOptionWidget;
	interactiveOptionWidget=new InteractiveColorBalanceWidget(ui.centralWidget);
	interactiveOptionWidget->setGeometry(ImageLabel->x()+ImageLabel->width()+10,ImageLabel->y(),240,ImageLabel->height());
	interactiveOptionWidget->setVisible(true);
	connect(((InteractiveColorBalanceWidget *)interactiveOptionWidget)->redSlider.get(),SIGNAL(valueChanged(int)),this,SLOT(interativeColorBalanceParametersChanged(int)));
	connect(((InteractiveColorBalanceWidget *)interactiveOptionWidget)->greenSlider.get(),SIGNAL(valueChanged(int)),this,SLOT(interativeColorBalanceParametersChanged(int)));
	connect(((InteractiveColorBalanceWidget *)interactiveOptionWidget)->blueSlider.get(),SIGNAL(valueChanged(int)),this,SLOT(interativeColorBalanceParametersChanged(int)));
	updateToolBar();
	updateDisplayImage();
}
Ejemplo n.º 16
0
//--------------------------------------------------------------
void defense::update(){
    
 
    CurrentSlide = keyString[SlideCounter];
    if(VideoIsPlaying == false){
    bool bNewFrame = false;
    vidGrabber.update();
    bNewFrame = vidGrabber.isFrameNew();
	if (bNewFrame){
       colorImg.setFromPixels(vidGrabber.getPixels(), Nx,Ny);
       colorImg.mirror(false, true);
       TheInputRGB = colorImg.getCvImage(); 
       grayImage = colorImg;
       TheInputGray = grayImage.getCvImage();
       cvResize(TheInputGray, HalfInputGray);
    }
    
    }
    
    if ((CurrentSlide.compare("BlockDiagram")==0)&&(InterMode>0)){
        ImageToEllipseList(TheInputGray, 16);
        CoherentEllipses();
        
    }
    

    if ((CurrentSlide.compare("VideoReview")==0)&&(VideoIsPlaying)){
        Mov.idleMovie();
    }
    
    if ((CurrentSlide.compare("VideoNPR")==0)&&(VideoIsPlaying)){
        Mov.idleMovie();
    }
    
    if ((CurrentSlide.compare("RedrawingRegions")==0)&&(InterMode<2)){
        updateMat();
    }
    
    if ((CurrentSlide.compare("RedrawingRegions")==0)&&(InterMode==3)){
    ImgToContours(TheInputGray,14,0);
    } 
    if ((CurrentSlide.compare("RedrawingRegions")==0)&&(InterMode==4)){
        ImgToContours(TheInputGray,8,1);
    } 
    if ((CurrentSlide.compare("EdgesAndLines")==0)&&(InterMode==1)){
        ImgToLineList();
    } 
    
    if ((CurrentSlide.compare("OrientationSlide")==0)||
        (CurrentSlide.compare("SizeSlide")==0)||
        CurrentSlide.compare("ShapeSlide")==0){
        
        NumOfSquares = ofVec2f(64,48);
        
        
//    if ((NumOfSquares.x != (int)(10+(Nx/4-10)*Slider2/127.0))||
//        (NumOfSquares.y != (int)(10+(Ny/4-10)*Slider3/127.0))){
//        NumOfSquares.x = (int)(10+(Nx/4-10)*Slider2/127.0);
//        NumOfSquares.y = (int)(10+(Ny/4-10)*Slider3/127.0);
        Destino = cvCreateImage(cvSize(NumOfSquares.x, NumOfSquares.y), 8, 1);
//    }
        cvResize(TheInputGray, Destino);
    }
    if (CurrentSlide.compare("DensitySlide")==0) {
        NumOfSquares = ofVec2f(128,96);
//        if ((NumOfSquares.x != (int)(10+(Nx/4-10)*Slider2/127.0))||
//            (NumOfSquares.y != (int)(10+(Ny/4-10)*Slider3/127.0))){
//            NumOfSquares.x = (int)(10+(Nx/4-10)*Slider2/127.0);
//            NumOfSquares.y = (int)(10+(Ny/4-10)*Slider3/127.0);
            Destino = cvCreateImage(cvSize(NumOfSquares.x, NumOfSquares.y), 8, 1);
//        }
        cvResize(TheInputGray, Destino);
        DithPointList();
    }
    if (CurrentSlide.compare("Connectedness")==0) {
        NumOfSquares = ofVec2f(128,96);
//        if ((NumOfSquares.x != (int)(10+(Nx/4-10)*Slider2/127.0))||
//            (NumOfSquares.y != (int)(10+(Ny/4-10)*Slider3/127.0))){
//            NumOfSquares.x = (int)(10+(Nx/4-10)*Slider2/127.0);
//            NumOfSquares.y = (int)(10+(Ny/4-10)*Slider3/127.0);
            Destino = cvCreateImage(cvSize(NumOfSquares.x, NumOfSquares.y), 8, 1);
//        }
        cvResize(TheInputGray, Destino);
        DithPointList();
        SortPointsToPlot();
          
    }
    
    
    if (CurrentSlide.compare("Transcoding")==0){
        
        NumOfSquares = ofVec2f(64,48);
        
        
        //    if ((NumOfSquares.x != (int)(10+(Nx/4-10)*Slider2/127.0))||
        //        (NumOfSquares.y != (int)(10+(Ny/4-10)*Slider3/127.0))){
        //        NumOfSquares.x = (int)(10+(Nx/4-10)*Slider2/127.0);
        //        NumOfSquares.y = (int)(10+(Ny/4-10)*Slider3/127.0);
        Destino = cvCreateImage(cvSize(NumOfSquares.x, NumOfSquares.y), 8, 1);
        //    }
        cvResize(TheInputGray, Destino);
    } 
    
    
    
    if(CurrentSlide.compare("NCcir")==0){
        NCCirUpdate();
        CircsFrameCount++;
        if (CircsFrameCount>260){
            CircsFrameCount=1;
        }
    
    }
    
    if (CurrentSlide.compare("NCcirMatched")==0) {
        CirMatched(0);
    }
    if (CurrentSlide.compare("MinMaxcir")==0) {
        CirMatched(1);
    }
    if (CurrentSlide.compare("BottleNeckCir")==0) {
        CirMatched(2);
    } 
    if (CurrentSlide.compare("DirectionFiltCir")==0) {
        CirMatched(3);
    }
    
    if((CurrentSlide.compare("NCcirMatched")==0)||
       (CurrentSlide.compare("MinMaxcir")==0)||
       (CurrentSlide.compare("BottleNeckCir")==0)||
       (CurrentSlide.compare("DirectionFiltCir")==0)){
        
        G_ka = 1.35 + 4*Slider1/127.0;
        G_Dammping = .45 + 4*Slider2/127.0;
        MaxBetweener = 2 + 18*(int)Slider3/127.0;
        BetweenFrames++;
        if(BetweenFrames>=MaxBetweener){
            CircsFrameCount++;
            BetweenFrames=0;
            if (CircsFrameCount>260){
                CircsFrameCount=1;
            }
        }
  
    }
    
    if((CurrentSlide.compare("MeshFlow")==0)||
    (CurrentSlide.compare("ArrowsDraw")==0)){
        
        G_kMesh=4.0 + 4*Slider1/127.0; // elastic constant	
        G_kgMesh=.4*Slider2/127.0; // gradient factor
//        G_kdMesh=.5+4*Slider3/127.0; // drag constant
       G_kdMesh=.05+4*Slider3/127.0; // drag constant  
        MeshFlowUpdate();
    }
    
    
    
    
    if(CurrentSlide.compare("GradientCircs")==0){
    
        CirclesGradientUpdate();
    }
    
    if (CurrentSlide.compare("TargetsAlgorithm")==0) {
        MaxMode =2;
        if(InterMode>MaxMode-1){InterMode=0;} 
        TargetAlgorithmUpdate(InterMode);
    }
    
    
    if (CurrentSlide.compare("EllipwithTarget")==0){
        
        ImageToEllipseList(TheInputGray, 16);
        MaxMode =2;
        if(InterMode>MaxMode-1){InterMode=0;} 
        if (InterMode==1){
            CoherentEllipses();
        }
        
    }
    
    
    if (CurrentSlide.compare("TargetEllipseExample")==0){
    
        ImageToEllipseList(TheInputGray, 16);
        CoherentEllipses();
    
    }
    
    if (CurrentSlide.compare("GoodFeaturesExample")==0) {
        GoodFeaturesUpdate();
    }

    if (CurrentSlide.compare("Mixing")==0){

        NumOfSquares.x = 28;
        NumOfSquares.y = 28;
        
        
            Destino = cvCreateImage(cvSize(NumOfSquares.x, NumOfSquares.y), 8, 1);
        cvResize(TheInputGray, Destino);
    }
    
    
    if ((CurrentSlide.compare("Bagette")==0)){
        ImageToEllipseList(TheInputGray, 16);
        CoherentEllipses();     
    }
  
    if ((CurrentSlide.compare("CaptureSlideJul26")==0)){
        ImageToEllipseList(TheInputGray, 16);
        CoherentEllipses();     
    }
   
    
    
    if (CurrentSlide.compare("Hormigas")==0) {
        HormigasUpdate();
    }
    
    if (CurrentSlide.compare("Tree")==0) {
        TreeUpdate();
    } 
    if (CurrentSlide.compare("TemplateDemo")==0) {
        ofSetFrameRate(12);
        TemplateDemoUpdate();
    }
    if (CurrentSlide.compare("TemplateDemo")!=0){
    ofSetFrameRate(30);
    }
    
   
    
}
Ejemplo n.º 17
0
bool PinholeCameraModel::fromCameraInfo(const sensor_msgs::CameraInfo& msg)
{
  // Create our repository of cached data (rectification maps, etc.)
  if (!cache_)
    cache_ = boost::make_shared<Cache>();
  
  // Binning = 0 is considered the same as binning = 1 (no binning).
  uint32_t binning_x = msg.binning_x ? msg.binning_x : 1;
  uint32_t binning_y = msg.binning_y ? msg.binning_y : 1;

  // ROI all zeros is considered the same as full resolution.
  sensor_msgs::RegionOfInterest roi = msg.roi;
  if (roi.x_offset == 0 && roi.y_offset == 0 && roi.width == 0 && roi.height == 0) {
    roi.width  = msg.width;
    roi.height = msg.height;
  }

  // Update time stamp (and frame_id if that changes for some reason)
  cam_info_.header = msg.header;
  
  // Update any parameters that have changed. The full rectification maps are
  // invalidated by any change in the calibration parameters OR binning.
  bool &full_dirty = cache_->full_maps_dirty;
  full_dirty |= update(msg.height, cam_info_.height);
  full_dirty |= update(msg.width,  cam_info_.width);
  full_dirty |= update(msg.distortion_model, cam_info_.distortion_model);
  full_dirty |= updateMat(msg.D, cam_info_.D, D_, 1, msg.D.size());
  full_dirty |= updateMat(msg.K, cam_info_.K, K_full_);
  full_dirty |= updateMat(msg.R, cam_info_.R, R_);
  full_dirty |= updateMat(msg.P, cam_info_.P, P_full_);
  full_dirty |= update(binning_x, cam_info_.binning_x);
  full_dirty |= update(binning_y, cam_info_.binning_y);

  // The reduced rectification maps are invalidated by any of the above or a
  // change in ROI.
  bool &reduced_dirty = cache_->reduced_maps_dirty;
  reduced_dirty  = full_dirty;
  reduced_dirty |= update(roi.x_offset,   cam_info_.roi.x_offset);
  reduced_dirty |= update(roi.y_offset,   cam_info_.roi.y_offset);
  reduced_dirty |= update(roi.height,     cam_info_.roi.height);
  reduced_dirty |= update(roi.width,      cam_info_.roi.width);
  reduced_dirty |= update(roi.do_rectify, cam_info_.roi.do_rectify);
  // As is the rectified ROI
  cache_->rectified_roi_dirty = reduced_dirty;

  // Figure out how to handle the distortion
  if (cam_info_.distortion_model == sensor_msgs::distortion_models::PLUMB_BOB ||
      cam_info_.distortion_model == sensor_msgs::distortion_models::RATIONAL_POLYNOMIAL) {
    cache_->distortion_state = (cam_info_.D.size() == 0 || (cam_info_.D[0] == 0.0)) ? NONE : CALIBRATED;
  }
  else
    cache_->distortion_state = UNKNOWN;

  // If necessary, create new K_ and P_ adjusted for binning and ROI
  /// @todo Calculate and use rectified ROI
  bool adjust_binning = (binning_x > 1) || (binning_y > 1);
  bool adjust_roi = (roi.x_offset != 0) || (roi.y_offset != 0);

  if (!adjust_binning && !adjust_roi) {
    K_ = K_full_;
    P_ = P_full_;
  }
  else {
    K_ = K_full_;
    P_ = P_full_;

    // ROI is in full image coordinates, so change it first
    if (adjust_roi) {
      // Move principal point by the offset
      /// @todo Adjust P by rectified ROI instead
      K_(0,2) -= roi.x_offset;
      K_(1,2) -= roi.y_offset;
      P_(0,2) -= roi.x_offset;
      P_(1,2) -= roi.y_offset;
    }

    if (binning_x > 1) {
      double scale_x = 1.0 / binning_x;
      K_(0,0) *= scale_x;
      K_(0,2) *= scale_x;
      P_(0,0) *= scale_x;
      P_(0,2) *= scale_x;
      P_(0,3) *= scale_x;
    }
    if (binning_y > 1) {
      double scale_y = 1.0 / binning_y;
      K_(1,1) *= scale_y;
      K_(1,2) *= scale_y;
      P_(1,1) *= scale_y;
      P_(1,2) *= scale_y;
      P_(1,3) *= scale_y;
    }
  }

  return reduced_dirty;
}
Ejemplo n.º 18
0
int main ( int argc, char *argv[] ) 
{
	printf("Jacobi Sequential\n");
	if(argc>=2)
		n = atoi(argv[1]);
	else
		n = 6;

	realSize = n + 2;
	h = 2.0/n;
	hh=h*h;
	u1 = createMat(n);
	u2 = createMat(n);

	if(argc>=3) 
	{
		if(argv[2][0] == 'i')
		{
			mode = 'i';
			iterationsLeft = atoi(argv[3]);
		}
			else 
		if(argv[2][0] == 'e')
		{
			mode = 'e';
			errLimit = atof(argv[3]);
		}
	}


	double wt = omp_get_wtime();
	clock_t t = clock();
	double err;
	
	
	if(mode=='i')
	{
		iterations=iterationsLeft;
		for(int i=0; i<(iterationsLeft/2)-1; i++)
		{
			updateMat(u1, u2);
			updateMat(u2, u1);
		}
		updateMat(u1, u2);
		err = updateMatE(u2, u1);
	}
	if(mode=='e')
	{
		err = 2*errLimit;
		iterations=0;
		int iterBlock=100;
		while(err>errLimit)
		{

			for(int i=0; i<(iterBlock/2)-1; i++)
			{
				updateMat(u1, u2);
				updateMat(u2, u1);
			}
			updateMat(u1, u2);
			err=updateMatE(u2, u1);

			iterations += iterBlock;
		}
	}
	wt = omp_get_wtime()-wt;
	t = clock()-t;

	printf("Thresold:\t%f\n",err);
	printf("Iterations:\t%i\n",iterations);
	printf("W Time:\t%f\n",wt);
	printf("C Time:\t%f\n",((float)t)/CLOCKS_PER_SEC);
	
	writeImg (n+2, u1);

	if(argc>=5 && argv[4][0] == 'p')
		print(u1, realSize);

	return 0;
}