Hi,guys!

i have done a little change to the code snippets from some website capable of doing median-filter processing on 24 bitmap,such code as following:

but final output image doesn't seem to be correct result. so anything wrong with the above code.thank you !Code:typedef struct element{ UCHAR b; UCHAR g; UCHAR r; }element; void CIMGutility::_medianfilter(const element* image, element* result, int N, int M) { // Move window through all elements of the image for (int m = 1; m < M - 1; ++m) for (int n = 1; n < N - 1; ++n) { // Pick up window elements int k = 0; element window[9]; for (int j = m - 1; j < m + 2; ++j) for (int i = n - 1; i < n + 2; ++i) window[k++] = image[j * N + i]; // Order elements (only half of them) for (int j = 0; j < 5; ++j) { // Find position of minimum element int min = j; for (int l = j + 1; l < 9; ++l) if (window[l].b < window[min].b) min = l; // Put found minimum element in its place byte temp = window[j].b; window[j].b = window[min].b; window[min].b = temp; min = j; for (int l = j + 1; l < 9; ++l) if (window[l].g < window[min].g) min = l; // Put found minimum element in its place temp = window[j].g; window[j].g = window[min].g; window[min].g = temp; min = j; for (int l = j + 1; l < 9; ++l) if (window[l].r < window[min].r) min = l; // Put found minimum element in its place temp = window[j].r; window[j].r = window[min].r; window[min].r = temp; } // Get result - the middle element result[(m - 1) * (N - 2) + n - 1] = window[4]; } }