How to find coordinates around point?

3 vues (au cours des 30 derniers jours)
Lilya
Lilya le 18 Oct 2022
Commenté : Lilya le 19 Oct 2022
Hi All,
There is a point (light blue) within the domain of dark blue.
I have the coordinate of the light blue point and want to extract the coordinates of the 4 points (dark blue)
any help will be appreciated.
  3 commentaires
Lilya
Lilya le 18 Oct 2022
all are has latitude and longitude coordinates
Jan
Jan le 18 Oct 2022
In the shown image, there are 4 dark blue dots. Finding them has no relation to the light blue dot. So which role does the light blue dot play in the question?
Maybe the real images contain a lot of dark blue dots and you want to find the 4 dots with the smallest distance? If so, note that there is no unqiue solution in some cases, e.g. if the dark dots are found on an equidistant grid and the light dot is on the center between two dark dots or exactly on a dark dot.

Connectez-vous pour commenter.

Réponse acceptée

Image Analyst
Image Analyst le 18 Oct 2022
Modifié(e) : Image Analyst le 18 Oct 2022
Try this. Red circles are shown around the pure blue spots, and the centroid coordinates are shown in the command window.
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
fontSize = 16;
%===============================================================================
% Get the name of the image the user wants to use.
baseFileName = 'blue dots.png';
folder = pwd;
fullFileName = fullfile(folder, baseFileName);
% Check if file exists.
if ~exist(fullFileName, 'file')
% The file doesn't exist -- didn't find it there in that folder.
% Check the entire search path (other folders) for the file by stripping off the folder.
fullFileNameOnSearchPath = baseFileName; % No path this time.
if ~exist(fullFileNameOnSearchPath, 'file')
% Still didn't find it. Alert user.
errorMessage = sprintf('Error: %s does not exist in the search path folders.', fullFileName);
uiwait(warndlg(errorMessage));
return;
end
end
%=======================================================================================
% Read in image.
rgbImage = imread(fullFileName);
% Get the dimensions of the image.
[rows, columns, numberOfColorChannels] = size(rgbImage)
% Display image.
subplot(1, 2, 1);
imshow(rgbImage, []);
impixelinfo;
axis on;
caption = sprintf('Original RGB Image\n%s', baseFileName);
title(caption, 'FontSize', fontSize, 'Interpreter', 'None');
hp = impixelinfo(); % Set up status line to see values when you mouse over the image.
% Set up figure properties:
% Enlarge figure to full screen.
g = gcf;
g.WindowState = "maximized";
% Get rid of tool bar and pulldown menus that are along top of figure.
% set(gcf, 'Toolbar', 'none', 'Menu', 'none');
% Give a name to the title bar.
set(gcf, 'Name', 'Demo by ImageAnalyst', 'NumberTitle', 'Off')
drawnow;
%=========================================================================================================================
% Threshold the image to create a mask
[r, g, b] = imsplit(rgbImage);
mask = (r == 0) & (g == 0) & (b == 255);
% Display the mask image.
subplot(1, 2, 2);
imshow(mask, []);
impixelinfo;
axis('on', 'image');
title('Mask Image', 'FontSize', fontSize);
drawnow;
%=========================================================================================================================
% Get the centroids of blobs in the mask
props = regionprops(mask, 'Centroid');
xyCentroids = vertcat(props.Centroid)
% Display red circles around the centroids.
subplot(1, 2, 1);
hold on;
viscircles(xyCentroids, 5);
impixelinfo;
xyCentroids =
49.5 42.5
49.5 112.5
112.5 42.5
112.5 112.5
To learn basic segmentation like this, see my Image Segmentation Tutorial in my File Exchange.
  1 commentaire
Lilya
Lilya le 19 Oct 2022
Thank You so much!! couldn't be more apprecited.

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by