My original data is (640 x480 double ) 2D array and in this image (pixel data from camera) there are certain patterns or objects I want to detect with a specific size. I want to start from row 2 col 2 and increment in steps of 1 along the col and row to find pixels with certain value (i.e >1) this indicates a pixel which is potentially part of my object to be detected. If the adjacent pixels are equal 1 (minimum size of a object is a 3 x 3 array of 1s and maximum size of a object is a 100 x 100 array of 1s) then this is a potential object to be detected, for eg:
0 0 1 1 1 0 0, 1 0 1 1 1 0 0, 0 0 1 1 1 1 0,
In the above matrix 1 particle (3 x 3 array of 1s) is detected
Once I have found a particle I want to sum up all the element values which contribute to the particle.
I have started working on a simple matrix below see code but I have got lost once I have detected a particle I do not know how to change this back into my original double values in the original 2DArray called A.
Any help will be appreciated.
A = magic(20);
B = A>=300;
pattern = [1,1];
Cind = cell(1,20);
Dind = cell(1,18);
for r= 1:20
Cind{r} = strfind(B(r,:),pattern);
end
for n= 1:18
Dind{n} = isequal(Cind(1,n), Cind(1,n+1));
if isempty(Cind{n})
Dind{n}=0;
end
end
Thanks....
Aucun commentaire:
Enregistrer un commentaire