MATLAB exercise program (adaptive median filter ramf)

Source: Internet
Author: User

Median Filtering is a classic algorithm. Today, I read the paper and I know that there is also an algorithm called adaptive median filter ramf. The original paper is here.

Ramf processes images in the following two steps.

1. First determine the maximum filtering radius, and then use an appropriate radius R to filter the image. Calculate the Imin, IMAX, and imed of the pixel gray scale of the Current Filter radius, and then judge whether imed is in the middle of [Imin, IMAX]. If imed is in, perform downward, otherwise, the current radius is extended until the R is equal to the maximum filtering radius.

2. If the currently processed pixel IMG (I, j) is between [Imin, IMAX], the current pixel is output; otherwise, the value of the current filtering radius pixel imed is output.

Let's see the effect:

Noisy Image:

Ramf algorithm:

Common 3*3 median filtering:

The Matlab code is as follows:

Clear all; close all1_clc1_img1_mat2gray(imread('lena.jpg '); [m n] = size (IMG); IMG = imnoise (IMG, 'Salt & pepper', 0.1 ); % added the salt and pepper noise imshow (IMG, []); Nmax = 10; % determined the maximum filtering radius %. below is the boundary extension, and Nmax pixels are added to the image from top to bottom to left. Imgn = zeros (m + 2 * Nmax + 1, n + 2 * Nmax + 1); imgn (Nmax + 1: m + Nmax, Nmax + 1: N + Nmax) = IMG; imgn (1: Nmax, Nmax + 1: N + Nmax) = IMG (1: Nmax, 1: N); % extended upper boundary imgn (1: m + Nmax, N + Nmax + 1: n + 2 * Nmax + 1) = imgn (1: m + Nmax, N: N + Nmax ); % extend the right boundary imgn (m + Nmax + 1: m + 2 * Nmax + 1, Nmax + 1: n + 2 * Nmax + 1) = imgn (M: m + Nmax, nmax + 1: n + 2 * Nmax + 1); % extended lower boundary imgn (1: m + 2 * Nmax +: Nmax) = imgn (1: m + 2 * Nmax + 1, Nmax + * Nmax); % expanded left Boundary Re = imgn; for I = Nmax + 1: m + Nmax for J = Nmax + 1: N + Nmax r = 1; % initial filtering radius wh Ile R ~ = Nmax W = imgn (I-r: I + R, J-R: J + r); W = sort (w); Imin = min (w (:)); IMAX = max (w (:)); imed = W (uint8 (2 * r + 1) ^ 2/2 )); if Imin <imed & imed <IMAX % if the median in the current neighborhood is not a noise point, use the break in the current neighborhood; else r = R + 1; % otherwise, expand the window, continue to judge end if Imin 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.