Sorting points of image
4 ビュー (過去 30 日間)
古いコメントを表示
I have an image with white curves on black background. How to Sort the white pixels in an array? the pixel array is attached.Thanks in advance.
10 件のコメント
Jan
2019 年 5 月 17 日
編集済み: Jan
2019 年 5 月 17 日
@JRose: I do not understand, what "if we plot the lines it matches excatly" means. "a line profile along these edges of the coordinate" is not clear to me also.
You do not answer my question, what exactly your inputs are. A screenshot in the memory, a saved image, a text file of coordinates? You have posted the file array.txt and show an image, but which of them is the data you want to process? You mention "the white pixels in an array", but arrays do not have pixels, and in the image, the drawn line has a certain width of about 8 pixels and it is not clear, which of these many pixels you consider as "start" and how you want to treat this area (which is not a 2D line).
Please read How to ask a good question
回答 (2 件)
KSSV
2019 年 5 月 16 日
I = imread('curves.png');
I1 = rgb2gray(I);
[y,x] = find(I1) ;
imshow(I)
hold on
plot(x,y,'r')
You see the lines are in order...that's why I am able to join them by a line, which lie exactly on the white region.
5 件のコメント
Sulaymon Eshkabilov
2019 年 5 月 16 日
Hi,
What you are trying to find out where the white pixels are residing, right?!
% This locates all white pixels accurately
AA = imread('curves.png');
A1 = AA(:,:,1);
A2 = AA(:,:,2);
A3 = AA(:,:,3);
Index1 = find(A1>0);
Index2 = find(A2>0);
Index3 = find(A3>0);
B1 = A1(Index1);
B2 = A2(Index2);
B3 = A3(Index3);
DATA = [B1, B2, B3];
imshow(DATA), shg
%% Given coordinates: don't seem to correct at all
array = load('array.txt');
AA = imread('curves.png');
A1 = AA(:,:,1);
A2 = AA(:,:,2);
A3 = AA(:,:,3);
B1 = A1(array(:,:));
B2 = A2(array(:,:));
B3 = A3(array(:,:));
DATA = [B1, B2, B3];
imshow(DATA), shg
Good luck.
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!