コード例 #1
0
RcppExport SEXP antsImageMutualInformation( SEXP r_in_image1 ,
  SEXP   r_in_image2  )
{
  if( r_in_image1 == NULL || r_in_image2 == NULL )
    {
      Rcpp::Rcout << "Invalid Arguments: pass 2 images in " << std::endl ;
      Rcpp::wrap( 1 ) ;
    }

  Rcpp::S4 in_image1( r_in_image1 ) ;
  Rcpp::S4 in_image2( r_in_image2 ) ;
  std::string in_pixeltype = Rcpp::as< std::string >(
    in_image1.slot( "pixeltype" ) ) ;
  unsigned int dimension = Rcpp::as< unsigned int >(
    in_image1.slot( "dimension" ) ) ;
  std::string in_pixeltype2 = Rcpp::as< std::string >(
    in_image2.slot( "pixeltype" ) ) ;
  unsigned int dimension2 = Rcpp::as< unsigned int >(
    in_image2.slot( "dimension" ) ) ;
  if (  ( dimension != dimension2 ) ||
        ( in_pixeltype.compare(in_pixeltype2) != 0 ) )
  {
    Rcpp::Rcout << "Images must have equivalent dimensionality & pixel type" << std::endl ;
    Rcpp::wrap( 1 );
  }

  double mivalue = 1;
  if ( dimension == 2 )
    {
    typedef itk::Image< float , 2 > ImageType;
    typedef ImageType::Pointer ImagePointerType;
    Rcpp::XPtr< ImagePointerType > antsimage_xptr1(
      static_cast< SEXP >( in_image1.slot( "pointer" ) ) ) ;
    Rcpp::XPtr< ImagePointerType > antsimage_xptr2(
      static_cast< SEXP >( in_image2.slot( "pointer" ) ) ) ;
    mivalue = antsImageMIHelper<2>(*antsimage_xptr1,*antsimage_xptr2);
    }
  else if ( dimension == 3 )
    {
    typedef itk::Image< float , 3 > ImageType3;
    typedef ImageType3::Pointer ImagePointerType3;
    Rcpp::XPtr< ImagePointerType3 > antsimage_xptr1_3(
    static_cast< SEXP >( in_image1.slot( "pointer" ) ) ) ;
    Rcpp::XPtr< ImagePointerType3 > antsimage_xptr2_3(
    static_cast< SEXP >( in_image2.slot( "pointer" ) ) ) ;
    mivalue = antsImageMIHelper<3>(*antsimage_xptr1_3,*antsimage_xptr2_3);
    }
  else if ( dimension == 4 )
    {
    typedef itk::Image< float , 4 > ImageType4;
    typedef ImageType4::Pointer ImagePointerType4;
    Rcpp::XPtr< ImagePointerType4 > antsimage_xptr1_4(
    static_cast< SEXP >( in_image1.slot( "pointer" ) ) ) ;
    Rcpp::XPtr< ImagePointerType4 > antsimage_xptr2_4(
    static_cast< SEXP >( in_image2.slot( "pointer" ) ) ) ;
    mivalue = antsImageMIHelper<4>(*antsimage_xptr1_4,*antsimage_xptr2_4);
    }
    else Rcpp::Rcout << " Dimension " << dimension << " is not supported " << std::endl;
  return Rcpp::wrap( mivalue );
}
コード例 #2
0
ファイル: neu_desktop.c プロジェクト: cherry-wb/quietheart
static void my_button_press(GtkWidget *widget, GdkEventButton *event,
		gpointer data)
{
	int x, y;
//	bstate = PRESSED;

	x = event->x;
	y = event->y;

#if MY_DEBUG_OUTPUT == 1
	g_print("hello, x is:%d, y is:%d\n", x, y);
#endif
	if(in_image1(x,y))
	{/*browser*/
#if MY_DEBUG_OUTPUT == 1
		g_print("pressed in the image1\n");
#endif
		//launchApp_simple("/usr/bin/midbrowser");
		startBrowser(widget);
	}
	else if(in_image2(x,y))
	{/*Audio*/
#if MY_DEBUG_OUTPUT == 1
		g_print("pressed in the image2\n");
#endif
		//launchApp_simple("/usr/bin/ls -a");//这里启动程序
		//launchApp_simple("/usr/bin/StartAudio.sh");
		startAudio(widget);
	}
	else if(in_image3(x,y))
	{/*Video*/
#if MY_DEBUG_OUTPUT == 1
		g_print("pressed in the image3\n");
#endif
		//launchApp_simple("/usr/bin/echo good");//这里启动程序
		//launchApp_simple("/usr/bin/StartVideo.sh");
		startVideo(widget);
	}
	else if(in_image4(x,y))
	{/*Wifi*/
#if MY_DEBUG_OUTPUT == 1
		g_print("pressed in the image4\n");
#endif
		//launchApp_simple("/usr/bin/echo 'hello world'");//这里启动程序
		//launchApp_simple("/usr/bin/StartWifi.sh");//这里启动程序
		startWifi(widget);
	}
	else
	{
#if MY_DEBUG_OUTPUT == 1
		g_print("pressed out of all the image!\n");
#endif
	}
}
コード例 #3
0
ファイル: neu_desktop.c プロジェクト: cherry-wb/quietheart
static void my_mouse_motion(GtkWidget *widget, GdkEventMotion *event,
		gpointer data)
{
	int x, y;
	GdkModifierType state;

#if MY_DEBUG_OUTPUT == 1
	g_print("hello, motion hint out?\n");
#endif
	if(event->is_hint)
	{
#if MY_DEBUG_OUTPUT == 1
		g_print("hello, motion hint in?\n");
#endif
		gdk_window_get_pointer(event->window, &x, &y, &state);
	}
	else
	{
		x = event->x;
		y = event->y;
		state = event->state;
	}
	if(in_image1(x,y))
	{
		btn1state = PRELIGHT;
	}
	else if(in_image2(x,y))
	{
		btn2state = PRELIGHT;
	}
	else if(in_image3(x,y))
	{
		btn3state = PRELIGHT;
	}
	else if(in_image4(x,y))
	{
		btn4state = PRELIGHT;
	}
	else
	{
		btn1state = NORMAL;
		btn2state = NORMAL;
		btn3state = NORMAL;
		btn4state = NORMAL;
	}
	gtk_widget_queue_draw(widget);
}
コード例 #4
0
ファイル: neu_desktop.c プロジェクト: cherry-wb/quietheart
static void my_button_release(GtkWidget *widget, GdkEventButton *event,
		gpointer data)
{
	int x, y;

	x = event->x;
	y = event->y;

#if MY_DEBUG_OUTPUT == 1
	g_print("hello, x is:%d, y is:%d\n", x, y);
#endif
	if(in_image1(x,y))
	{
#if MY_DEBUG_OUTPUT == 1
		g_print("release in the image1\n");
#endif
		//btn1state = PRELIGHT;
	}
	else if(in_image2(x,y))
	{
#if MY_DEBUG_OUTPUT == 1
		g_print("release in the image2\n");
#endif
	}
	else if(in_image3(x,y))
	{
#if MY_DEBUG_OUTPUT == 1
		g_print("release in the image3\n");
#endif
	}
	else if(in_image4(x,y))
	{
#if MY_DEBUG_OUTPUT == 1
		g_print("release in the image4\n");
#endif
	}
	else
	{
#if MY_DEBUG_OUTPUT == 1
		g_print("release out of all the image!\n");
#endif
	}
}
コード例 #5
0
// [[myRcpp::export]]
RcppExport SEXP itkConvolveImage( SEXP r_in_image1 ,
  SEXP r_in_image2  )
{
  if( r_in_image1 == NULL || r_in_image2 == NULL  )
    {
    Rcpp::Rcout << " Invalid Arguments: convolveImage.cpp " << std::endl ;
    Rcpp::wrap( 1 ) ;
    }
  Rcpp::S4 in_image1( r_in_image1 ) ;
  Rcpp::S4 in_image2( r_in_image2 ) ;
  std::string in_pixeltype = Rcpp::as< std::string >(
    in_image1.slot( "pixeltype" ) ) ;
  unsigned int dimension = Rcpp::as< unsigned int >(
    in_image1.slot( "dimension" ) ) ;
  std::string in_pixeltype2 = Rcpp::as< std::string >(
    in_image2.slot( "pixeltype" ) ) ;
  unsigned int dimension2 = Rcpp::as< unsigned int >(
    in_image2.slot( "dimension" ) ) ;
  if (  ( dimension != dimension2 ) ||
        ( in_pixeltype.compare(in_pixeltype2) != 0 ) )
  {
    Rcpp::Rcout << " Images must have equivalent dimensionality & pixel type" << std::endl ;
    Rcpp::wrap( 1 );
  }

  // make new out image, result of convolution
  Rcpp::S4 out_image( std::string( "antsImage" ) ) ;
  out_image.slot( "pixeltype" ) = in_pixeltype ;
  out_image.slot( "dimension" ) = dimension ;

  if ( dimension == 2 )
    {
    typedef itk::Image< float , 2 > ImageType;
    typedef ImageType::Pointer ImagePointerType;
    Rcpp::XPtr< ImagePointerType > antsimage_xptr1(
      static_cast< SEXP >( in_image1.slot( "pointer" ) ) ) ;
    Rcpp::XPtr< ImagePointerType > antsimage_xptr2(
      static_cast< SEXP >( in_image2.slot( "pointer" ) ) ) ;

    ImagePointerType* out_image_ptr_ptr =
      new ImagePointerType(
        convolveImageHelper<ImageType>(
          *antsimage_xptr1,*antsimage_xptr2 )
        );

    Rcpp::XPtr< ImagePointerType >
      out_image_xptr( out_image_ptr_ptr , true );
    out_image.slot( "pointer" ) = out_image_xptr;
    }
  else if ( dimension == 3 )
    {
    typedef itk::Image< float , 3 > ImageType;
    typedef ImageType::Pointer ImagePointerType;
    Rcpp::XPtr< ImagePointerType > antsimage_xptr1(
      static_cast< SEXP >( in_image1.slot( "pointer" ) ) ) ;
    Rcpp::XPtr< ImagePointerType > antsimage_xptr2(
      static_cast< SEXP >( in_image2.slot( "pointer" ) ) ) ;

    ImagePointerType* out_image_ptr_ptr =
      new ImagePointerType(
        convolveImageHelper<ImageType>(
          *antsimage_xptr1,*antsimage_xptr2 )
        );

    Rcpp::XPtr< ImagePointerType >
      out_image_xptr( out_image_ptr_ptr , true );
    out_image.slot( "pointer" ) = out_image_xptr;

    }
  else if ( dimension == 4 )
    {
    typedef itk::Image< float , 4 > ImageType;
    typedef ImageType::Pointer ImagePointerType;
    Rcpp::XPtr< ImagePointerType > antsimage_xptr1(
      static_cast< SEXP >( in_image1.slot( "pointer" ) ) ) ;
    Rcpp::XPtr< ImagePointerType > antsimage_xptr2(
      static_cast< SEXP >( in_image2.slot( "pointer" ) ) ) ;

    ImagePointerType* out_image_ptr_ptr =
      new ImagePointerType(
        convolveImageHelper<ImageType>(
          *antsimage_xptr1,*antsimage_xptr2 )
        );

    Rcpp::XPtr< ImagePointerType >
      out_image_xptr( out_image_ptr_ptr , true );
    out_image.slot( "pointer" ) = out_image_xptr;
    }
    else Rcpp::Rcout << " Dimension " << dimension << " is not supported " << std::endl;
  return out_image;
}
コード例 #6
0
// [[myRcpp::export]]
RcppExport SEXP invariantImageSimilarity( SEXP r_in_image1 ,
  SEXP r_in_image2, SEXP thetas, SEXP localSearchIterations,
  SEXP whichMetric, SEXP r_scale, SEXP r_doref, SEXP txfn )
{
  if( r_in_image1 == NULL || r_in_image2 == NULL )
    {
    Rcpp::Rcout << "Invalid Arguments: pass 2 images in " << std::endl;
    Rcpp::wrap( 1 );
    }
  Rcpp::S4 in_image1( r_in_image1 ) ;
  Rcpp::S4 in_image2( r_in_image2 ) ;
  std::string in_pixeltype = Rcpp::as< std::string >(
    in_image1.slot( "pixeltype" ) ) ;
  unsigned int dimension = Rcpp::as< unsigned int >(
    in_image1.slot( "dimension" ) ) ;
  std::string in_pixeltype2 = Rcpp::as< std::string >(
    in_image2.slot( "pixeltype" ) ) ;
  unsigned int dimension2 = Rcpp::as< unsigned int >(
    in_image2.slot( "dimension" ) ) ;
  if (  ( dimension != dimension2 ) ||
        ( in_pixeltype.compare(in_pixeltype2) != 0 ) )
    {
    Rcpp::Rcout << "Images must have equivalent dimensionality & pixel type"
      << std::endl ;
    Rcpp::wrap( 1 );
    }

  if ( dimension == 2 )
    {
    typedef itk::Image< float , 2 > ImageType;
    typedef ImageType::Pointer ImagePointerType;
    Rcpp::XPtr< ImagePointerType > antsimage_xptr1(
      static_cast< SEXP >( in_image1.slot( "pointer" ) ) ) ;
    Rcpp::XPtr< ImagePointerType > antsimage_xptr2(
      static_cast< SEXP >( in_image2.slot( "pointer" ) ) ) ;
    return Rcpp::wrap( invariantSimilarityHelper<2>(
      *antsimage_xptr1, *antsimage_xptr2, thetas,
      localSearchIterations, whichMetric, r_scale,
      r_doref, txfn ) );
  }
  else if ( dimension == 3 )
    {
    typedef itk::Image< float , 3 > ImageType3;
    typedef ImageType3::Pointer ImagePointerType3;
    Rcpp::XPtr< ImagePointerType3 > antsimage_xptr1_3(
    static_cast< SEXP >( in_image1.slot( "pointer" ) ) ) ;
    Rcpp::XPtr< ImagePointerType3 > antsimage_xptr2_3(
    static_cast< SEXP >( in_image2.slot( "pointer" ) ) ) ;
    return Rcpp::wrap(  invariantSimilarityHelper<3>(
      *antsimage_xptr1_3, *antsimage_xptr2_3, thetas,
      localSearchIterations, whichMetric, r_scale,
      r_doref, txfn ) );
    }
  else if ( dimension == 4 )
    {
    typedef itk::Image< float , 4 > ImageType4;
    typedef ImageType4::Pointer ImagePointerType4;
    Rcpp::XPtr< ImagePointerType4 > antsimage_xptr1_4(
    static_cast< SEXP >( in_image1.slot( "pointer" ) ) ) ;
    Rcpp::XPtr< ImagePointerType4 > antsimage_xptr2_4(
    static_cast< SEXP >( in_image2.slot( "pointer" ) ) ) ;
    return Rcpp::wrap(  invariantSimilarityHelper<4>(
      *antsimage_xptr1_4, *antsimage_xptr2_4, thetas,
      localSearchIterations, whichMetric, r_scale,
      r_doref, txfn ) );
    }
  else Rcpp::Rcout << " Dimension " << dimension <<
    " is not supported " << std::endl;
  return Rcpp::wrap( 1 );
}
コード例 #7
0
// [[myRcpp::export]]
RcppExport SEXP invariantImageSimilarity( SEXP r_in_image1 ,
  SEXP r_in_image2, SEXP thetas, SEXP thetas2, SEXP thetas3,
  SEXP localSearchIterations,
  SEXP whichMetric, SEXP r_scale, SEXP r_doref, SEXP txfn,
  SEXP whichTransform )
{
  if( r_in_image1 == NULL || r_in_image2 == NULL )
    {
    Rcpp::Rcout << "Invalid Arguments: pass 2 images in " << std::endl;
    Rcpp::wrap( 1 );
    }
  Rcpp::S4 in_image1( r_in_image1 ) ;
  Rcpp::S4 in_image2( r_in_image2 ) ;
  std::string in_pixeltype = Rcpp::as< std::string >(
    in_image1.slot( "pixeltype" ) ) ;
  unsigned int dimension = Rcpp::as< unsigned int >(
    in_image1.slot( "dimension" ) ) ;
  std::string in_pixeltype2 = Rcpp::as< std::string >(
    in_image2.slot( "pixeltype" ) ) ;
  unsigned int dimension2 = Rcpp::as< unsigned int >(
    in_image2.slot( "dimension" ) ) ;
  if (  ( dimension != dimension2 ) ||
        ( in_pixeltype.compare(in_pixeltype2) != 0 ) )
    {
    Rcpp::Rcout << "Images must have equivalent dimensionality & pixel type"
      << std::endl ;
    Rcpp::wrap( 1 );
    }
  typedef itk::AffineTransform<double, 2> AffineType2D;
  typedef itk::AffineTransform<double, 3> AffineType3D;
  typedef itk::AffineTransform<double, 4> AffineType4D;
  typedef itk::Similarity2DTransform<double> SimilarityType2D;
  typedef itk::Similarity3DTransform<double> SimilarityType3D;
  typedef itk::Euler2DTransform<double> RigidType2D;
  typedef itk::Euler3DTransform<double> RigidType3D;
  // 0=affine, 1 = similarity, 2 = rigid
  unsigned int whichTx = Rcpp::as< unsigned int >( whichTransform );
  if ( dimension == 2 )
    {
    typedef itk::Image< float , 2 > ImageType;
    typedef ImageType::Pointer ImagePointerType;
    Rcpp::XPtr< ImagePointerType > antsimage_xptr1(
      static_cast< SEXP >( in_image1.slot( "pointer" ) ) ) ;
    Rcpp::XPtr< ImagePointerType > antsimage_xptr2(
      static_cast< SEXP >( in_image2.slot( "pointer" ) ) ) ;
    if ( whichTx == 0 )
      return Rcpp::wrap( invariantSimilarityHelper<2,AffineType2D>(
        *antsimage_xptr1, *antsimage_xptr2, thetas,
        thetas2, thetas3,
        localSearchIterations, whichMetric, r_scale,
        r_doref, txfn ) );
    if ( whichTx == 1 )
      return Rcpp::wrap( invariantSimilarityHelper<2,SimilarityType2D>(
        *antsimage_xptr1, *antsimage_xptr2, thetas,
        thetas2, thetas3,
        localSearchIterations, whichMetric, r_scale,
        r_doref, txfn ) );
    if ( whichTx == 2 )
      return Rcpp::wrap( invariantSimilarityHelper<2,RigidType2D>(
        *antsimage_xptr1, *antsimage_xptr2, thetas,
        thetas2, thetas3,
        localSearchIterations, whichMetric, r_scale,
        r_doref, txfn ) );
  }
  else if ( dimension == 3 )
    {
    typedef itk::Image< float , 3 > ImageType3;
    typedef ImageType3::Pointer ImagePointerType3;
    Rcpp::XPtr< ImagePointerType3 > antsimage_xptr1_3(
    static_cast< SEXP >( in_image1.slot( "pointer" ) ) ) ;
    Rcpp::XPtr< ImagePointerType3 > antsimage_xptr2_3(
    static_cast< SEXP >( in_image2.slot( "pointer" ) ) ) ;
    if ( whichTx == 0 )
      return Rcpp::wrap(  invariantSimilarityHelper<3,AffineType3D>(
        *antsimage_xptr1_3, *antsimage_xptr2_3, thetas,
        thetas2, thetas3,
        localSearchIterations, whichMetric, r_scale,
        r_doref, txfn ) );
    if ( whichTx == 1 )
      return Rcpp::wrap(  invariantSimilarityHelper<3,SimilarityType3D>(
        *antsimage_xptr1_3, *antsimage_xptr2_3, thetas,
        thetas2, thetas3,
        localSearchIterations, whichMetric, r_scale,
        r_doref, txfn ) );
    if ( whichTx == 2 )
      return Rcpp::wrap(  invariantSimilarityHelper<3,RigidType3D>(
        *antsimage_xptr1_3, *antsimage_xptr2_3, thetas,
        thetas2, thetas3,
        localSearchIterations, whichMetric, r_scale,
        r_doref, txfn ) );
    }
  else if ( dimension == 4 )
    {
    typedef itk::Image< float , 4 > ImageType4;
    typedef ImageType4::Pointer ImagePointerType4;
    Rcpp::XPtr< ImagePointerType4 > antsimage_xptr1_4(
    static_cast< SEXP >( in_image1.slot( "pointer" ) ) ) ;
    Rcpp::XPtr< ImagePointerType4 > antsimage_xptr2_4(
    static_cast< SEXP >( in_image2.slot( "pointer" ) ) ) ;
    if ( whichTx == 0 )
      return Rcpp::wrap(  invariantSimilarityHelper<4,AffineType4D>(
        *antsimage_xptr1_4, *antsimage_xptr2_4, thetas,
        thetas2, thetas3,
        localSearchIterations, whichMetric, r_scale,
        r_doref, txfn ) );
    if ( ( whichTx == 1 ) || ( whichTx == 2 ) )
      {
      Rcpp::Rcout << " In dimension " << dimension <<
          " rigid/similarity is not supported " << std::endl;
        return Rcpp::wrap( 1 );
      }
    }
  else Rcpp::Rcout << " Dimension " << dimension <<
    " is not supported " << std::endl;
  return Rcpp::wrap( 1 );
}