フィルターのクリア

Image Normalization in the range 0 to 1

265 ビュー (過去 30 日間)
Sapam Jaya
Sapam Jaya 2013 年 12 月 12 日
コメント済み: DGM 2023 年 2 月 13 日
How to normalize an image in the range 0 to 1?

採用された回答

Image Analyst
Image Analyst 2013 年 12 月 12 日
Use mat2gray() or im2double(). Hopefully you have the image processing Toolbox.
normImage = mat2gray(yourImage);
normImage = im2double(yourImage);
Also look at stretchlim() and imadjust().
  10 件のコメント
Image Analyst
Image Analyst 2021 年 9 月 23 日
If you really want them to have fractional values between 0 and 1, that's not a standard image format so you'll just have to save them with
save('myFile.mat', 'yourImageVariable');
to save them in a .mat file.
Andrea Daou
Andrea Daou 2021 年 9 月 29 日
Thank you for your help.

サインインしてコメントする。

その他の回答 (3 件)

mutant
mutant 2019 年 10 月 6 日
Old question but as of R2017b, rescale does exactly this.
B = rescale(A); % Normalizes image (0 to 1, by default)
You can even use this to scale to uint8, for example:
B = rescale(A,0,255); % Normalizes image to [0 255]
Documentation here:

Azzi Abdelmalek
Azzi Abdelmalek 2013 年 12 月 12 日
編集済み: Azzi Abdelmalek 2013 年 12 月 12 日
If im is your image
im=(im-min(im(:)))/(max(im(:))-min(im(:)))
  1 件のコメント
Jos (10584)
Jos (10584) 2013 年 12 月 12 日
I suggest to do this in two steps to avoid the calculation of MIN twice ...
IM = IM - min(IM(:)) ;
IM = IM / max(IM(:)) ;

サインインしてコメントする。


Sajid Khan
Sajid Khan 2014 年 2 月 6 日
編集済み: DGM 2023 年 2 月 13 日
function image_normalized = imnormalize( image_orig, min_norm, max_norm)
val_max = max(image_orig(:));
val_min = min(image_orig(:));
range = val_max - val_min;
image_normalized = (image_orig - val_min) ./ range; % Then scale to [x,y] via:
range2 = max_norm - min_norm;
image_normalized = (image_normalized*range2) + min_norm;
end
In this function, you can set min_norm = 0 and max_norm = 1 to normalize image to a scale of 0 to 1. If you have any other questions to ask, then you are welcome. I always use this function for normalization purpose. It even works if you have to increase the scale length.
  2 件のコメント
Image Analyst
Image Analyst 2014 年 2 月 6 日
Your function basically does the same thing as the built in function mat2gray().
DGM
DGM 2023 年 2 月 13 日
Rather, mat2gray() only allows the specification of the input levels, assuming the output levels are [0 1]. Sajid's function allows specification of the output levels, while using image extrema as the input levels.
So in that sense, it's more like rescale(), same syntax and everything.

サインインしてコメントする。

Community Treasure Hunt

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

Start Hunting!

Translated by