This is the next part below:
2) Additional question:
Having received the average value of nonzero neighbors, I also want to check whether the neighboring elements are equal, smaller or larger than the average value of nonzero values. If it is greater than or equal to, then "1" or "0".
Note: if the neighbors are within a radius of two or more centers, take the lowest average center value for testing.
0 12 9
4 **9** 15
11 19 0
"9" in the middle is within a radius of 12, 15 and 19 centers, so take the minimum average value min [9.000, 9.000, 8.000] = 8.000
For example, when the radius = 1 m or 1 element.
new_x =
0 0 0 0 0
0 0 **9.0000** 9.0000 0
0 4.0000 9.0000 **9.0000** 0
0 **8.3333** **8.0000** 0 0
0 2.0000 4.0000 8.0000 0
0 4.0000 5.0000 8.0000 0
0 0 0 0 0
Test_x =
0 0 0 0 0
0 0 **9.0000** 1 0
0 0 1 **9.0000** 0
0 **8.3333** **8.0000** 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
==================================================== =================================
1) Let's say if I have the matrix shown below,
X =
0 0 0 0 0
0 0 12 9 0
0 4 9 15 0
0 11 19 0 0
0 2 4 8 0
0 4 5 8 0
0 0 0 0 0
, 10. , < 10.
, , ,
new_x =
0 0 0 0 0
0 0 9.0000 9.0000 0
0 4.0000 9.0000 9.0000 0
0 8.3333 8.0000 0 0
0 2.0000 4.0000 8.0000 0
0 4.0000 5.0000 8.0000 0
0 0 0 0 0
: , , , - (.. 10 ).
, , 10, "", avearge , , 1 m. 1 = 1 .
. 1 , .. 2 . , , .
**** . , = 2 , . **
,
= 1 = 1 ,
new_x = [(i + 1, j), (i-1, j), (i, j + 1) (i, j-1)] - , , .
= 2 = 2 ,
new_x = [(i + 1, j), (i + 2, j), (i-1, j), (i-2, j), (i, j + 1), (i, j + 2), (i, j-1), (i, j-2), (i + 1, j + 1), (i + 1, j-1), (i-1, j-1) (I-1, J + 1)].
=============================================== ===================
, .
, , .
.