I want to apply Median Filtering on a black & white 256x256 image with window size 3, 5 and 7... I can't find a sort algorithm with which I can work with. Can you help me and give me some ideas?
Asked
Active
Viewed 1,300 times
-3
-
2Which ones did you try and why didn't they work? – Carl Norum Jan 06 '13 at 05:20
-
Have you looked at [Quicksort](http://en.wikipedia.org/wiki/Quicksort)? It's the standard sort algorithm. – bitWorking Jan 06 '13 at 05:20
2 Answers
0
You can use the selection algorithm to find median without sorting: http://en.wikipedia.org/wiki/Selection_algorithm
But any sort can work. Just sort and take the number in the middle.
![](../../users/profiles/1516766.webp)
Vlad Krasnov
- 977
- 6
- 12
0
I made a sorting code:
int m = 1
for ( i = 0; i = 2; i++)
for ( j = 0, j = 2, j++)
x[m] <- outputImage[i,j];
m = m + 1;
}
}
for ( i = 1; i = 9; i++)
for ( j = 9; j = i; j-- )
if x[m] < x [m - 1]
x[m] = x[m - 1]
}
}
}
m = 1 for ( i = 0; i = 2; i++)
for ( j = 0, j = 2, j++)
outputImage[i,j] = x[m];
m = m + 1;
}
}
Ok after the sorting I take the number in the middle... My issue now is that I don't know how I will apply this to my code as the for loops of the code are like this, I want to use median filtering in 3x3 window size (I have putted salt n pepper noise):
for (i = 0; i < ROWS; i++)
{
for (j = 0; j < COLUMNS; j++)
{
outputImage[i][j] = inputImage[i][j];
}
}
for( p = 0; p <500; p++)
{
outputImage[rand() % 256 ] [rand() % 256] = 0;
}
![](../../users/profiles/1952054.webp)
Κώστας Μπ.
- 1
- 1