2017-06-02 64 views
-1

004_1.bmp我想知道的二進制圖像和圈

clc 
clear 
a = imread('004_1.bmp'); 
I2 = imcrop(a,[80 17 101 180]); 
[i,j]=size(I2);  


x_hist=sum(I2,1); 
y_hist=(sum(I2,2))'; 

x=1:j ; y=1:i; 
centx=sum(x.*x_hist)/sum(x_hist) 
centy=sum(y.*y_hist)/sum(y_hist) 


BW = edge(I2,'Canny',0.329); 
bw2 = imcomplement(BW); 
circle = int32([centx,centy,40]); 
shapeInserter = vision.ShapeInserter('Fill',false); 
release(shapeInserter); 
set(shapeInserter,'Shape','Circles'); 
K = step(shapeInserter,bw2,circle); 


figure, imshow(K) 

我有這樣的計劃,我想知道從圈和二進制圖像之間的交叉值之間的價值交叉點。如果有人知道如何找到價值?

+0

必須添加圖像太...以便用戶可以嘗試你的代碼.. –

+0

圖片添加..謝謝你的意見:) –

回答

1

您可以使用find獲得所需圖像的指標如下:

bwCircle = step(shapeInserter,true(size(bw2)),circle); % construct binary image of circle only 
[i, j] = find ((bw2 | bwCircle) == 0); % find the indexes of the intersection between the binary image and the circle 

figure 
imshow(bw2 & bwCircle) % plot the combination of both images 
hold on 
plot(j, i, 'r*') % plot the intersection points 

enter image description here

+0

好的,謝謝你的幫助:D –

+0

如果我想總結所有的交集,我怎麼能總結它?但我想總結順時針所有交集 –

+0

這可能是一個很好的想問一個關於它的單獨問題。如果你總結他們,你爲什麼要順時針? – m7913d