Filter löschen
Filter löschen

Drawing line through scatter plot

2 Ansichten (letzte 30 Tage)
Walter Mabry
Walter Mabry am 14 Okt. 2021
Bearbeitet: Walter Mabry am 14 Okt. 2021
clear
I = imread('star.png');
[r,c,nc] = size(I);
GC = I(:,:,2);
BI = GC < 200;
[y,x]=find(BI);
y=y*-1; x=x*-1;
c = linspace(1,10,length(x));
figure
plot(x,y,'.')
The code plots the folowing graph
I want to make on continuous line that produces the same image. So basically x an y cordinates for a line that traces this star.
EDIT: Also wanted to mention that I have tried implementing a polyfit--> polyval rountine but It has not given me the desired results.
  2 Kommentare
Matt J
Matt J am 14 Okt. 2021
Your code doesn't run to completion:
I = imread('star.png');
[r,c,nc] = size(I);
GC = I(:,:,2);
Index in position 3 exceeds array bounds. Index must not exceed 1.
BI = GC < 200;
[y,x]=find(BI);
y=y*-1; x=x*-1;
c = linspace(1,10,length(x));
figure
plot(x,y,'.')
Walter Mabry
Walter Mabry am 14 Okt. 2021
Matt,
Thanks for the commetn here. Depending on the image you might have to change that line. It will do the same if you put
I(:,:,1)

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by