Borrar filtros
Borrar filtros

find the coordinates 5 first white pixels in an image

2 visualizaciones (últimos 30 días)
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 comentarios
Image Analyst
Image Analyst el 30 de Ag. de 2023
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 el 31 de Ag. de 2023
Editada: Rocío García Mojón el 31 de Ag. de 2023
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.

Iniciar sesión para comentar.

Respuesta aceptada

Image Analyst
Image Analyst el 31 de Ag. de 2023
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 comentarios
Dyuman Joshi
Dyuman Joshi el 1 de Sept. de 2023
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.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Image Processing and Computer Vision en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by