diff --git a/README.md b/README.md
index b967bb9..77ae68c 100644
--- a/README.md
+++ b/README.md
@@ -21,14 +21,15 @@ I welcome and encourage contributions to this project upon review. Please check
### *Raison d'être*
-I started out this repository by implementing, translating and collecting code snippets from the *rare* available2,3,4,5 codes. Oftentimes papers are cryptical, codes are in C/C++ (requires compilation and major source code modification for general testing), or are just unavailable.
+I started out this repository by implementing, translating and collecting code snippets from the *rare* available2,3,4,5 codes. Oftentimes papers are cryptical, codes are in C/C++ (requires compilation and major source code modification for general testing), or are just unavailable. See, e.g. this CSDN post6 that has no valid links at all.
In this context, this repository aims to be a continous algorithmic aid for ongoing research and development of SIHR methods.
2 Tan and Ikeuchi. [Online]. Available:
3 Shen *et al.* [Online]. Available:
4 ~~Yang *et al.* [Online]. Available: ~~
-5 Shen and Zheng. [Online]. Available:
+5 Shen and Zheng. [Online]. Available:
+6 ~~https://blog.csdn.net/nvidiacuda/article/details/8078167~~
## Usage
@@ -95,9 +96,11 @@ Note: Akashi and Okatani's [10] method has highly fluctuating results because of
### Dataset
-In technical literature, there exist two ground truth datasets commonly used right now. One by Shen and Zheng [9] which is informally distributed alongside their code5, and one by Grosse *et al.* [12] in a dedicated page7. To the best of my knowledge, both are freely distributed without a license (it is of my understanding that the images implicitly exist solely for research purposes).
+In technical literature, there exist two ground truth datasets commonly used right now. One by Shen and Zheng [9] which is distributed alongside their code, and one by Grosse *et al.* [12] in a dedicated page7.
-As a part of the toolbox, I've included Tan and Ikeuchi's2 [4], Shen *et al.*'s3 [6] and Shen and Zheng's5 [9] test images in [`images`](https://github.com/vitorsr/SIHR/tree/master/images).
+Other test images are included alongside the code for Shen *et al.* [6] and Yang *et al.* [8].
+
+Follow the instructions in [`images`](https://github.com/vitorsr/SIHR/tree/master/images) in order to download a local copy of these images from the respective authors' pages.
7 Grosse *et al.* [Online]. Available:
@@ -105,66 +108,55 @@ As a part of the toolbox, I've included Tan and Ikeuchi's2 [4], Shen
Quantitative results reported are usually regarding the quality of the recovered diffuse component with respect to the ground truth available in the Shen and Zheng [9] test image set.
-Reproduced results below are available in the [`utils/my_quality.m`](https://github.com/vitorsr/SIHR/blob/master/utils/my_clip.m) script.
+Reproduced results below are available in the [`utils/my_quality.m`](https://github.com/vitorsr/SIHR/blob/master/utils/my_quality.m) script.
#### Highest (self and peer-reported | reproduced) PSNR results (in dB)
-|Year| Method | *animals* | *cups* | *fruit* | *masks* | Reproduced | *animals* | *cups* | *fruit* | *masks* |
-|:--:|--------------------|:---------:|:---------:|:---------:|:---------:|--------------------|:---------:|:------:|:-------:|:-------:|
-|2005| Tan and Ikeuchi | 30.2 | 30.1 | 29.6 | 25.6 | Tan and Ikeuchi | 30.4 | 31.6 | 30.4 | 25.8 |
-|2006| Yoon *et al.* | - | - | - | - | Yoon *et al.* | 32.9 | 33.3 | 36.6 | 34.1 |
-|2008| Shen *et al.* | 34.6 | 37.7 | 37.6 | 31.7 | Shen *et al.* | 34.2 | 37.5 | 38.0 | 32.1 |
-|2009| Shen and Cai | 34.8 | 37.6 | 36.9 | 34.0 | Shen and Cai | 34.9 | 37.6 | 36.7 | 34.0 |
-|2010| Yang *et al.* | *37.2* | 38.0 | 37.6 | 32.2 | Yang *et al.* | 36.5 | 37.5 | 36.2 | 33.5 |
-|2013| Shen and Zheng | **37.3** | **39.3** | *38.9* | 34.1 | Shen and Zheng | 37.5 | 38.3 | 38.2 | 32.7 |
-|2015| Liu *et al.* | 33.4 | 37.6 | 35.1 | **34.5** | - | - | - | - | - |
-|2016| Akashi and Okatani | 26.8 | 35.7 | 30.8 | 32.3 | Akashi and Okatani | 32.7 | 35.9 | 34.8 | 34.0 |
-|2016| Suo *et al.* | - | - | **40.4** | 34.2 | - | - | - | - | - |
-|2017| Ren *et al.* | - | 38.0 | 37.7 | **34.5** | - | - | - | - | - |
-|2018| Guo *et al.* | 35.7 | *39.1* | 36.4 | *34.4* | - | - | - | - | - |
+|Year| Method | *animals* | *cups* | *fruit* | *masks* | Reproduced | *animals* | *cups* | *fruit* | *masks* |
+|:--:|--------------------|:---------:|:---------:|:---------:|:---------:|--------------|:---------:|:------:|:-------:|:-------:|
+|2005| Tan and Ikeuchi | 30.2 | 30.1 | 29.6 | 25.6 | `Tan2005` | 30.4 | 31.6 | 30.4 | 25.8 |
+|2006| Yoon *et al.* | - | - | - | - | `Yoon2006` | 32.9 | 33.3 | 36.6 | 34.1 |
+|2008| Shen *et al.* | 34.6 | 37.7 | 37.6 | 31.7 | `Shen2008` | 34.2 | 37.5 | 38.0 | 32.1 |
+|2009| Shen and Cai | 34.8 | 37.6 | 36.9 | 34.0 | `Shen2009` | 34.9 | 37.6 | 36.7 | 34.0 |
+|2010| Yang *et al.* | *37.2* | 38.0 | 37.6 | 32.2 | `Yang2010` | 36.5 | 37.5 | 36.2 | 33.5 |
+|2013| Shen and Zheng | **37.3** | **39.3** | *38.9* | 34.1 | `Shen2013` | 37.5 | 38.3 | 38.2 | 32.7 |
+|2015| Liu *et al.* | 33.4 | 37.6 | 35.1 | **34.5** | - | - | - | - | - |
+|2016| Akashi and Okatani | 26.8 | 35.7 | 30.8 | 32.3 | `Akashi2016` | 32.7 | 35.9 | 34.8 | 34.0 |
+|2016| Suo *et al.* | - | - | **40.4** | 34.2 | - | - | - | - | - |
+|2017| Ren *et al.* | - | 38.0 | 37.7 | **34.5** | - | - | - | - | - |
+|2018| Guo *et al.* | 35.7 | *39.1* | 36.4 | *34.4* | - | - | - | - | - |
#### Highest (self and peer-reported | reproduced) SSIM results
-|Year| Method | *animals* | *cups* | *fruit* | *masks* | Reproduced | *animals* | *cups* | *fruit* | *masks* |
-|:--:|--------------------|:---------:|:---------:|:---------:|:---------:|--------------------|:---------:|:------:|:-------:|:-------:|
-|2005| Tan and Ikeuchi | 0.929 | 0.767 | 0.912 | 0.789 | Tan and Ikeuchi | 0.928 | 0.895 | 0.907 | 0.821 |
-|2006| Yoon *et al.* | - | - | - | - | Yoon *et al.* | 0.980 | 0.961 | 0.961 | 0.953 |
-|2008| Shen *et al.* | *0.974* | 0.962 | **0.961** | *0.943* | Shen *et al.* | 0.975 | 0.962 | 0.961 | 0.943 |
-|2009| Shen and Cai | - | - | - | - | Shen and Cai | 0.985 | 0.970 | 0.962 | 0.961 |
-|2010| Yang *et al.* | 0.970 | 0.941 | 0.939 | 0.899 | Yang *et al.* | 0.952 | 0.937 | 0.916 | 0.896 |
-|2013| Shen and Zheng | 0.971 | **0.966** | *0.960* | 0.941 | Shen and Zheng | 0.985 | 0.964 | 0.958 | 0.935 |
-|2015| Liu *et al.* | - | - | - | - | - | - | - | - | - |
-|2016| Akashi and Okatani | 0.802 | 0.937 | 0.765 | 0.657 | Akashi and Okatani | 0.7340 | 0.9190 | 0.9010 | 0.8710 |
-|2016| Suo *et al.* | - | - | - | - | - | - | - | - | - |
-|2017| Ren *et al.* | 0.896 | 0.957 | 0.952 | 0.913 | - | - | - | - | - |
-|2018| Guo *et al.* | **0.975** | *0.963* | 0.930 | **0.955** | - | - | - | - | - |
+|Year| Method | *animals* | *cups* | *fruit* | *masks* | Reproduced | *animals* | *cups* | *fruit* | *masks* |
+|:--:|--------------------|:---------:|:---------:|:---------:|:---------:|--------------|:---------:|:------:|:-------:|:-------:|
+|2005| Tan and Ikeuchi | 0.929 | 0.767 | 0.912 | 0.789 | `Tan2005` | 0.928 | 0.895 | 0.907 | 0.821 |
+|2006| Yoon *et al.* | - | - | - | - | `Yoon2006` | 0.980 | 0.961 | 0.961 | 0.953 |
+|2008| Shen *et al.* | *0.974* | 0.962 | **0.961** | *0.943* | `Shen2008` | 0.975 | 0.962 | 0.961 | 0.943 |
+|2009| Shen and Cai | - | - | - | - | `Shen2009` | 0.985 | 0.970 | 0.962 | 0.961 |
+|2010| Yang *et al.* | 0.970 | 0.941 | 0.939 | 0.899 | `Yang2010` | 0.952 | 0.937 | 0.916 | 0.896 |
+|2013| Shen and Zheng | 0.971 | **0.966** | *0.960* | 0.941 | `Shen2013` | 0.985 | 0.964 | 0.958 | 0.935 |
+|2015| Liu *et al.* | - | - | - | - | - | - | - | - | - |
+|2016| Akashi and Okatani | 0.802 | 0.937 | 0.765 | 0.657 | `Akashi2016` | 0.7340 | 0.9190 | 0.9010 | 0.8710 |
+|2016| Suo *et al.* | - | - | - | - | - | - | - | - | - |
+|2017| Ren *et al.* | 0.896 | 0.957 | 0.952 | 0.913 | - | - | - | - | - |
+|2018| Guo *et al.* | **0.975** | *0.963* | 0.930 | **0.955** | - | - | - | - | - |
## References
-1. R. T. Tan, “Specularity, Specular Reflectance,” in Computer Vision, Springer US, 2014, pp. 750–752 [Online]. Available:
-
-1. A. Artusi, F. Banterle, and D. Chetverikov, “A Survey of Specularity Removal Methods,” Computer Graphics Forum, vol. 30, no. 8, pp. 2208–2230, Aug. 2011 [Online]. Available:
-
-1. H. A. Khan, J.-B. Thomas, and J. Y. Hardeberg, “Analytical Survey of Highlight Detection in Color and Spectral Images,” in Lecture Notes in Computer Science, Springer International Publishing, 2017, pp. 197–208 [Online]. Available:
-
-1. R. T. Tan and K. Ikeuchi, “Separating reflection components of textured surfaces using a single image,” IEEE Transactions on Pattern Analysis and Machine Intelligence, vol. 27, no. 2, pp. 178–193, Feb. 2005 [Online]. Available:
-
-1. K. Yoon, Y. Choi, and I. S. Kweon, “Fast Separation of Reflection Components using a Specularity-Invariant Image Representation,” in 2006 International Conference on Image Processing, 2006 [Online]. Available:
-
-1. H.-L. Shen, H.-G. Zhang, S.-J. Shao, and J. H. Xin, “Chromaticity-based separation of reflection components in a single image,” Pattern Recognition, vol. 41, no. 8, pp. 2461–2469, Aug. 2008 [Online]. Available:
-
-1. H.-L. Shen and Q.-Y. Cai, “Simple and efficient method for specularity removal in an image,” Applied Optics, vol. 48, no. 14, p. 2711, May 2009 [Online]. Available:
-
-1. Q. Yang, S. Wang, and N. Ahuja, “Real-Time Specular Highlight Removal Using Bilateral Filtering,” in Computer Vision – ECCV 2010, Springer Berlin Heidelberg, 2010, pp. 87–100 [Online]. Available:
-
-1. H.-L. Shen and Z.-H. Zheng, “Real-time highlight removal using intensity ratio,” Applied Optics, vol. 52, no. 19, p. 4483, Jun. 2013 [Online]. Available:
-
-1. Y. Akashi and T. Okatani, “Separation of reflection components by sparse non-negative matrix factorization,” Computer Vision and Image Understanding, vol. 146, pp. 77–85, May 2016 [Online]. Available:
-
-1. T. Yamamoto and A. Nakazawa, “General Improvement Method of Specular Component Separation Using High-Emphasis Filter and Similarity Function,” ITE Transactions on Media Technology and Applications, vol. 7, no. 2, pp. 92–102, 2019 [Online]. Available:
-
-1. R. Grosse, M. K. Johnson, E. H. Adelson, and W. T. Freeman, “Ground truth dataset and baseline evaluations for intrinsic image algorithms,” in 2009 IEEE 12th International Conference on Computer Vision, 2009 [Online]. Available:
+1. R. T. Tan, “Specularity, Specular Reflectance,” in Computer Vision, Springer US, 2014, pp. 750–752 [Online]. Available: http://dx.doi.org/10.1007/978-0-387-31439-6_538
+1. A. Artusi, F. Banterle, and D. Chetverikov, “A Survey of Specularity Removal Methods,” Computer Graphics Forum, vol. 30, no. 8, pp. 2208–2230, Aug. 2011 [Online]. Available: http://dx.doi.org/10.1111/J.1467-8659.2011.01971.X
+1. H. A. Khan, J.-B. Thomas, and J. Y. Hardeberg, “Analytical Survey of Highlight Detection in Color and Spectral Images,” in Lecture Notes in Computer Science, Springer International Publishing, 2017, pp. 197–208 [Online]. Available: http://dx.doi.org/10.1007/978-3-319-56010-6_17
+1. R. T. Tan and K. Ikeuchi, “Separating reflection components of textured surfaces using a single image,” IEEE Transactions on Pattern Analysis and Machine Intelligence, vol. 27, no. 2, pp. 178–193, Feb. 2005 [Online]. Available: http://dx.doi.org/10.1109/TPAMI.2005.36
+1. K. Yoon, Y. Choi, and I. S. Kweon, “Fast Separation of Reflection Components using a Specularity-Invariant Image Representation,” in 2006 International Conference on Image Processing, 2006 [Online]. Available: http://dx.doi.org/10.1109/ICIP.2006.312650
+1. H.-L. Shen, H.-G. Zhang, S.-J. Shao, and J. H. Xin, “Chromaticity-based separation of reflection components in a single image,” Pattern Recognition, vol. 41, no. 8, pp. 2461–2469, Aug. 2008 [Online]. Available: http://dx.doi.org/10.1016/J.PATCOG.2008.01.026
+1. H.-L. Shen and Q.-Y. Cai, “Simple and efficient method for specularity removal in an image,” Applied Optics, vol. 48, no. 14, p. 2711, May 2009 [Online]. Available: http://dx.doi.org/10.1364/AO.48.002711
+1. Q. Yang, S. Wang, and N. Ahuja, “Real-Time Specular Highlight Removal Using Bilateral Filtering,” in Computer Vision – ECCV 2010, Springer Berlin Heidelberg, 2010, pp. 87–100 [Online]. Available: http://dx.doi.org/10.1007/978-3-642-15561-1_7
+1. H.-L. Shen and Z.-H. Zheng, “Real-time highlight removal using intensity ratio,” Applied Optics, vol. 52, no. 19, p. 4483, Jun. 2013 [Online]. Available: http://dx.doi.org/10.1364/AO.52.004483
+1. Y. Akashi and T. Okatani, “Separation of reflection components by sparse non-negative matrix factorization,” Computer Vision and Image Understanding, vol. 146, pp. 77–85, May 2016 [Online]. Available: http://dx.doi.org/10.1016/j.cviu.2015.09.001
+1. T. Yamamoto and A. Nakazawa, “General Improvement Method of Specular Component Separation Using High-Emphasis Filter and Similarity Function,” ITE Transactions on Media Technology and Applications, vol. 7, no. 2, pp. 92–102, 2019 [Online]. Available: http://dx.doi.org/10.3169/mta.7.92
+1. R. Grosse, M. K. Johnson, E. H. Adelson, and W. T. Freeman, “Ground truth dataset and baseline evaluations for intrinsic image algorithms,” in 2009 IEEE 12th International Conference on Computer Vision, 2009 [Online]. Available: http://dx.doi.org/10.1109/ICCV.2009.5459428
diff --git a/SIHR.m b/SIHR.m
index 6f88e0f..e66bd81 100644
--- a/SIHR.m
+++ b/SIHR.m
@@ -16,7 +16,7 @@
% SIHR % run it for a one-time session path setup
%
% API:
-% J = im2double(imread('synth.ppm')); % input image
+% J = im2double(imread('toys.ppm')); % input image
% J_d = Yang2010(J); % call AuthorYEAR method
% % e.g. Yang2010
% imshow([J, J_d, J - J_d]) % display result
@@ -58,8 +58,8 @@
if (is_octave)
assert(isempty(pkg('list', 'image')) == 0) % && ...
% isempty(pkg('list', 'statistics')) == 0)
- pkg unload image statistics
- pkg load image statistics
+ pkg unload image % statistics
+ pkg load image % statistics
else
assert(isequal(license('test', 'image_toolbox'), 1)) % && ...
% isequal(license('test', 'statistics_toolbox'), 1))
diff --git a/Shen2009/Shen2009.m b/Shen2009/Shen2009.m
index 3a685bd..6295574 100644
--- a/Shen2009/Shen2009.m
+++ b/Shen2009/Shen2009.m
@@ -1,9 +1,13 @@
function I_d = Shen2009(I)
%Shen2009 I_d = Shen2009(I)
-% This implementation was at one point distributed by the author as a
-% script. It was modified in order to conform with the toolbox and was
-% incorporated for completion.
-%
+% This method works by finding the largest highlight area, dilating it to
+% find the surrounding region, and then finding a coefficient that scales
+% how much the pseudo specular component will be subtracted from the
+% original image to find I_d.
+%
+% The nomenclature is in accordance with the corresponding paper with
+% exception of using I* instead of V* to denote an image.
+%
% See also SIHR, Shen2008, Shen2013.
assert(isa(I, 'float'), 'SIHR:I:notTypeSingleNorDouble', ...
@@ -16,58 +20,37 @@
assert(n_ch == 3, 'SIHR:I:notRGB', ...
'Input I is not a RGB image.')
-% Code for the following paper:
-% H. L. Shen, H. G. Zhang, S. J. Shao, and J. H. Xin,
-% Simple and Efficient Method for Specularity Removal in an Image,
-
-% clear; close all;
-
-% threshold_chroma = 0.03;
nu = 0.5;
-% I = imread('images\4k.bmp');
-% I = double(I);
-[height, width, dim] = size(I);
+I = reshape(I, n_row*n_col, 3);
-I3c = reshape(I, height*width, 3);
-% tic;
-% calculate specular-free image
-Imin = min(I3c, [], 2);
-% Imax = max(I3c, [], 2);
-Ithresh = mean(Imin) + nu * std(Imin);
-% Iss = I3c - repmat(Imin, 1, 3) .* (Imin > Ithresh) + Ithresh * (Imin > Ithresh);
+% Calculate specular-free image
+I_min = min(I, [], 2);
+T_v = mean(I_min) + nu * std(I_min);
+% I_MSF = I - repmat(I_min, 1, 3) .* (I_min > T_v) + T_v * (I_min > T_v);
-% calculate specular component
-IBeta = (Imin - Ithresh) .* (Imin > Ithresh) + 0;
+% Calculate specular component
+beta_s = (I_min - T_v) .* (I_min > T_v) + 0;
-% estimate largest region of highlight
-IHighlight = reshape(IBeta, height, width, 1);
+% Estimate largest region of highlight
+IHighlight = reshape(beta_s, n_row, n_col, 1);
IHighlight = mat2gray(IHighlight);
-IHighlight = im2bw(IHighlight, 0.1);
+IHighlight = im2bw(IHighlight, 0.1); %#ok
IDominantRegion = bwareafilt(IHighlight, 1, 'largest');
-% dilate largest region by 5 pixels to obtain its surrounding region
-se = strel('square',5);
+% Dilate largest region by 5 pixels to obtain its surrounding region
+se = strel('square', 5);
ISurroundingRegion = imdilate(IDominantRegion, se);
ISurroundingRegion = logical(imabsdiff(ISurroundingRegion, IDominantRegion));
% Solve least squares problem
-Vdom = mean(I3c(IDominantRegion, :));
-Vsur = mean(I3c(ISurroundingRegion, :));
-Betadom = mean(IBeta(IDominantRegion, :));
-Betasur = mean(IBeta(ISurroundingRegion, :));
-k = (Vsur - Vdom)/(Betasur - Betadom);
+I_dom = mean(I(IDominantRegion, :));
+I_sur = mean(I(ISurroundingRegion, :));
+beta_dom = mean(beta_s(IDominantRegion, :));
+beta_sur = mean(beta_s(ISurroundingRegion, :));
+k = (I_dom - I_sur) / (beta_dom - beta_sur);
% Estimate diffuse and specular components
-I_d = reshape(I3c - min(k) * IBeta, height, width, dim);
-
-%figure; imshow(uint8(reshape(I3c, height, width, dim))); title('original');
-%figure; imshow(uint8(reshape(Idf, height, width, dim))); title('diffuse component');
-%figure; imshow(uint8(reshape(Isp, height, width, dim))); title('specular component');
-
-
-%imwrite(uint8(reshape(Idf, height, width, dim)), 'comp_df.bmp', 'bmp');
-%imwrite(uint8(reshape(Isp, height, width, dim)), 'comp_sp.bmp', 'bmp');
-% toc;
+I_d = reshape(I-min(k)*beta_s, n_row, n_col, n_ch);
end
diff --git a/Yamamoto2019/Yamamoto2019.m b/Yamamoto2019/Yamamoto2019.m
index 7523ef3..1b6b095 100644
--- a/Yamamoto2019/Yamamoto2019.m
+++ b/Yamamoto2019/Yamamoto2019.m
@@ -6,7 +6,7 @@
% as a valid function handle, e.g. @Yang2010, @Shen2008.
%
% Example:
-% J = im2double(imread('synth.ppm'));
+% J = im2double(imread('toys.ppm'));
% J_d = Yamamoto2019(J, @Yoon2006);
% imshow(J_d)
%
diff --git a/Yoon2006/Yoon2006.m b/Yoon2006/Yoon2006.m
index 38c9071..aeeba3a 100644
--- a/Yoon2006/Yoon2006.m
+++ b/Yoon2006/Yoon2006.m
@@ -1,12 +1,13 @@
function I_d = Yoon2006(I)
%Yoon2006 I_d = Yoon2006(I)
-% This is a very subjective implementation of Yoon's method by me (Vtor).
+% This method operates by iteratively reducing or increasing a
+% neighboring pixel intensity.
%
-% It is ambiguous how they define neighborhood in which they operate, so I
+% It is ambiguous how they define the neighborhood in which they operate, so I
% have assumed they mean the next pixel when the image is represented in a
% lexicographic order.
%
-% It is specially slow in Octave because of the repeated iterated
+% This method is specially slow in Octave because of the repeated iterated
% accesses. Should take 1 s, but takes 10+ on Octave/Linux and 30+ on
% Octave/Windows. Ideally it should be made into a vectorized
% implementation.
@@ -27,17 +28,17 @@
assert(n_ch == 3, 'SIHR:I:notRGB', ...
'Input I is not a RGB image.')
-I_col = reshape(I, [n_row * n_col, n_ch]);
-Imin_col = min(I_col, [], 2);
-Isf_col = I_col - Imin_col;
+I = reshape(I, [n_row * n_col, n_ch]);
+I_min = min(I, [], 2);
+I_sf = I - I_min;
-Isfsum_col = sum(Isf_col, 2);
+sum_I_sf_ = sum(I_sf, 2);
-cr_col = Isf_col(:, 1) ./ Isfsum_col;
-cg_col = Isf_col(:, 2) ./ Isfsum_col;
+cr = I_sf(:, 1) ./ sum_I_sf_;
+cg = I_sf(:, 2) ./ sum_I_sf_;
-cr_col(isnan(cr_col)) = 0;
-cg_col(isnan(cg_col)) = 0;
+cr(isnan(cr)) = 0;
+cg(isnan(cg)) = 0;
skip = false([n_row * n_col - 1, 1]);
@@ -50,28 +51,28 @@
iter = uint16(0);
idx = (1:(n_row * n_col - 1))';
-skip(Isfsum_col(idx) == 0 ... % check if sum along rows ~= 0
- | Isfsum_col(idx+1) == 0) = true;
-skip(abs(cr_col(idx)-cr_col(idx+1)) > th_r ... % check discontinuities
- | abs(cg_col(idx)-cg_col(idx+1)) > th_g) = true;
+skip(sum_I_sf_(idx) == 0 ... % check if sum along rows ~= 0
+ | sum_I_sf_(idx+1) == 0) = true;
+skip(abs(cr(idx)-cr(idx+1)) > th_r ... % check discontinuities
+ | abs(cg(idx)-cg(idx+1)) > th_g) = true;
skip((1:n_row-1)*n_col) = true;
-skip(Imin_col(idx) < 12/255) = true;
+skip(I_min(idx) < 12/255) = true;
rd = ones([n_row * n_col - 1, 1]);
-rd(idx(~skip)) = sum(Isf_col(idx(~skip), :), 2) ...
- ./ sum(Isf_col(idx(~skip)+1, :), 2);
+rd(idx(~skip)) = sum(I_sf(idx(~skip), :), 2) ...
+ ./ sum(I_sf(idx(~skip)+1, :), 2);
rds = ones([n_row * n_col - 1, 1]);
while true
- rds(idx(~skip)) = sum(I_col((idx(~skip)), :), 2) ...
- ./ sum(I_col((idx(~skip))+1, :), 2);
+ rds(idx(~skip)) = sum(I((idx(~skip)), :), 2) ...
+ ./ sum(I((idx(~skip))+1, :), 2);
for x1 = 1:n_row * n_col - 1
x2 = x1 + 1;
if skip(x1)
continue
- elseif sum(I_col(x1,:), 2) == 0 || ...
- sum(I_col(x2,:), 2) == 0 % || ...
+ elseif sum(I(x1,:), 2) == 0 || ...
+ sum(I(x2,:), 2) == 0 % || ...
% (abs(cr_col(x1)-cr_col(x2)) > th_r && ...
% abs(cg_col(x1)-cg_col(x2)) > th_g)
skip(x1) = true;
@@ -79,19 +80,19 @@
end
% compare ratios and decrease intensity
if rds(x1) > rd(x1) % && rds ~= 1
- m = sum(I_col(x1, :), 2) - rd(x1) * sum(I_col(x2, :), 2);
+ m = sum(I(x1, :), 2) - rd(x1) * sum(I(x2, :), 2);
if m < 1e-3
continue
end
- I_col(x1, :) = I_col(x1, :)-m/3;
+ I(x1, :) = I(x1, :)-m/3;
%skip(x1) = true;
count = count + 1;
elseif rds(x1) < rd(x1) % && rd(x1) ~= 1
- m = sum(I_col(x2, :), 2) - sum(I_col(x1, :), 2) / rd(x1);
+ m = sum(I(x2, :), 2) - sum(I(x1, :), 2) / rd(x1);
if m < 1e-3
continue
end
- I_col(x2, :) = I_col(x2, :)-m/3;
+ I(x2, :) = I(x2, :)-m/3;
%skip(x2) = true;
count = count + 1;
end
@@ -103,6 +104,6 @@
iter = iter + 1;
end
-I_d = reshape(I_col, [n_row, n_col, n_ch]);
+I_d = reshape(I, [n_row, n_col, n_ch]);
end
diff --git a/images/README.md b/images/README.md
new file mode 100644
index 0000000..87ee49b
--- /dev/null
+++ b/images/README.md
@@ -0,0 +1,31 @@
+# `images`
+
+Download the zipped files from the archival links below which contain the codes for the methods of, respectively, Tan and Ikeuchi1, Shen *et al.*2, and Shen and Zheng3. Then, place the therein contained images inside this folder. See structure below.
+
+Note: the links were archived directly from the respective authors' pages (see link suffix) where their codes along with test images are freely distributed for research purposes.
+
+1 http://web.archive.org/web/20190828202158/https://tanrobby.github.io/code/highlight.zip
+2 http://web.archive.org/web/20190828202109/http://ivlab.org/publications/PR2008_code.zip
+3 http://web.archive.org/web/20190828202133/http://ivlab.org/publications/AO2013_code.zip
+
+The `images` folder should have the following structure.
+
+```
+README.md
+animals.bmp
+animals_gt.bmp
+cups.bmp
+cups_gt.bmp
+fish.ppm
+fruit.bmp
+fruit_gt.bmp
+head.ppm
+lady.bmp
+masks.bmp
+masks_gt.bmp
+rabbit.bmp
+toys.ppm
+train.bmp
+watermelon.bmp
+wood.bmp
+```