# Code computes histogram equalization not similar to Matlab's histeq function

3 visualizaciones (últimos 30 días)
Mohsin Shah el 5 de Mayo de 2018
Respondida: xiao el 11 de Mayo de 2018
I have a written a simple code for histogram equalization based on this formula: HistEq = (max gray leve/total no of pixels)*cumulative sum(count). I wonder why the result is quite different from Matlab's function histeq? Can someone please figure out where I am wrong?
clear;
clc;
% Input image
I = double(Img);
[H, W] = size(I);
total = H * W;
count = imhist(Img);
maxL = 255;
csum = 0; % Initialize to zero
cumuSum = zeros(1, length(count))';
for idx = 1 : length(count)
csum = csum + count(idx);
cumuSum(idx) = csum;
end
HistEq = round(maxL/total * cumuSum);
HIm = zeros(H, W);
for idx = 1 : H
for idy = 1 : W
HIm(idx, idy) = HistEq(Img(idx, idy));
end
end
<<
>>
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

### Respuestas (1)

xiao el 11 de Mayo de 2018
you can refer the function (histogram equalization) doc page and there are related references, then you can check the algorithm details.
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

### Categorías

Más información sobre Histograms en Help Center y File Exchange.

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by