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

Difference between double() and im2double()

311 views
Skip to first unread message

Sahil

unread,
Oct 28, 2010, 7:01:03 PM10/28/10
to
I'm confused between double() and im2double(). For image processing operations, when do I use which one?
Thanks!

Nathan

unread,
Oct 28, 2010, 8:08:02 PM10/28/10
to
On Oct 28, 4:01 pm, "Sahil " <ssa...@andrew.cmu.edu> wrote:
> I'm confused between double() and im2double(). For image processing operations, when do I use which one?
> Thanks!

From the im2double doc:

"I2 = im2double(I) converts the intensity image I to double precision,
rescaling the data if necessary."

"RGB2 = im2double(RGB) converts the truecolor image RGB to double
precision, rescaling the data if necessary."

"X2 = im2double(X,'indexed') converts the indexed image X to double
precision, offsetting the data if necessary."

Using im2double will rescale the data (if necessary) from your image.
Using double won't. I think that's the only difference.

-Nathan

ImageAnalyst

unread,
Oct 28, 2010, 8:19:48 PM10/28/10
to
Yeah, it's not well described. But a simple test will show you that
when you use im2double, it will convert your uint8 image from the
range of 0-255 into a double array in the range 0-1. In general, all
Image Processing Toolbox functions that take floating point arrays
want them in the range of 0 to 1. I find it kind of annoying but
that's the way it is. That's basically what "rescaling" means. So
this imdouble() function is there to help you get to what you might
need for later calls to Image Processing Toolbox functions. If you
use double() you would have to divide by 255 yourself if you needed
to. If you're doing your own custom functions then you can leave it
in the original range if you want.
0 new messages