Trying to determine locations of markers in image

조회 수: 4 (최근 30일)
MBP
MBP 2025년 7월 17일
답변: Image Analyst 2025년 7월 21일
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!
Mathieu NOE
Mathieu NOE 2025년 7월 21일
as always, my pleasure !

댓글을 달려면 로그인하십시오.

추가 답변 (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