'uint8' 类型的输入参数的未定义函数 'log' [英] Undefined function 'log' for input arguments of type 'uint8'

查看:47
本文介绍了'uint8' 类型的输入参数的未定义函数 'log'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试生成图像.

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);

错误显示在 I=(C*log(I+1))';...你能告诉我如何解决这个问题吗?

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

推荐答案

很可能 C1uint8 类型.你应该转换它,即:

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);
.....

如果你不将 C1 转换为 double,那么 I 也将是 uint8 类型 -它不会包含您想要的内容,并且 log 函数将无法使用它.

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.

这篇关于'uint8' 类型的输入参数的未定义函数 'log'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆