Trying to determine locations of markers in image

3 次查看(过去 30 天)
I'm trying to obtain the pixel coordinates of the dot pattern image data that is stored in the attached file; I'm using this image to spatially calibrate my camera image. Is there a way to automate the detection of these dots? Thanks in advance for any guidance.
  5 个评论
Walter Roberson
Walter Roberson 2025-7-18
Is the projection unequal? That is, is the distance between dots on (say) the lower left corner different from the distance between dots (say) near the upper right corner? If the distances are always the same, then you only need to locate a small number of dots in order to calculate the distance between pixels. If the distances are not always the same but the change is linear, then you only need to calculate based on a small number of locations. If, however, the projection is non-linear then the task becomes more difficult.
MBP
MBP 2025-7-18

The projections are equal... So, you're right, if I can get a small subset of dots that will be sufficient. I just need an automated way to do that rather than a manual method using, say ginput, to select the dot locations.

请先登录,再进行评论。

采纳的回答

Mathieu NOE
Mathieu NOE 2025-7-18
hello
maybe this ? not perfect but you may refine it and get as much dots as we / you can
% Read the grayscale image
img = readmatrix('CalImage_Grayscale.txt');
figure
imshow(img);
% Use adaptthresh to determine threshold to use in binarization operation.
T = adaptthresh(img, 0.3);
% Threshold the image to create a binary mask
binaryMask = imbinarize(img,T);
figure
imshow(binaryMask);
% Remove noise , small (and large) objects
cleanMask = bwareafilt(binaryMask, [5, 20]); % Keep objects with area between xx and yy pixels
figure
imshow(cleanMask);
% Label connected components (dots)
[labeledImage, numDots] = bwlabel(cleanMask);
% Display results
figure
imshow(img); hold on;
stats = regionprops(labeledImage, 'Centroid');
for k = 1:numDots
centroid = stats(k).Centroid;
plot(centroid(1), centroid(2), 'r*', 'MarkerSize', 10); % Mark dots
end
title(['Detected Dots: ', num2str(numDots)]);
hold off;
  4 个评论
MBP
MBP 2025-7-18
I really like the isocline-based detection, and I combined it with some pre-processing from ImageJ to get what I was looking for...thank you Mathieu for your help, and setting me on the right path!
The reason I used ImageJ was that I was able to get rid of the horizontal lines that are showing up in my image using the gray morphology option followed by the using the image calculator to subtract out the original and processed images (somewhat similar to what you did using the bwareafilt command). The resulting "cleaned-up" image I processed using the isocline-based technique and that gave me great results.
Thanks again!

请先登录,再进行评论。

更多回答(1 个)

Image Analyst
Image Analyst 2025-7-21
I recommend you use the code in the other answer to get the "cleanMask" binary image above. Then use regionprops to get the centroids, or weighted centroids, of the dots. The contour and looping stuff is overly complicated and not needed, when regionprops gives you the centroids directly (but it requires the Image Processing Toolbox).
Then for the next step needed for calibration you can use kmeans to get the mean rows and columns of each linear series of dot. If the image is tilted, you might then use that to get the angle of tile and then use imrotate to square it up with the image edges. Then you can sum the binary image vertically and horizontally with sum() to get a 1-D horizontal or vertical profile. Then you can use regionprops to get the row and column numbers of each line of dots. Knowing that you can complete your calibration in terms of millimeters (or whatever) per pixel.

类别

Help CenterFile Exchange 中查找有关 Image Processing Toolbox 的更多信息

产品


版本

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by