# How to get matrix from plot ???

10 Ansichten (letzte 30 Tage)
Mohammad Bhat am 23 Feb. 2018
Bearbeitet: Jan am 26 Feb. 2018
Hi,I plotted a CYY and CXX having certain values .....
plot(CYY,CXX,'g*');
Now I want to get those plotted values marked '*' in plot in an matrix, can it be done???
##### 2 Kommentare1 älteren Kommentar anzeigen1 älteren Kommentar ausblenden
Mohammad Bhat am 24 Feb. 2018
I have CXX and CYY....

Melden Sie sich an, um zu kommentieren.

### Akzeptierte Antwort

John BG am 23 Feb. 2018
1.
Allow me to start with the same image you have supplied op.jpg
close all;clc;clear all
input_image='001.jpg';
figure(1);imshow(A);
.
.
Attached both start image and script to help reproduce result.
.
2. Amplify the image to avoid some too close stars overlapping and then alias would happen
.
Ar=imresize(A,20);
.
3. Green minus Blue shows a good response to blur a bit the starts yet keeping sharpness of each peak
.
A21=Ar(:,:,2)-Ar(:,:,3); % green - blue
figure(2);h1=imshow(A21);
.
.
4. Comment, at this point imcontrast can be used to show what range of pixel values are most useful
.
imcontrast(h1); % thresholds 59 and 123
.
.
instead one can manually perform the same pixel selection without imcontrast
th1=100;th2=59;
A21(A21<th2)=0;
A21(A21>=th1)=255;
figure(3);imshow(A21);
.
.
5. Reducing the size of the image a bit to save time i next step finding 2D peaks
.
A2=imresize(A21,.1);
figure(4);imshow(A2);
6.
Use Natan's function FastPeakFind.m available here:
.
pk3=FastPeakFind(A2);
figure(5);imagesc(A2); hold on
figure(5);plot(pk3(1:2:end),pk3(2:2:end),'r+')
.
.
7.
FastPeakFind returns a single file list of coordinates that are the [x y] coordinates interleaved, to obtain the paired coordinates:
x_peak=pk3(1:2:end);
y_peak=pk3(2:2:end);
p_stars=[x_peak y_peak];
8.
The amount of stars found is:
size(p_stars,1)
ans =
152
if you find this answer useful would you please be so kind to consider marking my answer as Accepted Answer?
To any other reader, if you find this answer useful please consider clicking on the thumbs-up vote link
thanks in advance for time and attention
John BG
9.1. tried *imfindcircles* but all tested parameters did not return any result as close as the previous steps.
[centers, radii, metric] = imfindcircles(A21,[8 15],'ObjectPolarity','bright','Sensitivity',.94);
[centers, radii, metric] = imfindcircles(A21,[15 31],'Method','PhaseCode','ObjectPolarity','bright','Sensitivity',.94);
9.2. tried *findpeaks2.m* available from here:
% https://www.mathworks.com/matlabcentral/fileexchange/46806-findpeaks2-m?s_tid=srchtitle
% [pk2,id2]=findpeaks2(A2);
2 minutes waiting and still busy.
metricStrong5 = metric(1:5);
##### 14 Kommentare13 ältere Kommentare anzeigen13 ältere Kommentare ausblenden
Jan am 25 Feb. 2018
Bearbeitet: Jan am 26 Feb. 2018
@John BG: See Mohammad's refined question, where he explains again, that he has the CXX and CYY coordinates, and whats the adjacency matrix: https://www.mathworks.com/matlabcentral/answers/384657-how-to-form-adjacency-matrix-from-cxx-and-cyy-where-cxx-and-cyy-contains-collectively-some-informati#comment_539237.
Your answer shows how to digitize the plot, but this does not help in any way to get the adjacency matrix for the available coordinates.

Melden Sie sich an, um zu kommentieren.

### Weitere Antworten (1)

Jan am 24 Feb. 2018
##### 1 KommentarKeine anzeigenKeine ausblenden
Mohammad Bhat am 25 Feb. 2018
Bearbeitet: John Kelly am 26 Feb. 2018
No help, I have started new question see: Link to the new question

Melden Sie sich an, um zu kommentieren.

### Kategorien

Find more on Line Plots in Help Center and File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by