Undefined function 'log' for input arguments of type 'uint8'

被刻印的时光 ゝ 提交于 2019-12-12 16:09:06

问题


i have been trying generate an image.

C1 = imread(InputImage);
NumberOfGrayLevels=32;
I= 0.299*C1(:,:,1)+0.587*C1(:,:,2)+0.114*C1(:,:,3);
C = 0;
I=(C*log(I+1))';
new=uint8(mat2gray(I)*(NumberOfGrayLevels-1));
[m,n]= size(new);
rgb = zeros(m,n,3);
rgb(:,:,1) = new;
rgb(:,:,2) = rgb(:,:,1);
rgb(:,:,3) = rgb(:,:,2);
new = rgb/256;
imshow(new,[]);

no9=figure;
image(new);

the error is showing at I=(C*log(I+1))';..can you tell me how to solve this?


回答1:


Most probably C1 is of type uint8. You should convert it, i.e.:

C1 = imread(InputImage);
C1 = double(C1);
NumberOfGrayLevels = 32;
I = 0.299*C1(:,:,1) + 0.587*C1(:,:,2) + 0.114*C1(:,:,3);
.....

if you don't convert C1 to double, then I will also be of type uint8 - it will not contain what you want and log function will not work with it.



来源:https://stackoverflow.com/questions/14904030/undefined-function-log-for-input-arguments-of-type-uint8

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!