image thumbnail

SPDecolor.m

version 1.0.0.0 (4.68 KB) by Qiegen Liu
SPDecolor - contrast preserving color to gray by Semi-Parametric optimization

132 Downloads

Updated 03 Feb 2016

View License

%SPDecolor - contrast preserving color to gray by Semi-Parametric optimization
% S = SPDecolor(Im, sigma) performs contrast preserving decolorization
% on color image Im, with controling parameter sigma
%
% Paras:
% @Im : Input image (double), only color images are acceptable.
% @sigma : Controlling parameter defined in [1]. 5e-3 by default.
%
% Example
% ==========
% Im = im2double(imread('5.png'));
% gIm = SPDecolor(Im); % Default Parameters (sigma = 1e-2)
% figure, imshow(Im), figure, imshow(gIm);
clear all;close all;

%input image
Im = im2double(imread('5.png'));

%process image
gIm1 = cprgb2gray(Im);
gIm2 = rgb2gray(Im);
gIm3 = SPDecolor(Im);

%display image
figure(2000), imshow([Im,repmat([gIm1,gIm2,gIm3],[1,1,3])]);

Cite As

Qiegen Liu (2021). SPDecolor.m (https://www.mathworks.com/matlabcentral/fileexchange/55220-spdecolor-m), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2010a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!