matlab如何做如下图片处理

如何将灰度图片不同亮度处理成彩色图形式,并用不同颜色标记... 如何将灰度图片不同亮度处理成彩色图形式,并用不同颜色标记 展开
 我来答
真greatdju
2019-01-30 · TA获得超过3856个赞
知道小有建树答主
回答量:1300
采纳率:91%
帮助的人:760万
展开全部
clear;clc
[x,y]=meshgrid(linspace(-1,1,512));
A=1-sqrt((x.^2+y.^2));
A=uint8(255*A);
subplot 121
imshow(A)
subplot 122
imshow(A,'colormap',[[zeros(32,2),linspace(.3,.5,32)'];jet(256);[linspace(.5,1,32);linspace(0,1,32);linspace(0,1,32)]'])

leeming6666
2019-01-30 · TA获得超过3453个赞
知道大有可为答主
回答量:3240
采纳率:85%
帮助的人:732万
展开全部
function R=gray2rgb(img1,img2)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%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 %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% img1 - Source Image (gray image)
% img2 - Selected color image for coloring the gray image.
tic
clc;
warning off;
imt=imread(img1);
ims=imread(img2);
[sx sy sz]=size(imt);
[tx ty tz]=size(ims);
if sz~=1
imt=rgb2gray(imt);
end
if tz~=3
disp ('img2 must be a color image (not indexed)');
else
imt(:,:,2)=imt(:,:,1);
imt(:,:,3)=imt(:,:,1);

% Converting to ycbcr color space
nspace1=rgb2ycbcr(ims);
nspace2= rgb2ycbcr(imt);

ms=double(nspace1(:,:,1));
mt=double(nspace2(:,:,1));
m1=max(max(ms));
m2=min(min(ms));
m3=max(max(mt));
m4=min(min(mt));
d1=m1-m2;
d2=m3-m4;
% Normalization
dx1=ms;
dx2=mt;
dx1=(dx1*255)/(255-d1);
dx2=(dx2*255)/(255-d2);
[mx,my,mz]=size(dx2);
%Luminance Comparison
disp('Please wait..................');
for i=1:mx
for j=1:my
iy=dx2(i,j);
tmp=abs(dx1-iy);
ck=min(min(tmp));
[r,c] = find(tmp==ck);
ck=isempty(r);
if (ck~=1)
nimage(i,j,2)=nspace1(r(1),c(1),2);
nimage(i,j,3)=nspace1(r(1),c(1),3);
nimage(i,j,1)=nspace2(i,j,1);
end
end
end
rslt=ycbcr2rgb(nimage)
figure,imshow(uint8(imt));
figure,imshow(uint8(rslt));
R=uint8(rslt);
toc
end
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
别抢我辣条啦4326
2019-01-30 · 贡献了超过222个回答
知道答主
回答量:222
采纳率:3%
帮助的人:19.1万
展开全部
有啊。、、看简介
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 2条折叠回答
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式