Can anyone provide me chain code for boundary detection in the matlab with explanation?

1 次查看(过去 30 天)
Chain code is used for boundary detection.

回答(2 个)

Walter Roberson
Walter Roberson 2015-12-22
  2 个评论
Ekta Sharma
Ekta Sharma 2015-12-23
Hello Sir Thank you very much for your reply but I am unable to run it as while I am giving input to this program it is giving error and I am unable to understand what is unwrap means in input.Kindly help.
Walter Roberson
Walter Roberson 2015-12-23
unwrap: "if enable phase inversions are eliminated"
As for the errors: you will need to show us the error messages you are encountering.

请先登录,再进行评论。


Image Analyst
Image Analyst 2015-12-23
It's easy enough to do yourself. You can use bwboundaries() to get a list of boundary coordinates. Then loop over them and figure out which of the 8 directions the next pixel in the list is and assign a number from 1 to 8 to that pixel.
boundaries = bwboundaries()
x = boundaries(:, 2);
y = boundaries(:, 1);
for k = 1 : length(x)-1;
thisX = x(k);
thisY = y(k);
nextX = x(k+1);
nextY = y(k+1);
if nextX == thisX
% and so on.....
end
It's late here, so see if you can complete it yourself. It's easy.
  1 个评论
Ekta Sharma
Ekta Sharma 2016-2-29
I am doing like this way but not getting the desired results.Can you help? clc; clear; close all; I=imread('tool.png'); % imshow(I) I2 = imcrop(I,[180 174 250 450]); figure imshow(I2) im2double(I2); t=graythresh(I2); BW=im2bw(I2,t); figure imshow(BW) J=bwperim(BW); B=im2double(J); imshow(B) [M, N]=size(B); p=7; q=6; h=5; s=4; t=3; u=2; v=1; w=0; for j=2:N-1 for i=2:M-1 if B(i,j)==1 fprintf('Element(%d,%d) = %d.\n',i,j,B(i,j)) x=i; y=j; while (x>=2 && y<=246) if B(x+1,y+1)==1 fprintf('The chain code for (%d,%d)= %d.\n',x,y,p) newx=x+1; newy=y+1; break; elseif B(x+1,y)==1 fprintf('The chain code for (%d,%d)= %d.\n',x,y,q) newx=x+1; newy=y; break; elseif B(x+1,y-1)==1 fprintf('The chain code for (%d,%d)= %d.\n',x,y,h) newx=x+1; newy=y-1; break; elseif B(x,y-1)==1 fprintf('The chain code for (%d,%d)= %d.\n',x,y,s) newx=x; newy=y-1; break; elseif B(x-1,y-1)==1 fprintf('The chain code for (%d,%d)= %d.\n',x,y,t) newx=x-1; newy=y-1; break; elseif B(x-1,y)==1 fprintf('The chain code for (%d,%d)= %d.\n',x,y,u) newx=x-1; newy=y; break; elseif B(x-1,y+1)==1 fprintf('The chain code for (%d,%d)= %d.\n',x,y,v) newx=x-1; newy=y+1; break; elseif B(x,y+1)==1 fprintf('The chain code for (%d,%d)= %d.\n',x,y,w) newx=x; newy=y+1; break; end end end end end

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Feature Detection and Extraction 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by