Check for incorrect argument data type or missing argument in call to function 'log'.

function [BrightImage] = Brightness(image , val)
[row , col, depth] = size(image);
BrightImage = zeros(row,col);
BrightImage = im2double(BrightImage);
for r = 1:row
for c = 1:col
BrightImage(r,c) = val * log(image(r,c) + 1);
end
end
BrightImage = im2uint8(BrightImage);
end

댓글 수: 1

What is your question? What are the inputs you provide to this function? Do you get an error message? Then please post a copy of the complete message.
This part looks strange:
BrightImage = zeros(row,col);
BrightImage = im2double(BrightImage);
BrightImage is a double matrix and with im2double you convert it to a double array, but this does not change anything.
What happens with the 3rd dimension depth?
You ran replace:
BrightImage = zeros(row,col);
BrightImage = im2double(BrightImage);
for r = 1:row
for c = 1:col
BrightImage(r,c) = val * log(image(r,c) + 1);
end
end
by the much simpler:
BrightImage = val * log(image + 1);
but this does not change the error.

댓글을 달려면 로그인하십시오.

답변 (1개)

I suspect your image variable (which you probably want to rename, as image already has a meaning in MATLAB) is one of the eight integer data types in MATLAB. The log function is not defined for any of the integer data types.
z = zeros('int8');
which -all log(z)
'log(z)' not found.
It is defined for double and single precision data as you can see from the code below.
d = 0;
which -all log(d)
built-in (/MATLAB/toolbox/matlab/elfun/@double/log) % double method
s = 0;
which -all log(s)
built-in (/MATLAB/toolbox/matlab/elfun/@double/log) % double method
If you were to try to call log on z then MATLAB will throw an error. [The exact error message appears to have changed between release R2021a and the current release.]
y = log(z)
Incorrect number or types of inputs or outputs for function 'log'.
Convert your data to double or single precision if you need to take its logarithm.

카테고리

도움말 센터File Exchange에서 Convert Image Type에 대해 자세히 알아보기

제품

릴리스

R2021a

질문:

2022년 11월 1일

댓글:

Jan
2022년 11월 1일

Community Treasure Hunt

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

Start Hunting!

Translated by