Issue in plotting binary image boundaries with real axis values
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Turbulence Analysis
le 29 Juin 2021
Commenté : Turbulence Analysis
le 30 Juin 2021
Hi,
I have extracted the image boundaries from binary image and mm). I am able to diplay the binary image with real axis values i.e. x1, y1, (which is in mm), However, while plotting the extracted boundaries, the axes values are displayed in the pixels. (as shown in the attachment of binary image boundary.bmp).. Have anyone encountered simiar problem before ??
A = imgaussfilt(grayImage,5);
A1 = imbinarize (A,1900); %% binary image conversion
ax = gca;
A2 = imagesc (x1, y1,A1); %% Display binary image
set(gca, 'YDir','normal')
[b,~] = bwboundaries(A1, 8); b1 = b{1}; %% boundary extraction from binary image
b2 = smoothdata (b1(:,2),'sgolay',25);
b3 = smoothdata(b1(:,1),'sgolay',25);
plot(b2,b3,'b'); axis equal %% Plot the extrcated boundary
0 commentaires
Réponse acceptée
Steve Eddins
le 29 Juin 2021
The function bwboundaries returns boundary values in pixel coordinates. You'll need to scale those to world coordinates yourself. For this purpose, imref2d and intrinsicToWorld might be useful to you.
R = imref2d(imageSize,xWorldLimits,yWorldLimits)
[xWorld, yWorld] = intrinsicToWorld(R,xIntrinsic,yIntrinsic)
3 commentaires
Steve Eddins
le 29 Juin 2021
Look at the input to bwboundaries: it is just a MATLAB matrix. It does not have any information embedded in it about how matrix subscripts relate to some real-world coordinate system. Therefore, bwboundaries knows nothing about the world coordinate system and must return the output in what we call intrinsic coordinates. The syntax you used for imagesc suggests that, in your case, the intrinsic coordinates are related to the world coordinates by some combination of a multiplicative scale factor and an additive offset, or shift. You'll need to do this computation yourself on the output of bwboundaries. The other functions that I mentioned, imref2d and intrinsicToWorld, are capable of performing this computation for you if you wish.
Plus de réponses (1)
Joseph Cheng
le 29 Juin 2021
so you'll need to find the conversion between pixel to linear xy (mm). sort of the mm/px scale factor + offset to 0;
from the looks of it half of the image (row or column) is 0,
xscale = (max(x1)-min(x1))/size(A,2); %mm/pixel
newb2 = (b2-size(A,2)/2)*xscale;
2 commentaires
Voir également
Catégories
En savoir plus sur Convert Image Type dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!