Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Matlab, image, log function undefined for uint8

60 views
Skip to first unread message

leko...@yahoo.com

unread,
Sep 16, 2007, 2:47:44 PM9/16/07
to
Hi,

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

Giuseppe Rossini

unread,
Sep 16, 2007, 3:18:08 PM9/16/07
to
leko...@yahoo.com wrote in message
<1189968464....@w3g2000hsg.googlegroups.com>...

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

Dave Robinson

unread,
Sep 17, 2007, 4:39:27 AM9/17/07
to
"Giuseppe Rossini" <marca...@inwind.it> wrote in message
<fcjvhf$9pf$1...@fred.mathworks.com>...

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

Penny Anderson

unread,
Sep 17, 2007, 3:16:23 PM9/17/07
to
"Dave Robinson" <dave.r...@somewhere.biz> wrote in message
news:fclefv$b3q$1...@fred.mathworks.com...

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.


S. Masih

unread,
Sep 27, 2009, 12:39:03 PM9/27/09
to
Hi,
when I transform my image into log scale, I face problems showing that image with the following error:
>> M=double(imread('Mammogram.jpeg'));
>> LogM=log(1/512+M);
>> imshow(LogM,[])
??? Error using ==> checkDisplayRange at 22
HIGH must be greater than LOW.

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

Ishtiaq Ahmad

unread,
Oct 19, 2009, 3:11:00 AM10/19/09
to
Convert image1 in to double by
"image1=double(image1)" then take log i.e.
s(i,j)=log(image1(i,j))

Chears

Murat

unread,
Nov 8, 2011, 11:51:26 AM11/8/11
to
logIM = log(1+double(imread('cameraman.tif')));
imagesc(logIM), colormap gray

Murat

unread,
Nov 8, 2011, 11:53:10 AM11/8/11
to
0 new messages