GPUImage2 icon indicating copy to clipboard operation
GPUImage2 copied to clipboard

HighPassFilter doesn't work for photos for iOS

Open vjdaemp opened this issue 5 years ago • 4 comments

HighPassFilter works for Videos but not Photos.

Reproduction steps:

  1. Open SimpleImageFilter sample project.
  2. Replace line 16 SmoothToonFilter() with HighPassFilter()
  3. Run project and observe failure. Terminates due to memory issue.

vjdaemp avatar Aug 10 '18 00:08 vjdaemp

A high pass filter doesn't make as much sense for still images, because it is based on a rolling average of images. To do this, it uses a buffer to build a weighted average of all images it's seen over time (taking the current image, mixing it with the buffered image based on the high pass strength, then storing the new resulting image in the buffer and letting go of the old image).

With a still image, you don't have previous image frames, so there's nothing to average against. I'm also not sure what happens when you trigger this with a single image, so you may be hitting an infinite loop of some kind.

BradLarson avatar Aug 10 '18 18:08 BradLarson

Adobe Photoshop allows you to apply High Pass filter on a photo. Is there anyway to adapt the High Pass video filter in GPUImage to work with photos?

vjdaemp avatar Aug 10 '18 18:08 vjdaemp

What operation does Photoshop's High Pass filter perform? It might be performing an image processing operation that is called something different in this framework, such as a median filter. They're doing a spatial high pass, not a temporal one, so it's a different filter than what I have labeled as a high pass.

BradLarson avatar Aug 10 '18 18:08 BradLarson

Thanks for the clarifications. I will see if I can come up a custom filter for high pass on single image. Disregard my comment about the bug. I did not realize the High Pass filter in your library was only for video, so it works as intended.

According to Photoshop help:

Retains edge details in the specified radius where sharp color transitions occur and suppresses the rest of the image. (A radius of 0.1 pixel keeps only edge pixels.) The filter removes low-frequency detail from an image and has an effect opposite to that of the Gaussian Blur filter

vjdaemp avatar Aug 10 '18 23:08 vjdaemp