GcsDecolor2
%% The Code is created based on the method described in the following papers:
% [1] Q. Liu, P.X. Liu, W. Xie, Y. Wang, D. Liang, “GcsDecolor: Gradient correlation similarity for efficient contrast preserving decolorization,”
% IEEE Trans. Image Process., vol. 24, no. 9, pp. 2889-2904, 2015.
% Author: Q. Liu, P.X. Liu, W. Xie, Y. Wang, D. Liang
% Date : 02/7/2016
% Version : 1.0
% The code and the algorithm are for non-comercial use only.
% Copyright 2016, Department of Electronic Information Engineering, Nanchang University.
% The current version is not optimized.
% GcsDecolor2 - contrast preserving color-to-gray via Gradient correlation similarity
% S = GcsDecolor2(Im, Lpp) performs contrast preserving decolorization
% on color image Im, with controling parameter Lpp
%
% Paras:
% @Im : Input image (double), only color images are acceptable.
% @Lpp : Controlling parameter defined in [1]. 0.25 by default.
%
% Example
% ==========
% Im = im2double(imread('23.png'));
% gIm = GcsDecolor2(Im); % Default Parameters (Lpp = 0.25)
% figure, imshow(Im), figure, imshow(gIm);
% Example 2
for imgindx = 1:24
Im = im2double(imread(Imname{imgindx}));
[gIm0,Es0,bw0] = GcsDecolor2(Im,0.01);
[gIm1,Es1,bw1] = GcsDecolor2(Im,0.05);
[gIm2,Es2,bw2] = GcsDecolor2(Im,0.1);
[gIm3,Es3,bw3] = GcsDecolor2(Im,0.2);
[gIm4,Es4,bw4] = GcsDecolor2(Im,0.5);
[gIm5,Es5,bw5] = GcsDecolor2(Im,1);
gIm0 = (gIm0- min(gIm0(:)))/(max(gIm0(:)) - min(gIm0(:)));
gIm1 = (gIm1- min(gIm1(:)))/(max(gIm1(:)) - min(gIm1(:)));
gIm2 = (gIm2- min(gIm2(:)))/(max(gIm2(:)) - min(gIm2(:)));
gIm3 = (gIm3- min(gIm3(:)))/(max(gIm3(:)) - min(gIm3(:)));
gIm4 = (gIm4- min(gIm4(:)))/(max(gIm4(:)) - min(gIm4(:)));
gIm5 = (gIm5- min(gIm5(:)))/(max(gIm5(:)) - min(gIm5(:)));
figure(1000+imgindx), imshow([gIm0,gIm1,gIm2,gIm3,gIm4,gIm5]);
end
Cite As
Qiegen Liu (2026). GcsDecolor2 (https://www.mathworks.com/matlabcentral/fileexchange/55293-gcsdecolor2), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform Compatibility
Windows macOS LinuxCategories
- MATLAB > Graphics > Images > Modify Image Colors >
Tags
Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.
| Version | Published | Release Notes | |
|---|---|---|---|
| 1.0.0.0 |
