Hi, how can i scale the image data to 0 and 1

9 vues (au cours des 30 derniers jours)
Hafeez
Hafeez le 28 Mar 2017
Modifié(e) : Stephen23 le 29 Mar 2017
i am working on greyscale images, i have to scale the data between 0 and 1, and but dividing the image data on 255 gives only 0 or 1, how can i get the actual vale after division.

Réponse acceptée

Jan
Jan le 29 Mar 2017
Modifié(e) : Stephen23 le 29 Mar 2017
If you divide an uint8, you get an uint8. Therefore either convert the matrix to double at first:
gray_d = double(gray) / 255;
But for productive work and if you have the image processing toolbox, use Thorsten's suggestion. im2double checks the type of the input and considers, if the input is a uint16 or double already.

Plus de réponses (1)

Thorsten
Thorsten le 29 Mar 2017
  1 commentaire
Jan
Jan le 29 Mar 2017
+1. This is the best solution.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Images dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by