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
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.
采纳的回答
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;
更多回答(1 个)
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.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Processing Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!