Check for incorrect argument data type or missing argument in call to function 'log'.
Afficher commentaires plus anciens
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 commentaire
Jan
le 1 Nov 2022
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.
Réponses (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)
It is defined for double and single precision data as you can see from the code below.
d = 0;
which -all log(d)
s = 0;
which -all log(s)
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)
Convert your data to double or single precision if you need to take its logarithm.
Catégories
En savoir plus sur Convert Image Type dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!