How to truncate the image values so they stay in the [0 255] range
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Krish Desai
le 9 Oct 2015
Modifié(e) : Walter Roberson
le 9 Oct 2015
This is my current code:
function newImg = adjust_img(current_img)
for current_img>255
new=255;
newImg=new;
end
for current_img<0
new=0
newImg=new
end
0 commentaires
Réponse acceptée
Walter Roberson
le 9 Oct 2015
Modifié(e) : Walter Roberson
le 9 Oct 2015
newImg = max(0, min(255, current_img));
after which you will probably want to uint8() the result which would probably otherwise be class double()
On the other hand if you are going to uint8() the result of the above, you could replace the whole thing with
newImg = uint8(current_img);
as uint8() will make any negative values into 0 and make anything over 255 into 255.
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Geometric Transformation and Image Registration 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!