Borrar filtros
Borrar filtros

I have a binary image with white object and black background. How can I get the pixel coordinate for the center of the white image?

6 visualizaciones (últimos 30 días)
Attached is the starting RGB image, and I was able to isolate the colors and convert the shape I want to Binary where the background is black and the shape I want is white. How do I get the coordinates for the center of he the white image?

Respuestas (2)

Image Analyst
Image Analyst el 14 de Abr. de 2016
You forgot to attach the image, but anyway to get the (x,y) coordinates of the white pixels, do this:
[y, x] = find(binaryImage);
  4 comentarios
gokool surya
gokool surya el 20 de Abr. de 2018
Hello Image Analyst. I am interested in finding the parking spots from a black and white image and extracting the regions that were white (targets) and finding the co-ordinates of this region. For example, in the above comment, if the [y, x] gives us x = 3388x1 and y = 3388x1. There are many 'x' for one 'y' and vice versa. I am not sure how to proceed. Any help would be highly appreciated. Thanks in Advance
Image Analyst
Image Analyst el 20 de Abr. de 2018
I don't know what you have or what you want. If you have the binary image with white (targets) already segmented out, what exactly do you want to know? find() will give you the coordinates of all the pixels. So will regionprops(binaryImage, 'PixelList') will also give it to you. But I don't know why you need all the coordinates. Actually the binary image is already one representation of all the coordinates. But what are you going to do with them? Do you want the bounding box or centroid also or instead?

Iniciar sesión para comentar.


Zeinab Moradi
Zeinab Moradi el 30 de En. de 2021
could you please help me how to find the center of a black object in white background ... additionall i want to know the coordinate of black pixels.... i am looking forward for yyour helppp...thank youuu
  1 comentario
Image Analyst
Image Analyst el 30 de En. de 2021
binaryImage = grayImage < 128; % Or whatever threshold works.
imshow(binaryImage);
title('BinaryImage', 'FontSize', 20);
drawnow;
props = regionprops(binaryImage, grayImage, 'Centroid', 'WeightedCentroid');
% Plot the centroid(s) in red and the weighted centroids in green.
imshow(grayImage);
hold on;
for k = 1 : numel(props)
plot(props(k).Centroid(1), props(k).Centroid(2), 'r+', 'MarkerSize', 30, 'LineWidth', 2);
plot(props(k).WeightedCentroid(1), props(k).WeightedCentroid(2), 'g+', 'MarkerSize', 30, 'LineWidth', 2);
end
title('Gray Image with weighted and unweighted centroids', 'FontSize', 20);
drawnow;

Iniciar sesión para comentar.

Categorías

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

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by