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.

Antworten (1)

KALYAN ACHARJYA
KALYAN ACHARJYA am 24 Mär. 2021
Bearbeitet: KALYAN ACHARJYA am 24 Mär. 2021

0 Stimmen

% 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,:)
Note: you may get 3 pixels values for single row & cloumns indices, as there are three plane in the RGB image.

3 Kommentare

lena kappa
lena kappa am 24 Mär. 2021
thanks for the answer
i get only a white cyrcle when i run your code my picture is not rgb its grayscale
does this code work for grayscale and binary pictures also
KALYAN ACHARJYA
KALYAN ACHARJYA am 24 Mär. 2021
The original attached image is RGB image
lena kappa
lena kappa am 24 Mär. 2021
yes you are right it was my mistake.
what i wanted was to first draw the line in the pic and then find the coresponding pixel.
So for example if i want to draw a line 45 degrees starting from the point (0,0) of the pic and then find the coresponding pixels of that line.
Sorry if i did not post my question very crearly.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Convert Image Type finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 24 Mär. 2021

Kommentiert:

am 24 Mär. 2021

Community Treasure Hunt

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

Start Hunting!

Translated by