SPDecolor.m

SPDecolor - contrast preserving color to gray by Semi-Parametric optimization
140 Downloads
Updated 3 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 (2024). 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
Categories
Find more on Modify Image Colors in Help Center and MATLAB Answers

Community Treasure Hunt

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

Start Hunting!
Version Published Release Notes
1.0.0.0