2 views (last 30 days)

Show older comments

The following function creates a column vector and an image histogram:

function lutlum = lutlummer(image)

for i = 1:1:265

lutlum(i, 1) = i-1;

end

%multiplying the LUT with the luminescence histogram of the image

%Finding luminance image 'L' (Formula gained from class slides)

L = uint8(sum(bsxfun(@times,double(image),reshape([0.299 0.587 0.114],[1 1 3])),3));

%Finding luminance histogram'HL'

HL = histcounts(L,[0:256])';

lutlum = lutlum*HL;

end

The function is called with an image such that HL is a 1x2 matrix, so multiplying a 265x1 matrix ('lutlum') with a 1x2 matrix should be no problem. however, i still get this message:

Matrix dimensions must agree.

lutlum = lutlum.*HL;

Please do let me know where i am going wrong

thanking yall in advance!! :D

Sulaymon Eshkabilov
on 19 Sep 2021

There is an err, here is how it is to be:

lutlum = HL.'*lutlum; % creates 2 - by - 256

Sulaymon Eshkabilov
on 19 Sep 2021

There are a couple of errs in the code. Here is the corrected version:

function lutlum = lutlummer(image)

for i = 1:1:256 % Has to be 256 NOT 265. 256 similar to 265 :)

lutlum(i, 1) = i-1;

end

%multiplying the LUT with the luminescence histogram of the image

%Finding luminance image 'L' (Formula gained from class slides)

L = uint8(sum(bsxfun(@times,double(image),reshape([0.299 0.587 0.114],[1 1 3])),3));

%Finding luminance histogram'HL'

HL = histcounts(L,[0:256])'; % Note the size of HL is 256 - by - 1 NOT [1 - by - 2] as you have stated

lutlum = lutlum*HL'; % Transpose is necessary

end

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

Start Hunting!