MATLAB Answers

Replace pixels in a matrix without using histeq

7 views (last 30 days)
Chrissie Nyssen
Chrissie Nyssen on 17 Jul 2019
Commented: Chrissie Nyssen on 17 Jul 2019
I have a greyscale image that is 291 x 240. I have been tasked with performing histogram equalization but WITHOUT using histeq. We have been told to use a nested for loop to access each pixel individually (yes, I KNOW that this is not ideal) and replace each value by a lookup table value, T. T is an array of 256 values in the range 0 - 255.
Here is the loop , but apparently the code in the loop does not produce the correct answer. Can anyone please suggest how else I apply T to the pixel I want to transform.
for i = 1:1:r %go through rows
for j = 1:1:c %columns
img_heq(i, j) = intlut(img (i,j), uint8(T));
end
end

  1 Comment

Chrissie Nyssen
Chrissie Nyssen on 17 Jul 2019
Sorry if this seems a trivial question but I am new to MATLAB and getting no help from elsewhere. All suggestions will be gratefully received and tried.

Sign in to comment.

Accepted Answer

Jan
Jan on 17 Jul 2019
for i = 1:1:r %go through rows
for j = 1:1:c %columns
img_heq(i, j) = T(img(i,j) + 1);
end
end

  3 Comments

KALYAN ACHARJYA
KALYAN ACHARJYA on 17 Jul 2019
@Jan Ohh look up table T is already given, which use to map the image, right..
Chrissie Nyssen
Chrissie Nyssen on 17 Jul 2019
Thank you both for your suggestions. I tried Jan's one, the output image and histogram looked right but unfortunately the autograder is still not accepting my answer :( but TY anyway. I will fiddle around with it some more.

Sign in to comment.

More Answers (0)

Sign in to answer this question.