I am looking for a method in which i can manipulate elements in a matrix a certain distance, from a certain point.
an example could be.
given
1 2 3 4
int matrix[4][10] = {{1,2,3,1,2,3,1,2,3,1},
{1,2,3,1,2,3,1,2,3,1},
{1,7,3,1,4,3,3,2,3,1},
{1,3,3,1,5,3,4,2,3,5}}
and I say that my starting point is 3,3, and all elements which is distanced 2 element shall be rewritten to 2 such that the matrix will end up looking like this
So if I understand correctly, you want to locate a matrix element x and change all matrix elements a distance d away from that data point to some value y.
I think on the surface it's pretty easy to do:
1 2 3 4 5 6 7 8
int matrix[w][h]; // = ...
int targetX, targetY; //x, y value of matrix element that change is based off
int distance; //distance from target that will be changed
int changeValue; //value to change the matrix elements to
matrix[targetX + distance][targetY] = changeValue;
// ...
The issue is that if, for example, targetX > distance, you will have to handle that case differently.
The idea is it has to move like a wavefront planer..
I've created a method which does this, but for some reason it isn't doing the correct thing for the adjacent pixels. Only the pixel on the line gets inserted correctly