Intensity of each pixel frawn on an image
Mostra commenti meno recenti
I want to find out the intensity of every pixel if i draw a line on one image.
Im using the below code for drawing a line. Initial valu of (xi,yi) = (353,216) and the final value is (xf,yf) = (553,216).
I = imread('figure63.png');
figure, imshow(I)
hold on
p1 = [353,216];
p2 = [553,216];
plot([p1(1),p2(1)],[p1(2),p2(2)],'Color','m','LineWidth',1)
If I want intensity of every pixel of this line as a column matrix, how do I use imaprofile or I need to use something else?

Risposta accettata
Più risposte (1)
Walter Roberson
il 6 Dic 2021
I(p1(2), p1(1):p2(1))
except you should use min and max to ensure that you get increasing order for the column numbers.
This depends on the y coordinates being the same and being integers, a horizontal line. You could use similar logic for a vertical line.
If you need a slanted line then you need improfile or go directly for interp2 which is what improfile uses internally.
1 Commento
U B
il 6 Dic 2021
Categorie
Scopri di più su Convert Image Type in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!