Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9176225
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T17:04:01+00:00 2026-06-17T17:04:01+00:00

Can you explain the inconsisent behaviour of matlab im2double function? Basically this function given

  • 0

Can you explain the inconsisent behaviour of matlab im2double function?
Basically this function given as input a matrix A of int it normalizes the values in the range 0…1:

Example:

I1 = reshape(uint8(linspace(1,255,9)),[3 3])
I2 = im2double(I1)

I1 =

    1   96  192
   33  128  223
   65  160  255


I2 =

    0.0039    0.3765    0.7529
    0.1294    0.5020    0.8745
    0.2549    0.6275    1.0000

But now If i provide a matrix of double:

I1 =

    0.1000    0.2000
    1.5000    2.2000

The result of im2double is the same matrix I1 (so without any normalization). Can I understand this inconsisent behaviour?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T17:04:02+00:00Added an answer on June 17, 2026 at 5:04 pm

    Type help im2double. The first few lines are

    IM2DOUBLE takes an image as input, and returns an image of class
    double. If
    the input image is of class double, the output image is identical to it. If
    the input image is not double, IM2DOUBLE returns the equivalent image of
    class double, rescaling or offsetting the data as necessary.

    So the behavior is intended. Indeed, when opening im2double.m in the editor, you’ll see

    function d = im2double(img, typestr)
    ...
    if isa(img, 'double')
        d = img;
    ...
    
    end
    

    Whether it is intuitive, well, that’s debatable 🙂

    Anyway, there’s a good reason for this behavior. With inputs of type int8 you know what the ceiling is (255). With that information you can re-scale the output (values/255). Similar for int16 (values/65535), etc.

    However, when you’re given a double, you don’t have a realistic ceiling anymore. For most double values, values/realmax << realmin, so there’s little sense in re-scaling.

    You could argue that 255 would be a good default to scale to, with a warning saying that if 16-bit data is intended, you should give an extra argument or so. But well…that gets ugly and makes the function needlessly complicated. I for one can understand Mathworks’ decision to keep the original in such events.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I hope I can explain this right I have two input fields that require
Who can explain this, please? In my function, I use .remove() to remove one
Who can explain or give a good reference for understanding this example: int a=1;
anyone can explain me, why this parts of code are acting differently? while((c =
I hope I can explain this problem right, it's a bit confusing for me.
I hope this I can explain what I am trying to achieve: I want
I hope I can explain this well enough so that you can understand the
I hope I can explain this properly. I'm using flashDevelop for an avatar creation
Not sure if I can explain this correctly, but I am trying to execute
Who can explain the following behaviour? When disabling a command button in JavaScript, the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.