这个调整简单来说就是先建立一张lookup table, 然后以图像的灰度值作为索引,映射得到相应的颜色值。图像的灰度值是由图像本身决定的,但是lookup table 却可以各种各样,所以不同的lookup table 就能使图像最终呈现的色彩不一样。

clc;
clear all;
close all;
Image=imread('4.jpg');
size_info=size(Image);  
height=size_info(1);  
width=size_info(2);  

%% 图像转为灰度图
Gray_Img=rgb2gray(Image);


%% 建立 lookup table
row=50;
col=256;
Color(:,:,1)=rand(row,col);
Color(:,:,2)=rand(row,col);
Color(:,:,3)=rand(row,col);

for index=1:col
        val=index/col;
        %% color 1
% % %         Color(:,index,1)=3*(val);
% % %         Color(:,index,2)=3*(val)-1;
% % %         Color(:,index,3)=3*(val)-1;
       %% color 2
        Color(:,index,1)=sin(val);
        Color(:,index,2)=sin(val/2);
        Color(:,index,3)=sin(val/3);
        %% color 3
% % %         Color(:,index,1)=val;
% % %         Color(:,index,2)=val;
% % %         Color(:,index,3)=0;
end

figure, imshow(Color);

%% 以灰度值为索引,映射得到相应的颜色值。
Image_new=double(Image);
for ii=1:height
    for jj=1:width
        index=Gray_Img(ii,jj);
        Image_new(ii,jj,:)=Color(1, index, :);
    end
end

figure, imshow(Image_new);

原图:

PS 图像调整算法— —渐变映射

不同的lookup table 生成不同的图

PS 图像调整算法— —渐变映射

PS 图像调整算法— —渐变映射

PS 图像调整算法— —渐变映射

PS 图像调整算法— —渐变映射

相关文章:

  • 2021-11-30
  • 2021-05-19
  • 2021-06-19
  • 2021-03-31
  • 2021-08-06
  • 2022-12-23
猜你喜欢
  • 2021-12-06
  • 2021-06-26
  • 2021-12-10
  • 2022-12-23
  • 2021-05-02
相关资源
相似解决方案