CIS581-Presentation Contour finding Presented by: Wang, Qiang Supervised by: Dr. Longin Jan Latecki.
-
Upload
erick-ward -
Category
Documents
-
view
225 -
download
1
Transcript of CIS581-Presentation Contour finding Presented by: Wang, Qiang Supervised by: Dr. Longin Jan Latecki.
![Page 1: CIS581-Presentation Contour finding Presented by: Wang, Qiang Supervised by: Dr. Longin Jan Latecki.](https://reader035.fdocuments.net/reader035/viewer/2022062407/56649d1c5503460f949f183d/html5/thumbnails/1.jpg)
CIS581-Presentation
Contour finding
Presented by: Wang , Qiang
Supervised by: Dr. Longin Jan Latecki
![Page 2: CIS581-Presentation Contour finding Presented by: Wang, Qiang Supervised by: Dr. Longin Jan Latecki.](https://reader035.fdocuments.net/reader035/viewer/2022062407/56649d1c5503460f949f183d/html5/thumbnails/2.jpg)
Agenda
Introduction
Five steps to reach the goal
(processing the image)
Conclusion
![Page 3: CIS581-Presentation Contour finding Presented by: Wang, Qiang Supervised by: Dr. Longin Jan Latecki.](https://reader035.fdocuments.net/reader035/viewer/2022062407/56649d1c5503460f949f183d/html5/thumbnails/3.jpg)
Contour finding
Introduction
•Output: Sequence of boundary pixels of the largest object
•Input: Binary image containing segmented objects as black pixels
•Apply to MPEG-7 Shape 1 data set. (1400 images)
![Page 4: CIS581-Presentation Contour finding Presented by: Wang, Qiang Supervised by: Dr. Longin Jan Latecki.](https://reader035.fdocuments.net/reader035/viewer/2022062407/56649d1c5503460f949f183d/html5/thumbnails/4.jpg)
Introduction Sample images:
![Page 5: CIS581-Presentation Contour finding Presented by: Wang, Qiang Supervised by: Dr. Longin Jan Latecki.](https://reader035.fdocuments.net/reader035/viewer/2022062407/56649d1c5503460f949f183d/html5/thumbnails/5.jpg)
•Pre-processing: erase the noise•Edge detection•Contour detection•Delete the redundant points•Simplify the contours
Five steps:
Processing
![Page 6: CIS581-Presentation Contour finding Presented by: Wang, Qiang Supervised by: Dr. Longin Jan Latecki.](https://reader035.fdocuments.net/reader035/viewer/2022062407/56649d1c5503460f949f183d/html5/thumbnails/6.jpg)
Pre-processing Pre-processing: Erasing the noisefor num_bmp=1:1400 tmp=imread(strcat(int2str(num_bmp),'.bmp')); tmp=medfilt2(tmp,[10 10]); x = zeros(size(tmp,1)+6,size(tmp,2)+6); x(4:size(tmp,1)+3,4:size(tmp,2)+3)=tmp;
x=x~=0; x=im2bw(x); …End% some other choices of filters: % tmp=filter2(1/25*ones(5,5),tmp);% tmp=ordfilt2(tmp,36,ones(6,6));
![Page 7: CIS581-Presentation Contour finding Presented by: Wang, Qiang Supervised by: Dr. Longin Jan Latecki.](https://reader035.fdocuments.net/reader035/viewer/2022062407/56649d1c5503460f949f183d/html5/thumbnails/7.jpg)
Pre-processing Pre-processing: Erasing the noiseAnother way to erase the noise: Object LabelingFind out all those pixels connected to each other, and label them with the same number.
1 1 1 0 0 0 0 01 1 1 0 1 1 0 01 1 1 0 1 1 0 01 1 1 0 0 0 1 01 1 1 0 0 0 1 01 1 1 0 0 0 1 01 1 1 0 0 1 1 01 1 1 0 0 0 0 0
[labeled,numObjects] = bwlabel(bw,4)
1 1 1 0 0 0 0 01 1 1 0 2 2 0 01 1 1 0 2 2 0 01 1 1 0 0 0 0
1 1 1 0 0 0 3 01 1 1 0 0 0 3 01 1 1 0 0 3 3 01 1 1 0 0 0 0 0
![Page 8: CIS581-Presentation Contour finding Presented by: Wang, Qiang Supervised by: Dr. Longin Jan Latecki.](https://reader035.fdocuments.net/reader035/viewer/2022062407/56649d1c5503460f949f183d/html5/thumbnails/8.jpg)
Pre-processing Pre-processing: Erasing the noise
![Page 9: CIS581-Presentation Contour finding Presented by: Wang, Qiang Supervised by: Dr. Longin Jan Latecki.](https://reader035.fdocuments.net/reader035/viewer/2022062407/56649d1c5503460f949f183d/html5/thumbnails/9.jpg)
Edge detection
Edge detection Fortunately… there is a very useful function in matlab: img_edge=edge(
x);
![Page 10: CIS581-Presentation Contour finding Presented by: Wang, Qiang Supervised by: Dr. Longin Jan Latecki.](https://reader035.fdocuments.net/reader035/viewer/2022062407/56649d1c5503460f949f183d/html5/thumbnails/10.jpg)
Edge detection
![Page 11: CIS581-Presentation Contour finding Presented by: Wang, Qiang Supervised by: Dr. Longin Jan Latecki.](https://reader035.fdocuments.net/reader035/viewer/2022062407/56649d1c5503460f949f183d/html5/thumbnails/11.jpg)
Contour detection
Problem: after edge detection, we just get an image with all those points on the contour as 1 while all the others as 0,we need to get the coordinates of those 1 pixels (vertices).
Basic idea: just travel around all the contour, find out all the pixels of 1.
![Page 12: CIS581-Presentation Contour finding Presented by: Wang, Qiang Supervised by: Dr. Longin Jan Latecki.](https://reader035.fdocuments.net/reader035/viewer/2022062407/56649d1c5503460f949f183d/html5/thumbnails/12.jpg)
Contour detectionHow to travel??
•Need a starting point;•Need to decide the direction to travel;•Need to avoid any circle in traveling.
(The last one is the most tricky thing)
![Page 13: CIS581-Presentation Contour finding Presented by: Wang, Qiang Supervised by: Dr. Longin Jan Latecki.](https://reader035.fdocuments.net/reader035/viewer/2022062407/56649d1c5503460f949f183d/html5/thumbnails/13.jpg)
Contour detection
Solution:
A matrix and
a vector
![Page 14: CIS581-Presentation Contour finding Presented by: Wang, Qiang Supervised by: Dr. Longin Jan Latecki.](https://reader035.fdocuments.net/reader035/viewer/2022062407/56649d1c5503460f949f183d/html5/thumbnails/14.jpg)
Contour detection
The matrix: Anti-clockwise
[1 1 0 -1 -1 -1 0 1 for x 0 1 1 1 0 -1 -1 -1]; for y
![Page 15: CIS581-Presentation Contour finding Presented by: Wang, Qiang Supervised by: Dr. Longin Jan Latecki.](https://reader035.fdocuments.net/reader035/viewer/2022062407/56649d1c5503460f949f183d/html5/thumbnails/15.jpg)
Contour detection
The vector:
1 2 3 4 5 6 7 8 Current neighbor index
[8 8 2 2 4 4 6 6] New neighbor indexMake sure we know which one will be next neighbor to check!Keep anti-clockwise direction.
![Page 16: CIS581-Presentation Contour finding Presented by: Wang, Qiang Supervised by: Dr. Longin Jan Latecki.](https://reader035.fdocuments.net/reader035/viewer/2022062407/56649d1c5503460f949f183d/html5/thumbnails/16.jpg)
Contour detectionCode:
[a b]=find(img_edge); counter=size(find(img_edge),1); point_x(1)=a(1); point_y(1)=b(1); % find out the starting point neighbor_offset=[1 1 0 -1 -1 -1 0 1;0 1 1 1 0 -1 -1 -1]; new_neighbor=[8 8 2 2 4 4 6 6]; neighbor=1;
for i=1:counter %try to find out all those pixels on the contour while img_edge(point_x(i)+neighbor_offset(1,neighbor),point_y(i)+neighbor_offset(2,neighbor))==0 neighbor=mod(neighbor,8)+1; end
point_x(i+1)=point_x(i)+neighbor_offset(1,neighbor); point_y(i+1)=point_y(i)+neighbor_offset(2,neighbor); neighbor=new_neighbor(neighbor);
if and(point_x(1)==point_x(i+1),point_y(1)==point_y(i+1)) break end end
![Page 17: CIS581-Presentation Contour finding Presented by: Wang, Qiang Supervised by: Dr. Longin Jan Latecki.](https://reader035.fdocuments.net/reader035/viewer/2022062407/56649d1c5503460f949f183d/html5/thumbnails/17.jpg)
Contour detection
![Page 18: CIS581-Presentation Contour finding Presented by: Wang, Qiang Supervised by: Dr. Longin Jan Latecki.](https://reader035.fdocuments.net/reader035/viewer/2022062407/56649d1c5503460f949f183d/html5/thumbnails/18.jpg)
redundant points
Delete the redundant points When there are many points on exact the same straight line,
we just need to keep the starting and ending points.
for i=1:size(point_x,2)-2; if or(and(point_x(i)==point_x(i+1),point_x(i+1)==point_x(i+2)), and(point_y(i)==point_y(i+1),point_y(i+1)==point_y(i+2))) point_x(i+1)=[]; point_y(i+1)=[]; end end
![Page 19: CIS581-Presentation Contour finding Presented by: Wang, Qiang Supervised by: Dr. Longin Jan Latecki.](https://reader035.fdocuments.net/reader035/viewer/2022062407/56649d1c5503460f949f183d/html5/thumbnails/19.jpg)
Simplify the contour
for i1=1:n-pointsleftevomaass=evo(Zneu);%Function: computes a relvance measure for every point"[y,I]=sort(evomaass);Zneu(I(1))=[];% in Zneu the points with the smallest relevance measure is % removedend
Simplify the Contour: using a small number of edges to represent the contour.
![Page 20: CIS581-Presentation Contour finding Presented by: Wang, Qiang Supervised by: Dr. Longin Jan Latecki.](https://reader035.fdocuments.net/reader035/viewer/2022062407/56649d1c5503460f949f183d/html5/thumbnails/20.jpg)
Simplify the contour
function K=evo(Z)n=length(Z);LM=norm(Z(2)-Z(n));LR=norm(Z(1)-Z(2));LL=norm(Z(n-1)-Z(1));His(1)=LL+LR-LM;for j=2:n-1 LM=norm(Z(j-1)-Z(j+1)); LR=norm(Z(j)-Z(j+1)); LL=norm(Z(j-1)-Z(j)); His(j)=LL+LR-LM;end;LM=norm(Z(n-1)-Z(1));LR=norm(Z(n)-Z(1));LL=norm(Z(n-1)-Z(n));His(n)=LL+LR-LM;K=His;
![Page 21: CIS581-Presentation Contour finding Presented by: Wang, Qiang Supervised by: Dr. Longin Jan Latecki.](https://reader035.fdocuments.net/reader035/viewer/2022062407/56649d1c5503460f949f183d/html5/thumbnails/21.jpg)
Simplify the contour
![Page 22: CIS581-Presentation Contour finding Presented by: Wang, Qiang Supervised by: Dr. Longin Jan Latecki.](https://reader035.fdocuments.net/reader035/viewer/2022062407/56649d1c5503460f949f183d/html5/thumbnails/22.jpg)
Conclusion
input image: 512 * 512 pixels
Output file: 50 points
input size: 250 KB Output size: < 400 bytes
Based on the output: we can do•Image compression•Image processing•Feature extraction and analysis
...
![Page 23: CIS581-Presentation Contour finding Presented by: Wang, Qiang Supervised by: Dr. Longin Jan Latecki.](https://reader035.fdocuments.net/reader035/viewer/2022062407/56649d1c5503460f949f183d/html5/thumbnails/23.jpg)
The end
Thanks!