I am trying to get a log value for an image. This is what I have done
so far...
image1=imread(image.jpg)
[m,n]=size(image1)
for j=1:n
for i=1:m
s(i,j)=log(image1(i,j))
end
end
When i do this I get an error msg saying 'log' is not defined for
values of class 'uint8'. How can I correct this.
Thanks,
LS
Hi,
the answer is very simple:
use this line:
image1=double(imread(image.jpg));
this call transform your image (that is an uint8 matrix) in
a double matrix
Well very nearly. You will still run into nasties when you
hit a black pixel (i.e. has an intensity of zero) as the
log of 0 is not defined. One of the solutions is to do a
logical indexing on your double image array, and replace
all 0 pixels with an arbitrary small number, say something
like 1/512, (which is half your image LSB)then log it.
Regards
Dave Robinson
To customize this, or any similar operatin in MATLAB, write your own
@uint8/log.m
function that does exactly what you want, including on 0 input values. Put
it in a directory on your path and any calls to log with uint8 input will be
intercepted by this function.
For bonus points, share with the newsgroup your function so we can see
exactly what you want log(uint8) to do.
Penny.
Error in ==> imageDisplayValidateParams at 57
common_args.DisplayRange = checkDisplayRange(common_args.DisplayRange,mfilename);
Error in ==> imageDisplayParseInputs at 79
common_args = imageDisplayValidateParams(common_args);
Error in ==> imshow at 199
[common_args,specific_args] = ...
How can I solve this problem?
Thanks for your attention
Chears
leko...@yahoo.com wrote in message <1189968464....@w3g2000hsg.googlegroups.com>...