![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/560683/image.png)
find pixels of a line in picture
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hello everyone, i have a question maybe its really easy but i dont really know how to do it.
How can i find the pixels in the pixture that corresponde in a certain line within the picture.
For example if i have the image bellow and i draw the red line as shown below how can i find the pixels of the image that are in that line.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/560648/image.png)
0 comentarios
Respuestas (1)
KALYAN ACHARJYA
el 24 de Mzo. de 2021
Editada: KALYAN ACHARJYA
el 24 de Mzo. de 2021
% Load the image
rgbImage=imread('image_line.png');
% Get the one plane/Gray Image
red_channel=rgbImage(:,:,1);
% Segment the ROI
line_seg=bwareafilt(imbinarize(red_channel,0.85),1);
% Display the Region of Interest
figure,imshow(line_seg);
% Get the rows and column indices of ROI
[r,c]=find(line_seg==1);
% Get the pixel values of particular rows & columns
rgbImage(r,c,:)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/560683/image.png)
Note: you may get 3 pixels values for single row & cloumns indices, as there are three plane in the RGB image.
3 comentarios
Ver también
Categorías
Más información sobre Image Processing Toolbox en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!