E-mail (17 Sept 99) from Lazikas o Pontios:
below follow the filters i told you about. There are a lot of different
filters that bellong in different algorithm methods . A few things that
are important to all methods :
Images must be 256 gray levels (I did not test them with color images).
We assume that image has the function RC (x,y) where x,y are the position
of every pixel.
0<=X<=image_width-1 and
0<=Y<=Image_height-1 .
Thats all we need to know about.
--------------------------------------------------------------------------
1. CONVOLUTION FILTERS : This is the most used method (also known as
"moving window filters" and maybe you have already used it. For each
pixel in range (1,1),(width-1,height-1) we calculate its new value
using the following algo :
for j=1 to height-1
for i = 1 to width-1
newcolor=a1*RC(i ,j-1) + a2*RC(i ,j-1) + a3*RC(i+1,j-1) +
b1*RC(i-1,j) + b2*RC(i ,j) + b3*RC(i+1,j) +
c1*RC(i-1,j+1) + c2*RC(i ,j+1) + c3*RC(i+1,j+1) ;
newcolor=newcolor/kl;
newcolor=abs( newcolor ); // hate negative values !!!
if ( newcolor >255 ) newcolor=255; // not greater than 255
// do whatever you want here eg put new pixel color in a buffer
end i
end j
Unfortunatelly in this method we have strange results in first & last
row & column. Thats why we start from row-column 1 ( which is the second ) and
we stop 1 row & column before end.
Here follow the names of the filters that belong into this method and the
parameters a1..c3, kl that be used :
LOW_PASSn are noise removal filters. Images are getting smoother.
LAPLACE_ORIGINAL is Edge ehnancement filter.
LAPLACE is a special effect filter ( looks like you type the image in
abnormal paper)
LAPLACE_EDGE is Edge detection filter.
FOCUS is a sharpen filter (looks like you have changed the focus of
the camera when snaping the picture)
case LOW_PASS1: {
kl=9;
a1=1; a2=1; a3=1;
b1=1; b2=1; b3=1;
c1=1; c2=1; c3=1; break;
}
case LOW_PASS2: {
kl=10;
a1=1; a2=1; a3=1;
b1=1; b2=2; b3=1;
c1=1; c2=1; c3=1; break;
}
case LOW_PASS3: {
kl=16;
a1=1; a2=2; a3=1;
b1=2; b2=4; b3=2;
c1=1; c2=2; c3=1; break;
}
case LOW_PASS4: {
kl=5;
a1=0; a2=1; a3=0;
b1=1; b2=1; b3=1;
c1=0; c2=1; c3=0; break;
}
case LAPLACE_ORIGINAL: {
kl=1;
a1=-1; a2=-1; a3=-1;
b1=-1; b2=9; b3=-1;
c1=-1; c2=-1; c3=-1; break;
}
case LAPLACE: {
kl=1;
a1=1; a2=-2; a3=1;
b1=-2; b2=5; b3=-2;
c1=1; c2=-2; c3=1; break;
}
case LAPLACE_EDGE: {
kl=1;
a1=-1; a2=-1; a3=-1;
b1=-1; b2=8; b3=-1;
c1=-1; c2=-1; c3=-1; break;
}
case FOCUS: {
kl=1;
a1= 0; a2=-1; a3= 0;
b1=-1; b2= 5; b3=-1;
c1= 0; c2=-1; c3= 0; break;
}
-------------------------------------------------------------------------
2. Relief filter : Try it, it is good !
for j=0 to height-1
for i = 0 to width-1
newcolor=RC (i,j)+((maxcolor / 2) - RC (i-2,j-2));
newcolor=abs( newcolor ); // hate negative values !!!
if ( newcolor >255 ) newcolor=255; // not greater than 255
// do whatever you want here eg put new pixel color in a buffer
end i
end j
where
maxcolor is the maximum gray scale of the image.
This is a very fancy filter. All new pixels have values near the
(maxcolor/2) and for better results in viewing it is good to create a
histogram equalization for the new image.
----------------------------------------------------------------------------
Lazikas o Pontios.