• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Constructing an NSData object from a CIImage
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Constructing an NSData object from a CIImage


  • Subject: Constructing an NSData object from a CIImage
  • From: "Jaret Hargreaves" <email@hidden>
  • Date: Sun, 13 Aug 2006 18:02:48 -0600

I am performing image filtering using an algorithm developed in objc
and calling it from python.  The objC filtering method uses a memcpy
command to create a local copy and then generates a CIImage
("inputImage").  This CIImage is filtered and available as
"outputImage".  The relevant code is below:

***

- (id) initWithData:(char*)data xDim:(int)x yDim:(int)y
bytesPerPixel:(int)pixelSize k:(float)filterParam iter:(int)iterations
{
      self = [super init];

      [CIPlugIn loadAllPlugIns];

      // Copy the image into inputData via memcpy
      inputData = nil;
      inputData = (float*) malloc(x * y * pixelSize);

      memcpy(inputData, data, x * y * pixelSize);

      // Create a CIImage from inputData for processing
      NSData *imageData = [NSData dataWithBytes:(char*)inputData length:(x
* y * pixelSize)];
      inputImage = [CIImage imageWithData:(NSData*)imageData];

      // Initialize the aniso filter
      anisoFilter = [CIFilter filterWithName:@"AnisoDiffusionFilter"];

      [anisoFilter setValue: [NSNumber numberWithFloat: filterParam]
forKey: @"inputK"];

      // Perform first iteration of filtering
      [anisoFilter setValue: inputImage forKey: @"inputImage"];
      outputImage = [anisoFilter valueForKey: @"outputImage"];

      // Perform subsequent iterations of filtering as needed
      int i;
      for(i=0;i<(iterations-1);i++)
      {
              [anisoFilter setValue: inputImage forKey: @"inputImage"];
              outputImage = [anisoFilter valueForKey: @"outputImage"];
      }

      // How do we get CIImage "outputImage" back into NSData "inputData"?
      //inputData =

      // Copy the filtered image directly back to data
      memcpy(data, inputData, x * y * pixelSize);

      return 0;
}

***

How do I copy the results from the resulting CIImage ("outputImage")
back into inputData for the final memcpy out?

Any suggestions on a better/faster way to approach this operation
would also be appreciated.

Thanks in advance for any help.

-Jaret
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Prev by Date: Re: How do I know if a file is a system link?
  • Next by Date: Re: Unit testing and Xcode integration
  • Previous by thread: Re: How do I know if a file is a system link?
  • Next by thread: QTKit and QTMedia information?
  • Index(es):
    • Date
    • Thread