MATLAB Answers

Rescale Depth RGB image between zeros and one?

22 views (last 30 days)
Salem
Salem on 12 Dec 2014
Commented: Salem on 12 Dec 2014
Dear All, I have 1000 d-rgb images (unit16) and each image has different size. I want to normalize the image by resizing them to [0 1] interval. Could you please tell me if there is a function or an efficient algorithm which can do such operation. I transfer the image to double and single, but the scaled images become since 0 and 0.05 intervals. Bye the way the scale of d-rgb image is different from image to others which scaled from zero to greater than 3000.

  0 Comments

Sign in to comment.

Accepted Answer

Adam
Adam on 12 Dec 2014
Edited: Adam on 12 Dec 2014
normImage = single( imageData ) / single( max( imageData(:) ) );
will scale a single image between 0 and 1.
If you want to scale every image independently between 0 and 1 then you can just use that on each image.
If you want to scale all images with the same scale factors then you would have to scan over all the images first and find the maximum value across all images and then use that value for every image in place of max( imageData(:) ) for each image.
If your images do not contain 0s though and you want to map the minimum data value of the image to 0 then it is a little more complicated. This is something I created a custom RangeMapper class for so that I don't have to go over the maths any more!

  1 Comment

Salem
Salem on 12 Dec 2014
Great, thank you very much. My images have zeros as min number.

Sign in to comment.

More Answers (1)

Image Analyst
Image Analyst on 12 Dec 2014
You can't resize the images to 0-1. How many pixels would that be? You need at least a 2 row by 2 column array to have an image. You can have, say 1000 pixels across or tall, and if you want you can define a spatial calibration factor such that 1000 pixels equals one unit of whatever distance measuring unit you want, such as meters.
Also explain what a "d-rgb" image is, as opposed to just a normal RGB full color image.

  3 Comments

Salem
Salem on 12 Dec 2014
Hi Image Analyst,
You are right, but, I want to rescue the data inside the matrix which 64x64 pixels (unit16). Now The data inside the matrices are between 0 and maybe 3000, I want to rescale them to 0 and 1 to use them for data mining. I meant by d-grab the depth of the images which are taken from Kinect Microsoft. I could scale the RGB image but the depth I could not.
Image Analyst
Image Analyst on 12 Dec 2014
From the answer you accepted, it looks like you actually didn't want to resize your image like you said. You want to change the intensity range , not the size . To do that you can use the function mat2gray(). It scales an array with any range of values to the range 0-1. I also added the "kinect" tag for you.

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!