在对图像执行直方图均衡后,我很难理解如何更改灰度 GIF 图像的颜色图。对于没有关联颜色图的图像压缩类型(例如 JPEG),该过程非常简单,而且我已经让它与灰度 JPEG 图像一起使用。
clear
clc
[I,map] = imread('moon.gif');
h = zeros(256,1); %array value holds number of pixels with same value
hmap = zeros(256,1);
P = zeros(256,1); %probability that pixel intensity will appear in image
Pmap = zeros(256,1);
s = zeros(256,1); %calculated CDF using P
smap = zeros(256,1);
M = size(I,1);
N = size(I,2);
I = double(I);
Inew = double(zeros(M,N));
mapnew = zeros(256,3);
for x = 1:M;
for y = 1:N;
for l = 1:256;
%count pixel intensities and probability
end
end
end
for j = 2:256
for i = 2:j
%calculate CDF of P
end
end
s(1) = P(1);
smap(1) = Pmap(1);
for x = 1:M;
for y = 1:N;
for l = 1:256;
%calculates adjusted CDF and sets it to new image
end
end
end
mapnew = mapnew/256;
Inew = uint8(Inew);
I = uint8(I);
subplot(1,2,1), imshow(Inew,map); %comparing the difference between original map
subplot(1,2,2), imshow(Inew,mapnew); %to'enhanced' colormap, but both turn out poorly
就实际图像的均衡而言,一切都很好,但我不确定要对颜色图进行哪些更改。我尝试在颜色图上执行与图像相同的操作,但没有骰子。
抱歉,由于我的代表率低,我无法发布图片,但我会尽力根据要求提供所有信息。
任何帮助将不胜感激。