MATLAB Answers

Issue in plotting binary image boundaries with real axis values

2 ビュー (過去 30 日間)
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

採用された回答

Steve Eddins
Steve Eddins 2021 年 6 月 29 日
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 件のコメント
Turbulence Analysis
Turbulence Analysis 2021 年 6 月 30 日
Hi,
I treid as follows, now I can able to shift the psoition of zero and convert the pixel to mm with the scale factor.. !
b2 = smoothdata ((b1(:,2)/10)-40,'sgolay',35);
b3 = smoothdata((b1(:,1)/10),'sgolay',35);
ax = gca;
plot(b2 ,b3 ,'r');
axis equal

サインインしてコメントする。

その他の回答 (1 件)

Joseph Cheng
Joseph Cheng 2021 年 6 月 29 日
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 件のコメント
Turbulence Analysis
Turbulence Analysis 2021 年 6 月 29 日
sorry, *** position of the ''zero '' in x axis is not correct..

サインインしてコメントする。

Community Treasure Hunt

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

Start Hunting!

Translated by