Filtered image is white

5 replies [Last post]
Rahvin
User offline. Last seen 8 years 48 weeks ago. Offline
Joined: 06/01/2012
Posts:

Hi.

I installed the framework today and so far it was straight forward.
But when I use any image filter the resulting image is completely white.

I tried some filters from CoreImage and they worked fine.

This is my test-code:

    NSString* strImageName = @"IMG_0100.jpg";
 
    UIImage *bla = [UIImage imageNamed:strImageName];
    GPUImageSepiaFilter *filter = [[GPUImageSepiaFilter alloc] init];
 
    UIImage *target = [filter imageByFilteringImage:bla];
    [imageView setImage:target];

The Programm compiles without any warnings or errors. Any idea what I'm doing wrong?

Rahvin
User offline. Last seen 8 years 48 weeks ago. Offline
Joined: 06/01/2012
Posts:

I've looked through your samples and finally it worked with using GPUImageView instead of UIImageView.

Is there any way to get it to work with UIImageView? How can I assign a flltered UIImage to GPUImageView?

Brad Larson
Brad Larson's picture
User offline. Last seen 4 years 22 weeks ago. Offline
Joined: 05/14/2008
Posts:

Have you tried saving your UIImage to disk to verify that it's all white, and that there isn't a problem somewhere with your UIImageView? The code you posted above should filter your source image just fine. If you look at the SimpleImageFilter example, I do just this in there for one of the images and that works in all of my tests.

Rahvin
User offline. Last seen 8 years 48 weeks ago. Offline
Joined: 06/01/2012
Posts:

Thanks for your fast reply :).

I've tried some different approaches:

This works fine... of course:

  UIImage *img = [UIImage imageNamed:@"IMG_0100.jpg"];
  [imageView setImage:img];

Using GPUImageView also works fine:

    CGRect mainScreenFrame = [[UIScreen mainScreen] applicationFrame];	
    GPUImageView *primaryView = [[GPUImageView alloc] initWithFrame:mainScreenFrame];
    self.view = primaryView;    
 
    UIImage *inputImage = [UIImage imageNamed:@"IMG_0100.jpg"];
    GPUImagePicture *imgSource = [[GPUImagePicture alloc] initWithImage:inputImage];
    GPUImageSepiaFilter *filter = [[GPUImageSepiaFilter alloc] init];
    [imgSource addTarget:filter];
    [filter addTarget:primaryView];
    [imgSource processImage];

Using the 'long' version with UIImageView also works fine:

    UIImage *inputImage = [UIImage imageNamed:@"IMG_0100.jpg"];
    GPUImagePicture *imgSource = [[GPUImagePicture alloc] initWithImage:inputImage];
    GPUImageSepiaFilter *filter = [[GPUImageSepiaFilter alloc] init];
    [imgSource addTarget:filter];
    [imgSource processImage];
    UIImage* outputImage = [filter imageFromCurrentlyProcessedOutput];
    [imageView setImage:outputImage];

The short version does not work, I only get a completely white image:

    UIImage *imgSource = [UIImage imageNamed:@"IMG_0100.jpg"];
    GPUImageSepiaFilter *filter = [[GPUImageSepiaFilter alloc] init];
    UIImage *imgDest = [filter imageByFilteringImage:imgSource];    
    [imageView setImage:imgDest];

Is there anything wrong with my 'short' version and UIImageView?

Brad Larson
Brad Larson's picture
User offline. Last seen 4 years 22 weeks ago. Offline
Joined: 05/14/2008
Posts:

Are you trying this in the Simulator or on an actual device? The shorter version of the image capture enables -prepareForImageCapture on the filter it's going to grab an image from, which uses the iOS 5.0 texture caches if available to read the filtered image much faster than the normal route. However, reading from these texture caches is currently broken in the iOS Simulator, where it works just fine on actual devices.

The Simulator has some other issues when it comes to this framework, due to the way it has to use software emulation for some of the shader functions, so I tend to do all of my testing on the devices themselves. I suppose I could add a fallback to prevent this on the Simulator, since a number of people have his this issue.

Rahvin
User offline. Last seen 8 years 48 weeks ago. Offline
Joined: 06/01/2012
Posts:

Your're right, I just tested it in the simulator. I'll test it on the device tomorrow.

Thank you very much for the fast answers. By the way. great framework :)!

Syndicate content