[Journal of mathematics, jiaricang University] 055th image filtering model of direction Diffusion

Source: Internet
Author: User

$ \ BF abstract $: This article gives a detailed description of section 5.4.1 of "methods of partial differential equations in image processing" Edited by Wang dakai.

 

$ \ BF keywords $: Image filtering; Direction diffusion model; matlab programming

 

1. Model Creation

From the point of view of protecting the image edge, we hope that the diffusion will be carried out along the tangent direction parallel to the edge (that is, perpendicular to $ \ n I $. therefore, we can get the following PDAs: $ \ bee \ label {1: DF} I _t = I _ {\ Xi }, \ EEE $ \ XI (\ perp \ n I) $ is the unit vector. we simplify \ eqref {1: DF} is as follows (if $ \ Bex {\ BF \ ETA} =\ frac {\ n I }{\ sev {\ n I }}= (\ cos t, \ sin t), \ quad {\ BF \ Xi} = (-\ sin t, \ cos t) (\ perp {\ BF \ ETA }), \ EEx $ then $ \ Bex \ sex {\ BA {CC} \ frac {\ p} {\ P \ Xi} \ frac {\ p} \ ETA} \ EA} & =& \ sex {\ BA {CC} \ cos T & \ sin t \-\ sin T & \ cos t \ EA} \ sex {\ BA {CC} \ frac {\ p} {\ P x} \ frac {\ p} {\ P y} \ EA }, \ EEx $ and $ \ Bex \ frac {\ P ^ 2} {\ P \ Xi ^ 2} + \ frac {\ P ^ 2} {\ P \ ETA ^ 2} & = & \ sex {\ BA {CC} \ frac {\ p} {\ P \ Xi} & \ frac {\ p} {\ P \ ETA} \ EA} \ sex {\ BA {CC} \ frac {\ p} {\ P \ Xi} \ frac {\ p} {\ P \ ETA} \ EA} = \ sex {\ BA {CC} \ frac {\ p} {\ P x} & \ frac {\ p} {\ P y} \ EA} \ sex {\ BA {CC} \ cos T &-\ sin t \ sin T & \ cos t \ EA} \ sex {\ BA {CC} \ cos T & \ sin t \\-\ sin T & \ cos t \ EA} \ sex {\ BA {CC} \ frac {\ p} {\ P x} \ frac {\ p} {\ P Y} \ EA }\\\\\\sex {\ba {CC} \ frac {\p }{\ p x} & \ frac {\ P }{\ p y} \ EA} \ sex {\ BA {CC} \ frac {\ p} {\ P x} \ frac {\ p} {\ P y} \ EA} = \ frac {\ P ^ 2} {\ P x ^ 2} + \ frac {\ P ^ 2} {\ P y ^ 2} \ EEx $): $ \ Bex I _t = I _ {\ Xi} \\\\\=& \ lap I-I _ {\ ETA \ ETA }\\\\=& \ lap I -(\ sev {\ n I }) _ \ ETA \ quad \ sex {I _ \ ETA = \ n I \ cdot {\ BF \ ETA} = \ n I \ cdot \ frac {\ n I} {\ sev {\ n I }}=\ sev {\ n I }}\\\& \ lap I-\ n \ sev {\ n I} \ cdot {\ BF \ ETA }\\& = & \ lap I-\ frac {\ sex {I _xi _ {XX} + I _yi _ {XY }, I _xi _ {XY} + I _yi _ {YY }}{\ sev {\ n I }}\ cdot \ frac {(I _x, I _y )} {| \ n I |}\\& = & I _ {XX} + I _ {YY}-\ frac {I _x ^ 2I _ {XX} + 2i_xi_yi _ {XY} + I _y ^ 2I _ {YY }{| \ n I | ^ 2 }\\\&\frac {I _y ^ 2I _ {XX}-2i_xi_yi _ {XY} + I _x ^ 2I _ {YY }{| \ n I | ^ 2 }. \ EEx $ \ bee \ label {1: df_xy} I _t = \ frac {I _y ^ 2I _ {XX}-2i_xi_yi _ {XY} + I _x ^ 2I _ {YY} {| \ n I | ^ 2 }. \ EEE $ notice $ I $ level set $ \ Bex \ Chi _ \ Lambda (I) =\ sed {(x, y ); \ I (x, y) \ geq \ Lambda} \ EEx $ suitable for $ \ Bex \ lambda_1 \ Leq \ lambda_2 \ Ra \ Chi _ {\ lambda_2} (I) \ subset \ Chi _ {\ lambda_1} (I ), \ EEx $ a normal vector of curves with $ {\ BF \ Xi} $ in the tangent direction $ \ Bex {\ BF n }=\ frac {\ n I }{ \ sev {\ n I }={\ BF \ ETA }. \ EEx $ therefore, by $ \ Bex \ Kappa =-\ Div {\ BF n} =-\ Div \ frac {\ n I} {\ sev {\ n I} =-\ frac {I _y ^ 2I _ {XX}-2i_xi_yi _ {XY} + I _x ^ 2I _ {YY }{\ sev {\ n I} ^ 3} \ EEx $ Zhi \ eqref {1: df_xy} can be further reduced to $ \ bee \ label {1: df_cuv} I _t =-\ Kappa \ sev {\ n I }. \ EEE $ this descriptionMoving along the horizontal set in the tangent direction is equivalent to performing the curvature movement on the horizontal set.We have noticed the connection between curvature motion and mathematical morphology.Moving along a horizontal set is also equivalent to performing median filtering on an image..The advantage of PDIS: it is not necessary to decompose all the horizontal sets of the image-median set operation (an algorithm of mathematical morphology)-reconstruction of the three steps to achieve the median filter on the gray image.. Edge stopping function: $ \ bee \ label {1: ESF} g (r) = \ frac {1} {1 + \ sex {\ frac {r} {k} ^ p}, \ quad \ sex {p = 1, 2 }, change \ eqref {1: DF} to $ \ bee \ label {1: df_esf} I _t = g (\ sev {\ n I }) I _ {\ Xi}, \ EEE $, or change \ eqref {1: df_xy} to $ \ bee \ label {1: df_xy_esf} I _t = g (\ sev {\ n I }) \ frac {I _y ^ 2I _ {XX}-2i_xi_yi _ {XY} + I _x ^ 2I _ {YY }{| \ n I | ^ 2 }, \ EEE $ or change \ eqref {1: df_cuv} to $ \ bee \ label {1: df_cuv_esf} I _t =-\ Kappa g (\ sev {\ n I }) \ sev {\ n I }. \ EEE $

 

2. Numerical Algorithms

We use a completely explicit solution to solve \ eqref {1: df_xy} Or \ eqref {1: df_xy_esf }:$ \ bee \ label {2: scheme_df} I _ {IJ} ^ {n + 1} = I ^ N _ {IJ} + \ lap t \ cdot Q ^ N _ {IJ }, \ EEE $ \ Bex Q ^ N _ {IJ} = \ frac {\ sex {d ^ {(0 )} _ Yi ^ N _ {IJ} ^ 2 \ cdot d ^ {(0) }_{ XX} I ^ N _ {IJ}-2D ^ {(0 )} _ Xi ^ N _ {IJ} \ cdot d ^ {(0)} _ Yi ^ N _ {IJ} \ cdot d ^ {(0 )} _ {XY} I ^ N _ {IJ} + \ sex {d ^ {(0 )} _ Xi ^ N _ {IJ }}^ 2 \ cdot d ^ {(0 )} _ {YY} I ^ N _ {IJ }}{\ sex {d ^ {(0 )} _ Xi ^ N _ {IJ} ^ 2 + \ sex {d ^ {(0)} _ Yi ^ N _ {IJ} ^ 2 }, \ EEx $ \ Bex d ^ {(0)} _ Xi ^ N _ {IJ} = \ frac {I ^ N _ {I, J + 1}-I ^ N _ {I, J-1} {2}, \ quad d ^ {(0 )} _ Yi ^ N _ {IJ }=\ frac {I ^ N _ {I + 1, J}-I ^ N _ {I-1, J }}{ 2 }, \ EEx $ \ Bex d ^ {(0) }_{ XX} I ^ N _ {XY} & = & d ^ {(0 )} _ Xi ^ N _ {I, j + \ frac {1} {2}-d ^ {(0)} _ Xi ^ N _ {I, j-\ frac {1} {2 }\\\&\sex {I ^ N _ {I, j + 1}-I ^ N _ {I, j }}- \ sex {I ^ N _ {I, j}-I ^ N _ {I, J-1 }}\\& = & I ^ N _ {I, J + 1} + I ^ N _ {I, J-1}-2I ^ N _ {IJ}, \ EEx $ \ Bex d ^ {(0 )} _ {XY} I ^ N _ {IJ} & = & d ^ {(0)} _ Xi ^ N _ {I + \ frac {1} {2 }, j}-d ^ {(0)} _ Xi ^ N _ {I-\ frac {1} {2 }, j }\\& = & d ^ {(0) }_x \ frac {I ^ N _ {I + 1, j} + I ^ N _ {IJ }}{ 2}-d ^ {(0)} _ x \ frac {I ^ N _ {I-1, j} + I ^ N _ {IJ} {2} \ quad \ sex {\ mbox {use mean to approximate half-point value }}\\\=& \ frac {\ sex {I ^ N _ {I + 1, J + 1}-I ^ N _ {I + 1, J-1} + \ sex {I ^ N _ {I, j + 1}-I ^ N _ {I, j-1 }}{ 4 }\\& &-\ frac {\ sex {I ^ N _ {I-1, J + 1}-I ^ N _ {I-1, j-1 }}+ \ sex {I ^ N _ {I, j + 1}-I ^ N _ {I, j-1 }}{ 4 }\\\&\frac {I ^ N _ {I + 1, J + 1} + I ^ N _ {I-1, j-1}-I ^ N _ {I + 1, J-1}-I ^ N _ {I-1, J + 1 }}{ 4 }, \ EEx $ \ Bex d ^ {(0) }_{ YY} I ^ N _ {IJ} = I ^ N _ {I + 1, j} + I ^ N _ {I-1, j}-2I ^ N _ {IJ}, \ EEx $ or $ \ bee \ label {2: scheme_df_esf} I ^ {n + 1} _ {IJ} = I ^ N _ {IJ} + \ lap t \ cdot g \ sex {I ^ N _ {IJ }}\ cdot Q ^ N _ {IJ }. \ EEE $

 

3. Numerical Experiments

Use the following Matlab code

Clear all;

Close all;

CLC;

 

 

% Parameter settings

Dt = 0.05; % time step

N = 1000; % set the number of iterations

D = 200; % output graphics every run d

Nn = 1; % Number of output images initialized

 

I =imread('key.bmp ');

I = imnoise (I, 'sale & pepper', 0.3 );

I = double (rgb2gray (I ));

 

[NY, nx] = size (I );

J = I; % diffuse image Initialization

K = I; % diffuse image initialization with Edge Function

 

For n = 1: N

 

DX = 0.5 * (J (:, [2: NX, nx])-J (:, [: nx-1]);

DY = 0.5 * (J ([2: NY, NY], :)-J ([: ny-1], :));

Dxx = (J (:, [2: NX, nx])-j)-(J-J (:, [: nx-1]);

Dxy = 0.25 * (J ([2: NY, NY], [2: NX, nx])-J ([2: NY, NY], [1, 1: nx-1])

-(J ([: ny-1], [2: NX, nx])-J ([: ny-1], [: nx-1]);

Dyy = (J ([2: NY, NY], :)-j)-(J-J ([: ny-1], :));

J = J + dt * (dy. ^ 2. * Dxx-2 * dx. * dy. * dxy + dx. ^ 2. * dyy ). /(EPS + dx. ^ 2 + dy. ^ 2 );

 

DX = 0.5 * (K (:, [2: NX, nx])-K (:, [: nx-1]);

DY = 0.5 * (K ([2: NY, NY], :)-K ([: ny-1], :));

Dxx = (k (:, [2: NX, nx])-(K-K (:, [: nx-1]);

Dxy = 0.25 * (K ([2: NY, NY], [2: NX, nx])-K ([2: NY, NY: nx-1])

-(K ([: ny-1], [2: NX, nx])-K ([: ny-1], [: nx-1]);

Dyy = (k ([2: NY, NY], :)-k)-(K-K ([: ny-1], :));

K = K + dt./(1 + (dx. ^ 2 + dy. ^ 2)/1024)

. * (Dy. ^ 2. * Dxx-2 * dx. * dy. * dxy + dx. ^ 2. * dyy ). /(EPS + dx. ^ 2 + dy. ^ 2 );

 

If Mod (n, d) = 0

Figure (NN );

Subplot (1, 3 );

Imshow (uint8 (I ));

Subplot (1, 3, 2 );

Imshow (uint8 (j ));

Subplot (1, 3 );

Imshow (uint8 (k ));

Hold off;

Nn = nn + 1;

End

End

To achieve the direction diffusion, see (each image consists of three small images, the first is the original image, and the second is the image after the direction diffusion, the third image is an image with an edge stop function ). we can see thatThe direction of the function with edge stop can better maintain the sharpness of the edge..

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.