フィルターのクリア

find the coordinates 5 first white pixels in an image

2 ビュー (過去 30 日間)
Rocío García Mojón
Rocío García Mojón 2023 年 8 月 30 日
I am trying to find the coordinates of the first 5 white pixels of a black and white image. With the find function I am able to find the first and the last one, but I need more, could someone help me? Thanks
%Find coordinates of the last and first white pixel
%First image
pix_amarelor = imread('pac14_e.png')
[row1first,colum1first] = find(pix_amarelor,1,'first');
imshow(pix_amarelor);
hold on;
plot(colum1first,row1first,'r+','LineWidth',2,'MarkerSize',30);
[row1last,colum1last] = find(pix_amarelor,1,'last');
% imshow(pix_amarillor);
hold on;
plot(colum1last,row1last,'r+','LineWidth',2,'MarkerSize',30)
  2 件のコメント
Image Analyst
Image Analyst 2023 年 8 月 30 日
Depends on how you define "first". Attach 'pac14.png' and tell us what pixels you consider to be the "first". And format your code as code with the code icon/button.
If you have any more questions, then attach your data and code to read it in with the paperclip icon after you read this:
Rocío García Mojón
Rocío García Mojón 2023 年 8 月 31 日
編集済み: Rocío García Mojón 2023 年 8 月 31 日
Thank you very much.
I have an image like the first one and I would like to find the coordinates of the second photo, but with 4 additional points that are in the same column.

サインインしてコメントする。

採用された回答

Image Analyst
Image Analyst 2023 年 8 月 31 日
Try this:
% Find coordinates of the last and first white pixel
% First image
pix_amarelor = imread('pac14_e.png');
[row1first,colum1first] = find(pix_amarelor,1,'first');
imshow(pix_amarelor);
hold on;
plot(colum1first,row1first,'r+','LineWidth',2,'MarkerSize',30);
[row1last,colum1last] = find(pix_amarelor,1,'last');
% imshow(pix_amarillor);
hold on;
plot(colum1last,row1last,'r+','LineWidth',2,'MarkerSize',30)
% Find all other pixels in the first column.
col1 = pix_amarelor(:, colum1first);
rowsInCol1 = find(col1)
rowsInCol1 = 6×1
292 293 294 295 296 297
% Find all other pixels in the last column.
col2 = pix_amarelor(:, colum1last);
rowsInCol2 = find(col2)
rowsInCol2 = 6×1
714 715 716 717 718 719
  3 件のコメント
Dyuman Joshi
Dyuman Joshi 2023 年 9 月 1 日
Hello @Rocío García Mojón, if this answer solved your problem, please consider accepting the answer.
Accepting the answer indicates that your problem has been solved (which can be helpful to other people in future) and it awards the volunteer with reputation points for helping you.
You can accept only 1 answer for a question, but you can vote for as many answers as you want. Voting an answer also provides reputation points.
Rocío García Mojón
Rocío García Mojón 2023 年 9 月 4 日
Thank you @Dyuman Joshi

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeImage Processing and Computer Vision についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by