Intel® Integrated Performance Primitives
Deliberate problems developing high-performance vision, signal, security, and storage applications.
6761 Discussions

ippsFilterMedian with delay lines not working (Change of anchor position)

Videometer
Beginner
2,890 Views

Hi

According to the documentation "ippsFilterMedian" can be called with "delay lines".

Quote from documentation page 252: "Another specific feature of the median filter implementation in Intel IPP is that elements outside the source vector, which are needed to determine the median value for “border” elements, are located in a delay line."

Using this is must be should be possible to change the anchor position to be "centered". Meaning that median filtering with a filter of length 3, then each element in the output is computed as output[i] = median(input[i-1], input[i], input[i+1]).

We are using attached code that is implemented according to the documentation. However it do not work. Se below examples. In each example we assume that the border is handled by duplicating the first/last element. I have marked unexpected values in bold.

Median filter of length 3:

Input 1, 2, 3, 25, 5
Expected output 1, 2, 3, 5, 5
Actual output 1, 2, 2, 3, 5

 

Input -1, -2, -3, -25, -5
Expected output -1, -2, -3, -5, -5
Actual output -1, -2, -2, -3, -5

 

Input 100, 100, 100, 100, 100
Expected output 100, 100, 100, 100, 100
Actual output 100, 100, 100, 100, 100

 

Median filter of length 5:

Input 100, 100, 100, 100, 100, 100, 100
Expected output 100, 100, 100, 100, 100, 100, 100
Actual output 100, 100, 100, 100, 100, 100, 100

 

Input 101, 102, 103, 104, 105, 106, 107
Expected output 101, 102, 103, 104, 105, 106, 107
Actual output 101, 102, 103, 104, 105, 106, 107

 

Input 1, 2, 127, 4, 5, 0, 7, 8
Expected output 1, 2, 4, 5, 4, 5, 7, 8
Actual output 1, 2, 2, 4, 5, 4, 5, 7

 

In the final implementation we don't care if the border is handled by duplicating the first/last element, by zero padding, or something different. As long as it is consistent, we can adapt out use case.

How are we supposed to wrap "ippsFilterMedian" in order to make it do centered median filtering?

Thank you for any help you for able to provide.

/Kristian

Labels (3)
0 Kudos
3 Replies
Abhinav_S_Intel
Moderator
2,867 Views

Let us investigate this issue at our end and get back to you with an update.

0 Kudos
Videometer
Beginner
2,843 Views

Thank you.

In the mean time we managed to make it work for two use cases:

1) Centered median filtering where we ignore then border. I.e. for a filter of length 3 the first and last element is returned as zero.

2) Centered median filtering where we use "wrap around" like described below:
output[0] = median( input[n], input[0], input[1]) (Note the warp around to input element n)
output[1] = median( input[0], input[1], input[2])
output[2] = median( input[1], input[2], input[3])
 ...
output[n-1] = median( input[n-2], input[n-1], input[n])
output[n] = median( input[n-1], input[n], input[0]) (Note the warp around to input element 0)

I have attached the code in the hope that someone may benefit from it.

Best Regards
Kristian

0 Kudos
Andrey_B_Intel
Employee
2,734 Views

Hi Kristian.

I am attaching a workaround with a centered median filter. The "dst centered" is as expected.

src:
1 2 3 25 5
dst:
1 1 2 3 5
dst centered:
1 2 3 5 5

Could you try it, please?

Thanks for the feedback.

Andrey.

 

 

0 Kudos
Reply