# Determining what filter (if any) has been applied to an image

I'm trying to determine what "filter" has been applied to an image. I have the original, raw image and the processed image. The processed image has been put through a pipeline (black box) that does various things to the image in an iterative manner.

The filter, as far as I can tell, is similar to an unsharp-mask, but with "negative bowls" mitigated. However, the processed image cannot be reproduced by a simple unsharp mask.

I've attempted to measure the "filter function" by taking the ratio of the power spectra of the raw and unprocessed images, but the best I've been able to do with that is unsharp mask with a non-gaussian smoothing function.

What methods are available for determining the filter applied to an image?

(not related to Determining the type of filter on an image)

• One big factor to consider is whether the unknown filter is linear or non-linear. Dec 28 '12 at 13:39
• Can you provide original and filtered images? Do you want to determine a particular filter or a class of filters? Jan 1 '13 at 16:32

If you have a "black box" filter, you can gain more knowledge about it by providing sets of synthetic images and then inspect changes in some of the following:

• spatial domain
• frequency domain
• histogram
• response curve
• pixel-pixel differences

If you know that the filter uses convolution, a method of blind deconvolution may be helpful.

• Good answer. However, I think that blind convolution is suited for harder problem - when you don't know the kernel and the original signal. Here you have the original signal, the result signal, and you need to find only the kernel. This can be done using a simple LS procedure. Jan 1 '13 at 16:47
• In case your filter is linear, this should be quite easy. You have a linear model with unknown parameters (9 if your support is 3x3, 16 if 4x4, etc...). You have a lot of constraints - the original image and result image. You can use linear least squares. If you can generate any input, it is even easier. Recall that a linear time-invariant system is fully determined by its response to delta impulse, which is its kernel.

• In case your filter is not linear (like Paul says), there is almost nothing that you can do to find it out, except using your common sense, or attempting to optimize another model, given your inputs and outputs. Image processing logic can be very non-linear, including ad-hoc solutions, so it looks quite hard to me.

If the filter is linear, then you could use the 2D deconvolution method discussed here The problem is the same, and has the same original conditions: The result of a convolution, and one of the images that was used in the convolution.
You have the original image and the result of convolving it with a filter, so deconvolution should give you back the filter kernel.

If the filter isn't linear, then I don't think there's any simple and direct way to reconstruct it. I think you would have to feed it various images and run deconvolutions on those results to try to zero in on what the filter does in which conditions - messy, manual, error prone.