, , .
, , Fortran .
, .
( ) . , .., , , .
, , , , , , , . , , , .
, . , , . , , , , , ( , , ..).
( ).
1990 ( ). , .
. .
, , :
C :
:
;
, ;
;
;
;
;
, , ( ) . 0 , .
.
, ,
,
, :
,
, ( ):
:
;
c
;
,
.
(
1), , ( ).
:
;
, , ;
. , . :
.
- , ,
.
:
, , .
( 3).
.
,
,
.
, ,
,
:
.
,
. , ,
, .
,
,
, .
, . . :
- :
- . ,
. , , :
:
. .
, , , , .
:
:
.
. , .
, , , . :
. .
Fortran
, , . ,
, .
:
- ( w h );
- (w+2)*(h+2) ( I);
- (w+2)*(h+2) ( BlurI);
- I=0;
- I ( , , , );
- level
- 4 I, - . , BlurI, I;
- I BlurI;
- , level=level+deltaT, deltaT , ;
- BlurI. ;
- , ;
, .
Fortran
. , . , , - .
, . ( ) , , .
, , PGM P5. bitmap . ASCII , ( 0 255) . , .
PGM , , ,
. 255.
PGM .
program blur
use pgmio
implicit none
double precision, parameter :: t=10.0d0, deltaT=0.2d0, k=10.0d0
character*(*), parameter :: input='dif_tomography.pgm', output='output.pgm'
double precision, allocatable :: u(:,:), nu(:,:)
double precision :: north, south, east, west, level
integer :: w, h, offset, n, i, j
end program blur
t
, ,
deltaT
,
k
g
.
Input
output
.
w
h
.
call pgmsize(input, w, h, offset)
Offset
, .
input
.
allocate(u(0:w+1,0:h+1))
u=0
allocate(nu(w,h))
call pgmread(input, offset, w, h, u, 0, 0)
, , , , u ,
0
w+1
,
0
h+1
. .
pgmread
w*h
,
offset
( PGM)
u
. ,
u
.
, , , , PGM .
.
level = 0 !
do while (levelcode>
, , Fortran ,
j
i
. , , - , . , , , -.
.
deallocate(u)
call pgmwriteheader(output, w, h)
call pgmappendbytes(output, nu, 1, 1)
deallocate(nu)
pgmwriteheader
output
PGM P5.
pgmappendbytes
output
nu
, ,
nu
1 . ,
pgmappendbytes
, , , .
g
. ,
3.
contains
function g(x) result(v)
implicit none
double precision, intent(in) :: x
double precision :: v
v = 1/(1+(x/k)**2)
end function g
->
gfortran ( , ):
gfortran pgmio.f90 blur.f90
t
.
.
.
.
(
t=10
).
(
t=10, k=8
).
, .
.
k
t
deltaT
(
t=10, deltaT=0.2
).
,
k
. . k , .
(
t=10,k=5
).
. .
, , .
deltaT=10
.
.
,
.
, . . , , .
:
PGM,
.
- . Scale-Space and Edge Detection Using Anisotropic Diffusion
-
- PGM
-
https://habrahabr.ru/post/331618/