4
votes

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
What language is this? Please replace one of your tags with the appropriate language tag. - Barmar

1 Answers

3
votes

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.