0

I am trying to find coordinates of edges of the image (a rectangle, basicly) formed by this code:

%Pre-setting Variables
N=300; M=300; H=80; L=100; Alfa=10;
Tx=20; Ty=20; Tz=10;  
Sx=0.6; Sy=0.7; Sz=1.2;
Tetax=20; Tetay=30; Tetaz=20;  

% Forming source image
source=zeros(M,N);
source(round(M/2-L/2):round(M/2+L/2),round(N/2-H/2):round(N/2+H/2))=1;
source=imrotate(source,Alfa,'crop'); 
imshow(source);
disp(source);

I really have no clue how to do it, and I can't change the method of forming the image. Thank you in advance.

TylerH
  • 20,799
  • 66
  • 75
  • 101

1 Answers1

0

I recomend using corner to find the coordinates of the corner points.

And if you really just have a image of zeros and ones with a rectangle that is aligned with the pixel grid, you can also use

%y-coordinates
find(sum(img,1),1,'first')
find(sum(img,1),1,'last')

%x-coordinates
find(sum(img,2),1,'first')
find(sum(img,2),1,'last')

(or even replace sum by any)

flawr
  • 10,814
  • 3
  • 41
  • 71