how to calculate pixel value differences?
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Rezaur Rahman
le 23 Fév 2016
Commenté : Rezaur Rahman
le 23 Fév 2016
let my image be
temp=
[5 10;
10 15]
if i want to calculate temp(1,1)-temp(1,2) or temp(1,1)-temp(2,1) it always shows 0. how can i store the value?? i have also tried abs(temp(1,1)-temp(1,2)); bt failed. thanx in advance
0 commentaires
Réponse acceptée
Guillaume
le 23 Fév 2016
In your example, it actually works the way you want. The most likely reason why it does not work with your real image is that your image is of type uint8 (or uint16). The range of uint8 is limited to [0, 255], any value below or above these values are clamped to 0 or 255.
The fix is simple, convert your image to double:
temp = uint8([5 10; 10 15]) %demo image
temp(1,1) - temp(1, 2) %output 0, since -5 is not allowed for uint8
temp = double(temp); %convert to double
temp(1,1) - temp(1, 2) %output -5 as it should
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Import, Export, and Conversion dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!