Use Roipoly to develop an interesting polygon area for an image. Returns a binary image that can be used as a template for template filtering operations
BW = Roipoly (I, C, R) returns the polygon region specified by the vector C and R, where the c,r corresponds to the horizontal ordinate information.
The BW returned is a two-valued image bounded by a drawn polygon; see Matlab encyclopedia Http://wiki.ilovematlab.cn/index.php?doc-innerlink-roipoly
Here is a use of roipoly to do an interactive mapping program, I hope you like.
Clc Clear [Filename,pathname,q]=uigetfile ({' *.* '; ') *.bmp '; ' *.jpg '; ' *.png '}); If q>0 Lujing=strcat (Pathname,filename); I = Imread (lujing); Figure Imshow (I); End P=size (i,3); If p==3 R=i (:,:, 1); G=i (:,:, 2); B=i (:,:, 3); I1=rgb2gray (I); Else I1=i; End Hold on [X,y,c]=ginput (1); M (1) =x; N (1) =y; Plot (x,y, ' R '); k=2; while (c==1) [X1,y1,c1]=ginput (1); If C1==1 M (k) =x1; N (k) =y1; Plot (x,y, ' R '); Line ([M (K-1) m (k)],[n (k-1) n (k)]); k=k+1; C=C1; Else Break End End Line ([M (K-1) m (1)],[n (k-1) n (1)]); BW = Roipoly (i1,m,n); If p==3 R1=double (R). *double (BW); G1=double (g). *double (BW); B1=double (b). *double (BW); I1=cat (3,R1,G1,B1); Figure Imshow (Mat2gray (I1)); Else I2=double (I1). *double (BW); Figure Imshow (Mat2gray (I2)); End |