用MATLAB实现对灰度图像到彩色图像的变换?
部分程序,希望补全。I=imread(‘i_boat.bmp’);I=double(I);[m,n]=size(I);L=256;fori=1:mforj=1:nifI(...
部分程序,希望补全。
I=imread(‘i_boat.bmp’);
I=double(I);
[m,n]=size(I);
L=256;
for i=1:m
for j=1:n
if I(i,j)<L/4
R(i,j)=0;
G(i,j)=4*I(i,j);
B(i,j)=L;
else if I(i,j)<=L/2
R(i,j)=0;
G(i,j)=L;
B(i,j)=-4*I(i,j)+2*L;
else if I(i,j)<=3*L/4
R(i,j)=4*I(i,j)-2*L;
G(i,j)=L;
B(i,j)=0;
else
R(i,j)=L;
G(i,j)=-4*I(i,j)+4*L;
B(i,j)=0;
end
end
end
end
end
for i=1:m
for j=1:n
G2C(i,j,1)=R(i,j);
G2C(i,j,2)=G(i,j);
G2C(i,j,3)=B(i,j);
end
end
G2C=G2C/256 展开
I=imread(‘i_boat.bmp’);
I=double(I);
[m,n]=size(I);
L=256;
for i=1:m
for j=1:n
if I(i,j)<L/4
R(i,j)=0;
G(i,j)=4*I(i,j);
B(i,j)=L;
else if I(i,j)<=L/2
R(i,j)=0;
G(i,j)=L;
B(i,j)=-4*I(i,j)+2*L;
else if I(i,j)<=3*L/4
R(i,j)=4*I(i,j)-2*L;
G(i,j)=L;
B(i,j)=0;
else
R(i,j)=L;
G(i,j)=-4*I(i,j)+4*L;
B(i,j)=0;
end
end
end
end
end
for i=1:m
for j=1:n
G2C(i,j,1)=R(i,j);
G2C(i,j,2)=G(i,j);
G2C(i,j,3)=B(i,j);
end
end
G2C=G2C/256 展开
1个回答
2011-12-13
展开全部
clear all;close all;clc;
I=imread('i_boat.jpg');
imshow(I);
I=double(I);
[m,n]=size(I);
L=256;
for i=1:m
for j=1:n
if I(i,j)<L/4
R(i,j)=0;
G(i,j)=4*I(i,j);
B(i,j)=L;
else if I(i,j)<=L/2
R(i,j)=0;
G(i,j)=L;
B(i,j)=-4*I(i,j)+2*L;
else if I(i,j)<=3*L/4
R(i,j)=4*I(i,j)-2*L;
G(i,j)=L;
B(i,j)=0;
else
R(i,j)=L;
G(i,j)=-4*I(i,j)+4*L;
B(i,j)=0;
end
end
end
end
end
for i=1:m
for j=1:n
G2C(i,j,1)=R(i,j);
G2C(i,j,2)=G(i,j);
G2C(i,j,3)=B(i,j);
end
end
G2C=G2C/256;
figure
imshow(G2C)
G2C=rgb2gray(G2C)
figure
imshow(G2C)
I=imread('i_boat.jpg');
imshow(I);
I=double(I);
[m,n]=size(I);
L=256;
for i=1:m
for j=1:n
if I(i,j)<L/4
R(i,j)=0;
G(i,j)=4*I(i,j);
B(i,j)=L;
else if I(i,j)<=L/2
R(i,j)=0;
G(i,j)=L;
B(i,j)=-4*I(i,j)+2*L;
else if I(i,j)<=3*L/4
R(i,j)=4*I(i,j)-2*L;
G(i,j)=L;
B(i,j)=0;
else
R(i,j)=L;
G(i,j)=-4*I(i,j)+4*L;
B(i,j)=0;
end
end
end
end
end
for i=1:m
for j=1:n
G2C(i,j,1)=R(i,j);
G2C(i,j,2)=G(i,j);
G2C(i,j,3)=B(i,j);
end
end
G2C=G2C/256;
figure
imshow(G2C)
G2C=rgb2gray(G2C)
figure
imshow(G2C)
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |