필터 지우기
필터 지우기

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일
댓글: Rocío García Mojón 2023년 9월 4일
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.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Image 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