How to find coordinates around point?

6 ビュー (過去 30 日間)
Lilya 2022 年 10 月 18 日
コメント済み: Lilya 2022 年 10 月 19 日
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 件のコメント
Lilya 2022 年 10 月 18 日
all are has latitude and longitude coordinates
Jan 2022 年 10 月 18 日
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.



Image Analyst
Image Analyst 2022 年 10 月 18 日
編集済み: Image Analyst 2022 年 10 月 18 日
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);
% 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, []);
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')
% 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, []);
axis('on', 'image');
title('Mask Image', 'FontSize', fontSize);
% 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);
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 件のコメント
Lilya 2022 年 10 月 19 日
Thank You so much!! couldn't be more apprecited.


その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by