how can i extract radius signature of a binary image?
이전 댓글 표시
i have a binary image and radius signature is distance between pixels on contour of object and its centroid. i use bwboundaries() but result is not good
i saw a example in matlab code of bwboundaries(),it used plot to show contour plot has best result but i dont need plot i need a matrix. i use blow code but my result is not same with matlab's example.
img4=zeros(size(img3));
[B,L] = bwboundaries(img3,'noholes');
for k = 1:length(B)
boundary = B{k};
for i=1:size(boundary,1)
img4(boundary(i,1), boundary(i,2))=1;
end
end
답변 (3개)
Image Analyst
2013년 8월 26일
편집: Image Analyst
2013년 8월 26일
2 개 추천
Use regionprops to find the centroid, then use the Pythagorean theorem to get the distances between the boundary x,y coordinates and the centroid.
댓글 수: 9
Explorer
2014년 2월 10일
I also need to do the same i.e. find the signature of binary image.
________________________________________________________________________
image = imread('C:\Users\Saeed Rattar\Desktop\aa_contour.jpg');
GRAY1 = rgb2gray(image);
threshold1 = graythresh(GRAY1);
BW1 = im2bw(GRAY1, threshold1);
stats = regionprops(BW1, 'Centroid')
c = stats.Centroid
--------------------------------------------------------------------------
I am getting this " 173.5000 1.0000 " as centroid. I think centroid should be single numerical value but why I am getting answer of 2 x 1 size.
How to use Pythagorean theorem to get the distances between the boundaries?
My binary image is like

Image Analyst
2014년 2월 10일
Use bwboundaries on the binary image
boundary = bwboundaries(binaryImage);
x = boundary(:,1);
y = boundary(:,2);
distances = sqrt((x - c(1)).^2 + (y - c(2)).^2);
Explorer
2014년 2월 11일
mage = imread('C:\Users\Explorer\Desktop\aa_contour.jpg');
GRAY1 = rgb2gray(image);
threshold1 = graythresh(GRAY1);
BW1 = im2bw(GRAY1, threshold1);
stats = regionprops(BW1, 'Centroid')
c = stats.Centroid
boundary = bwboundaries(BW1);
x = boundary(:,1);
y = boundary(:,2);
distances = sqrt((x - c(1)).^2 + (y - c(2)).^2)
____________________________________________________________________________
Error
-------------------------------------------------------------------------------
stats = 2x1 struct array with fields:
Centroid
c = 173.5 1
Index exceeds matrix dimensions. Error in signature (line 17) y = boundary(:,2);
___________________________________________________________________________
What should I do to correct this error?
Image Analyst
2014년 2월 11일
Use the debugger? What does "whos boundary" say? Is it an N rows by 2 columns array?
>> whos
Name Size Bytes Class Attributes
BW 519x346 179574 logical
boundary 3x1 39824 cell
c 1x2 16 double
image 519x346x3 538722 uint8
stats 2x1 320 struct
x 3x1 39824 cell
Explorer
2014년 2월 11일
>> whos boundary
Name Size Bytes Class Attributes
boundary 3x1 39824 cell
Image Analyst
2014년 2월 11일
You have 3 blobs in your binary image, not just one. I don't know why. What are the other 2 blobs? You can get one by doing
thisBoundary = boundary{1}; % Or whatever blob you want.
x = thisBoundary(:,1);
y = thisBoundary(:,2);
distances = sqrt((x - c(1)).^2 + (y - c(2)).^2);
Explorer
2014년 2월 11일
Thanks for helping!
Image Analyst
2014년 2월 11일
Can you go ahead and accept it to close this out?
Sabanam
2014년 2월 25일
0 개 추천
Thanks sir...its really helpful and the best answer to find radius signature...
Which formula used to find centroid in matlab?..Whenever i have read they are using mean of the point but is it right?
카테고리
도움말 센터 및 File Exchange에서 Object Analysis에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!