Azzera filtri
Azzera filtri

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

1 visualizzazione (ultimi 30 giorni)
Chain code is used for boundary detection.

Risposte (2)

Walter Roberson
Walter Roberson il 22 Dic 2015
  2 Commenti
Ekta Sharma
Ekta Sharma il 23 Dic 2015
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 il 23 Dic 2015
unwrap: "if enable phase inversions are eliminated"
As for the errors: you will need to show us the error messages you are encountering.

Accedi per commentare.


Image Analyst
Image Analyst il 23 Dic 2015
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 Commento
Ekta Sharma
Ekta Sharma il 29 Feb 2016
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

Accedi per commentare.

Community Treasure Hunt

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

Start Hunting!

Translated by