How to find the neighboring maxima in an image

Hi,
I am working on a tool that helps me to find all the maxima in an image. (as shown). The image is a simulated image that I did using MatLab to do. It is similar to the high-resolution transmission electron microscopy to practice this tool in it before applying to real data.
What I want to do is find all the maxima value in the image. For example, I want to select only three-point using
[a,b] = ginput;
let's say these are the value of coordinated position in the image
a =
22.6868
33.0902
23.3238
b =
22.9522
22.7399
13.1858
The next thing I did is using the following command.
gscatter(a,b);
to obatain the follwing
I know that the red points are precisely the point that I select from that image. So here is what I need help with, I want to use only the a and b coordination to determent the other positions in the image.
I did that manually, but this is not going to help because I can't do that in real image.
Any suggections or thought that may help.

 Akzeptierte Antwort

Image Analyst
Image Analyst am 31 Mai 2020

0 Stimmen

Why not simply use imregionalmax()?

5 Kommentare

Sara
Sara am 31 Mai 2020
Thank you for your respond,
I thought of using imregionalmax function, and it will give the maxima position in the image. However, I do not think this function will help in my case. The aim behind my post is to find three positions (x1,x2,x3,y1,y2,y3) in an image(Which I did by using ginput), and based on these coordinations, I create a 2D image. The created 2D image will show the defect present in the image. (In my case transmission electron microscopy here the image has no defect, but in real image it will have defect). In other words, my thought will help me to see the defect in the image.
You can fill out an array with meshgrid() if you know how many rows and columns there are and if you click on the corners of the rectangle.
xu = linspace(x1, x2, numColumns);
yu = linspace(y1, y3, numRows);
[x, y] = meshgrid(xu, yu);
plot(x(:), y(:), 'r.', 'MarkerSize', 20);
Sara
Sara am 1 Jun. 2020
Thank you for your comment.
In the code, I was trying to minimize any manual entrance. In other words, I want to run the code with few entering parameters( I hoe to create a software :) )
I did what you suggest, and it works. However, there are limitations that I faced after I apply your suggestion.
1- the number of columns and rows must provide. Essy solution is using length(image).
2- the x1,x2,y1,y2 are not scalars ,which means I need to enter the value manually after selecting them from the ginput function. I did not know much about the convert to a scalar value.
I write my comment so when someone is looking for information similar to my question, he or she can find it here.
Thank you again for you time.
Image Analyst
Image Analyst am 2 Jun. 2020
Bearbeitet: Image Analyst am 2 Jun. 2020
Why are they not scalars???? Of course they are, or else you did not compute them correctly. Why would the number of rows and columns be the same as the number of rows and columns in your image? Also you say you want to minimize user input, yet you say you want to avoid an automatic way to find the bright spots and use ginput() instead. That seems like contradictory requirements to me.
Here is my code for the ginput() method you asked for:
grayImage = imread('eSFRTestImage.jpg');
imshow(grayImage);
g = gcf;
g.WindowState = 'maximized'
uiwait(msgbox('Click 3 points : upper left, upper right, lower left'));
[a, b] = ginput(3)
hold on;
plot(a, b, 'r+', 'MarkerSize', 150, 'LineWidth', 3);
x1 = mean([a(1), a(3)])
x2 = a(2)
y1 = mean([b(1), b(2)])
y2 = b(3)
numColumns = 5;
numRows = 3;
xu = linspace(x1, x2, numColumns);
yu = linspace(y1, y2, numRows);
[x, y] = meshgrid(xu, yu);
% Plot grid
plot(x(:), y(:), 'r.', 'MarkerSize', 150);
I clicked where the red crosshairs are, and then I computed a regularly spaced set of coordinates of 3 rows and 5 columns, which are plotted with the round red spots. Is this not what you want?
Sara
Sara am 4 Jun. 2020
Yes that what I want it. Thank you for your comment

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Gefragt:

am 29 Mai 2020

Kommentiert:

am 4 Jun. 2020

Community Treasure Hunt

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

Start Hunting!

Translated by