my data is a centroid of 2 pictures.
clear all;
background=imread('junc3.png');
backgray=rgb2gray(background);
frame1=imread('junc3-01.png');
backgray2=rgb2gray(frame1);
Z=imsubtract(backgray2,backgray);
figure;
imshow(Z);
se=strel('ball',5,5);
dilatedZ=imdilate(Z,se);
imshow(dilatedZ)
% centroid
Zbw = im2bw(dilatedZ,0.1);
imshow(Zbw)
cent = regionprops(Zbw,'centroid');
se=strel('line',11,90);
imshow(Zbw); hold on;
for x = 1:2
plot(cent(x).Centroid(1),cent(x).Centroid(2),'ro');
end
% frame2
clear all;
background=imread('junc3.png');
backgray=rgb2gray(background);
frame1=imread('junc3-02.png');
backgray3=rgb2gray(frame1);
Z=imsubtract(backgray3,backgray);
figure;
imshow(Z);
se=strel('ball',5,5);
dilatedZ=imdilate(Z,se);
imshow(dilatedZ)
% % centroid
Zbw = im2bw(dilatedZ,0.1);
imshow(Zbw)
cent = regionprops(Zbw,'centroid');
se=strel('line',11,90);
imshow(Zbw); hold on;
for x = 1:2
plot(cent(x).Centroid(1),cent(x).Centroid(2),'ro');
end

댓글 수: 2

Chaya N
Chaya N 2016년 10월 25일
And what is your question exactly? Please provide details.
syawal rosly
syawal rosly 2016년 11월 1일
sorry..actually i try to store the value of the centroid in array..i get the value of the centroid from a few of frame.. i want to do a car counting project.. im not really good in english..sorry..hehe

댓글을 달려면 로그인하십시오.

답변 (2개)

KSSV
KSSV 2016년 10월 26일
편집: KSSV 2016년 10월 26일

0 개 추천

I guess you want to store centroids into an array. You can store centroids into array using:
centroids=cat(1, cent.Centroid) ;
Walter Roberson
Walter Roberson 2016년 11월 1일

0 개 추천

Just before
% frame2
insert
cent1 = [cent.Centroid];
and after the end of the code you show,
cent2 = [cent.Centroid];
then cent1 and cent2 will each be numeric arrays with two rows each of which indicates one centroid.

카테고리

도움말 센터File Exchange에서 Computer Vision Toolbox에 대해 자세히 알아보기

질문:

2016년 10월 25일

답변:

2016년 11월 1일

Community Treasure Hunt

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

Start Hunting!

Translated by