├── demo.png ├── img_noise └── 0001.png ├── img_output └── 0001_GABF.png ├── demo_GABF.m ├── README.md └── func_GABF.m /demo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigmms/chen_spl20_gabf/HEAD/demo.png -------------------------------------------------------------------------------- /img_noise/0001.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigmms/chen_spl20_gabf/HEAD/img_noise/0001.png -------------------------------------------------------------------------------- /img_output/0001_GABF.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigmms/chen_spl20_gabf/HEAD/img_output/0001_GABF.png -------------------------------------------------------------------------------- /demo_GABF.m: -------------------------------------------------------------------------------- 1 | clear, clc; 2 | 3 | imgRoot = './img_noise/'; 4 | imnames=dir([imgRoot '*' 'png']); 5 | Rad = 15; 6 | StdS = 30; 7 | StdR = 10; 8 | 9 | for img = 1 : length(imnames) 10 | strin = sprintf('./img_noise/%04d.png', img); 11 | Isrc = double(imread(strin)); 12 | 13 | Iout = func_GABF(Isrc, Rad, StdS, StdR); 14 | 15 | strin = sprintf('./img_output/%04d_GABF.png', img); 16 | imwrite(uint8(Iout), strin); 17 | fprintf('image %d has been done!\n', img); 18 | end -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Gaussian-Adaptive Bilateral Filter 2 | Matlab implementation of "Gaussian-Adaptive Bilateral Filter." 3 | 4 | [Article about this implemention](https://ieeexplore.ieee.org/document/9200678) 5 | 6 | ![](/demo.png) 7 | 8 | ## Dependencies 9 | > * MATLAB R2019a 10 | 11 | ## It was tested and runs under the following OSs: 12 | * Windows 10 13 | * Ubuntu 16.04 14 | 15 | Might work under others, but didn't get to test any other OSs just yet. 16 | 17 | ## Getting Started: 18 | ### Run testing 19 | ```bash 20 | $ git clone https://github.com/bigmms/chen_spl20_gabf.git 21 | $ cd chen_spl20_gabf 22 | $ matlab 23 | >> demo_GABF 24 | ``` 25 | The test results will be saved in: `./img_output/` 26 | 27 | ## Citation: 28 | @ARTICLE{chen_spl20_gabf, 29 | author={B. -H. {Chen} and Y. -S. {Tseng} and J. -L. {Yin}}, 30 | journal={IEEE Signal Processing Letters}, 31 | title={Gaussian-Adaptive Bilateral Filter}, 32 | year={2020}, 33 | volume={27}, 34 | number={}, 35 | pages={1670-1674},} 36 | -------------------------------------------------------------------------------- /func_GABF.m: -------------------------------------------------------------------------------- 1 | function Iout = func_GABF(Isrc, Rad, StdS, StdR) 2 | 3 | [Hei,Wid] = size(Isrc); 4 | iKg = zeros(1,2*Rad+1); 5 | for i = 0 : 1 : Rad 6 | iKg(Rad+i+1) = exp(-(i^2)/2/(StdS^2)); 7 | iKg(Rad-i+1) = exp(-(i^2)/2/(StdS^2)); 8 | end 9 | iKs = iKg' * iKg; 10 | iKr = zeros(1,256); 11 | for i = 0 : 1 : 255 12 | iKr(i+1) = exp(-(i^2)/2/(StdR^2)); 13 | end 14 | 15 | Ibuf = imrotate(Isrc,90); 16 | Ibuf = func_GF(Ibuf, Wid, Hei, Rad, StdS); 17 | Ibuf = imrotate(Ibuf,-90); 18 | Ibuf = func_GF(Ibuf, Hei, Wid, Rad, StdS); 19 | 20 | Iout = Ibuf; 21 | for h = 1 : 1 : Hei 22 | for w = 1 : 1 : Wid 23 | SumUp = 0; 24 | SumDn = 0; 25 | for sh = -Rad : 1 : Rad 26 | i = min(max(h + sh, 1), Hei); 27 | for sw = -Rad : 1 : Rad 28 | j = min(max(w + sw, 1), Wid); 29 | PxlDif = abs(Ibuf(i,j) - Isrc(h,w)); 30 | if sh == 0 && sw == 0 31 | SumUp = SumUp + Isrc(h,w); 32 | SumDn = SumDn + 1; 33 | else 34 | SumUp = SumUp + Ibuf(i,j) * iKs(sh+Rad+1, sw+Rad+1) * iKr(PxlDif+1); 35 | SumDn = SumDn + iKs(sh+Rad+1, sw+Rad+1) * iKr(PxlDif+1); 36 | end 37 | end 38 | end 39 | if SumDn < 0.001 40 | Iout(h,w) = Ibuf(h,w); 41 | else 42 | Iout(h,w) = round(SumUp / SumDn); 43 | end 44 | end 45 | end 46 | 47 | end 48 | 49 | function Iout = func_GF(Isrc, Hei, Wid, Rad, StdG) 50 | 51 | iKs = zeros(1,Rad+1); 52 | for i = 0 : 1 : Rad 53 | iKs(i+1) = exp(-(i^2)/2/(StdG^2)); 54 | end 55 | 56 | Iout = Isrc; 57 | for h = 1 : 1 : Hei 58 | for w = 1 : 1 : Wid 59 | SumUp = 0; 60 | SumDn = 0; 61 | for sw = -Rad : 1 : Rad 62 | j = min(max(w + sw, 1), Wid); 63 | SumUp = SumUp + Isrc(h,j) * iKs(abs(sw)+1); 64 | SumDn = SumDn + iKs(abs(sw)+1); 65 | end 66 | Iout(h,w) = round(SumUp / SumDn); 67 | end 68 | end 69 | 70 | end --------------------------------------------------------------------------------