From: Christian Eschermann on 11 May 2010 07:27 Hello, I need the centres of the „0-areas“ in a 2-dim 0-1-array . Moreover I need the size of each area. Example: z = [ 1 1 0 1 1; 1 0 0 0 1; 1 1 0 1 1; 1 1 1 1 1; 1 0 0 0 1] Result: Centre, Area: C1 = 12, A1 = 5 C2 = 15, A2 = 3 It’s easy to find centres by using „mean“. But I need a hint how to differentiate between different 0-areas. For the area-sizes I found this: >> z = [1 1 1 0 1 1 0 0 1 0 1 1 0 1 1 1]; >> l = findstr([0 z 0],[1 0])-findstr([0 z 0],[0 1]) l = 3 2 1 2 3 Problem: „findstr“ doesn’t work in a 2-dim array. Is there any alternative? Thank you. Christian
From: Sean on 11 May 2010 07:36 "Christian Eschermann" <christian.eschermann(a)still.de> wrote in message <hsbeu8$f82$1(a)fred.mathworks.com>... > Hello, > > I need the centres of the „0-areas“ in a 2-dim 0-1-array . Moreover I need the size of each area. > > Example: > > z = [ > 1 1 0 1 1; > 1 0 0 0 1; > 1 1 0 1 1; > 1 1 1 1 1; > 1 0 0 0 1] > > Result: > > Centre, Area: > C1 = 12, A1 = 5 > C2 = 15, A2 = 3 > > It’s easy to find centres by using „mean“. But I need a hint how to differentiate between different 0-areas. > > For the area-sizes I found this: > > >> z = [1 1 1 0 1 1 0 0 1 0 1 1 0 1 1 1]; > >> l = findstr([0 z 0],[1 0])-findstr([0 z 0],[0 1]) > > l = > > 3 2 1 2 3 > > Problem: „findstr“ doesn’t work in a 2-dim array. Is there any alternative? > > > Thank you. > Christian Do you have the image processing toolbox? If so: >>help bwconncomp >>help regionprops Those two will do exactly what you want.
|
Pages: 1 Prev: second order ordinary differential equations Next: delete application from memory |