How do I get pixel intensity values of images stored in an array ?

3 vues (au cours des 30 derniers jours)
Devansh Sangoi
Devansh Sangoi le 8 Déc 2022
Réponse apportée : DGM le 8 Déc 2022
I'm trying to get pixel intensity values of images stored in an array but I'm confused about how do it as i dont understand to index 3 dim variable, where testimgs is the image array.
Here is the code of the following:
adj = zeros(size(testimgs));
intensity_value = adj(698,72,i);

Réponses (1)

DGM
DGM le 8 Déc 2022
That would be correct, assuming that i is a real-valued integer between 1 and size(adj,3). The output will be the value at the 698th row, 72nd column, and ith page.
Of course, adj is currently all zero. Do you have a particular image that you're trying to inspect? Perhaps a volumetric image?
If you're trying to retrieve the full 3-color tuple for a pixel in an RGB image, you can do that all at once.
inpict = imread('peppers.png');
% what is the value at 100,100,1?
thispixel = inpict(100,100,1)
thispixel = uint8 66
% what is the value at 100,100,3?
thispixel = inpict(100,100,3)
thispixel = uint8 60
% or you could get the whole tuple at once
thispixel = reshape(inpict(100,100,:),1,[])
thispixel = 1×3
66 35 60

Produits


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by