Ejemplo n.º 1
0
int main()
{
	int A[N][N] = { 
			{1, 1, 1, 1},
			{2, 2, 2, 2},
			{3, 3, 3, 3},
			{4, 4, 4, 4}
		      };

	int B[N][N] = {
			{2, 2, 2, 2},
			{3, 3, 3, 3},
			{4, 4, 4, 4},
			{5, 5, 5, 5}
		      };

	int C[N][N];

	int i,j;

	multiplyArray(A, B, C);

	//print array
	for(i = 0; i < N; i++)
	{
		for(j = 0; j<N;j++)
		{
			printf("%d ", C[i][j]);
		}
		printf("\n");
	}
	return 0;
}
Ejemplo n.º 2
0
void SpencerOTF::process( BidomainArray2D *in, BidomainArray2D *out )
{
  const FFTWComplexArray *input = in->getFrequency(); // This must be executed before out->setFrequency() if (in == out)  
  multiplyArray( out->setFrequency(), input, filter.getFrequency() );
}
Ejemplo n.º 3
0
void applyAbsoluteOnFrames( int argc, char* argv[] )
{
  pfs::DOMIO pfsio;

  float destY = 1.0f;
  float srcY = 1.0f;  

  bool verbose = false;

  static struct option cmdLineOptions[] = {
    { "help", no_argument, NULL, 'h' },
    { "verbose", no_argument, NULL, 'v' },
    { NULL, 0, NULL, 0 }
  };

  int optionIndex = 0;
  while( 1 ) {
    int c = getopt_long (argc, argv, "", cmdLineOptions, &optionIndex);
    if( c == -1 ) break;
    switch( c ) {
    case 'h':
      printHelp();
      throw QuietException();
    case 'v':
      verbose = true;
      break;
    case '?':
      throw QuietException();
    case ':':
      throw QuietException();
    }
  } 

  if( optind == argc )
    throw pfs::Exception( "Destination luminance level <dest Y> must be specified" );
  if( optind < (argc - 2) )
    throw pfs::Exception( "Too many arguments" );

  destY = strtof( argv[optind++], NULL );
  if( optind != argc )
    srcY = strtof( argv[optind++], NULL );
  
  VERBOSE_STR << "rescale luminance to: " << destY << std::endl;
  if( srcY != 1.0f )
    VERBOSE_STR << "from: " << srcY << std::endl;

  float multY = destY/srcY;
  
  while( true ) {
    pfs::Frame *frame = pfsio.readFrame( stdin );
    if( frame == NULL ) break; // No more frames

    const char *lumType = frame->getTags()->getString( "LUMINANCE" );
    if( lumType != NULL && !strcmp( lumType, "ABSOLUTE" ) ) {
      VERBOSE_STR << "luminance is already absolute, skipping frame.";
    } else {
    
      pfs::Channel *X, *Y, *Z;
      frame->getXYZChannels( X, Y, Z );
    
      if( X != NULL ) {           // Color, XYZ

        if( lumType != NULL && !strcmp( lumType, "DISPLAY" ) ) {
          VERBOSE_STR << "converting from display-referred to linear luminance.";
          pfs::transformColorSpace( pfs::CS_XYZ, X, Y, Z, pfs::CS_RGB, X, Y, Z );
          pfs::transformColorSpace( pfs::CS_SRGB, X, Y, Z, pfs::CS_XYZ, X, Y, Z );
        }
        multiplyArray( X, X, multY );
        multiplyArray( Y, Y, multY );
        multiplyArray( Z, Z, multY );
        
      } else if( (Y = frame->getChannel( "Y" )) != NULL ) {
        // Luminance only

        if( lumType != NULL && !strcmp( lumType, "DISPLAY" ) ) 
          throw pfs::Exception( PROG_NAME ": Cannot handle gray-level display-referred images." );
        
        multiplyArray( Y, Y, multY );

      } else
        throw pfs::Exception( "Missing color channels in the PFS stream" );

      frame->getTags()->setString("LUMINANCE", "ABSOLUTE");
    }    
    
    pfsio.writeFrame( frame, stdout );
    pfsio.freeFrame( frame );        
  }
}