資源簡介
使用Matlab給灰度圖像上色的 Gray2RGB 函數(shù),需要額外提供一張配色接近的圖片。
該原始算法源于Jeny Rajan , Chandrashekar,但其運(yùn)行速度過慢,我做了一些Matlab特有的小優(yōu)化,大大提高了運(yùn)行速度。
該原始算法源于Jeny Rajan , Chandrashekar,但其運(yùn)行速度過慢,我做了一些Matlab特有的小優(yōu)化,大大提高了運(yùn)行速度。
代碼片段和文件信息
function?R=gray2rgb(img1img2)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% This?Program?converts?a?gray?image?ro?RGB?image?based?on?the?colors?of?the?destination?image.?The better?the?destination?image?match?with?the?source?gray?image?the?better?the?coloring?will?be.?The?program?takes?some?time??as?the?searching?time?is?high.?You?can?decrease?the?searching?time?by?taking only?samples?from?the?used?color?image?but?quality?may?decrease.?U?can?use?jittered?sampling?for?improving?running?speed.?%?
%??You?can?use?also?use?the?attahed?test?images?Use?the?following?combinations?for?better?result nature1.jpg(as?img1)?and?nature2.jpg(as?img2)?or?test1.jpg(as?img1)?and?test2.jpg?(as?img2) %
% Usage:?gray2rgb(‘nature1.jpg‘‘nature2.jpg‘);??%
%??Authors?:?Jeny Rajan??Chandrashekar P.S?%
%??鄙人做了一點(diǎn)微小的優(yōu)化。????????????????P.S?%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%?img1?-?Source?Image??(gray?image)???
%?img2?-?Selected?color?image?for?coloring?the?gray?image.?
%%?導(dǎo)入
?tic;clc;
?warning?off;
?imG=imread(img1);
?imR=imread(img2);
?[txtytz]=size(imG);
?[sxsysz]=size(imR);
?
?if?tz~=1
?????imG=rgb2gray(imG);
?end
?imG(::2)=imG(::1);
- 上一篇:蝙蝠算法BA代碼
- 下一篇:根據(jù)亮度分布檢測火焰
評論
共有 條評論