matlab - 在GIF图像上,MATLAB直方图均衡

  显示原文与译文双语对照的内容
0 0

在对图像进行直方图均衡之后,我有一点理解如何更改灰度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

在实际图像的均衡方面,全部都是很好的,但是我不确定该怎么改变颜色图。 我试图在图像上执行相同的操作,但是没有骰子。

对不起,我不能发布我的低代表的图像,但是我会试着提供所有可以请求的信息。

任何帮助都将非常有用。

时间: 原作者:

0 0

function J=histeqo(I)

 J=I;
 [m,n]=size(I);
 [h,d]=imhist(I);
 ch=cumsum(h);//The cumulative frequency
 imagesize=(m*n);//The image size lightsize=size(d,1);//The Lighting range
 tr=ch*(lightsize/imagesize);//Adjustment function

 for x=1:m
 for y=1:n
 J(x,y)=tr(I(x,y)+1);
 end
 end
 subplot(1,2,1);imshow(J);
 subplot(1,2,2);imhist(J);
end

原作者:
...