# Thread: Take pixels values from pic with specifiec order

1. ## Take pixels values from pic with specifiec order

Hi
one good question.
I have one pic 3X3. Width=3 Height=3

let say with values:

0 1 2
3 4 5
6 7 8
With 2 for (1 for width and 1 for height)i was able to take that values and save to one dimension array with that way:
PixelValues=0,3,6,1,4,7,2,5,8
My question:
Is possible to take that values with that order: 4,5,8,7,6,3,0,1,2.
Is possible to do that with for?? Or i need something else???
The method i use is PixelValues=Image1->Canvas->Pixels[i][j];

2. Sure, why not.

Draw out a 5x5 and 7x7 and 9x9 array of pixels and trace out the paths.

Something like
R1,D1
L2,U2,R2
D3.....

When you actually spot the pattern for the general case, then you can go away and implement some code which scans the image in the order you want it to.

3. I didnt get it. My example is for small array. I have to do it for big arrays from pics. My problem is to do it while i save the values in pic array.

code:

int x=Image1->Height;
int y=Image1->Width;

for(i=0;i<x;i++)
for(j=0;j<y;j++)
Pic1Values=Image->Canvas->Pixels[i][j];

now i have that code and i took values with the order i said in 3*3 array. I want to start from center and go right and down and left., like i said in 3*3 array. I possible that with for??? or another way? Can you explain your method with code?? Or other ideas in my code??

4. Right 1
Down 1
Left 2
Up 2

Work out how the sequence of run lengths progresses as you spiral out from the centre of the bitmap.
Then write some code to modify the values of 'i' and 'j' according to those rules.

5. Thats the problem, i dont know what to do or where to look to make the code you say. I still dont get it.
What is Right=1 Down=1 Left=2 up=2. What you mean by that??????
Oh and another problem the pics are not only bitmap. They are jpeg,png,tif etc.

6. Oh ffs, DRAW some grids out and work out the pattern.

Say just for arguments sake the run lengths go 1,1,2,2,3,3,4,4,5,5

int i = width / 2;
int j = height / 2;
int runlen = 1;

Treat middle as a special case
processPixel(i,j);

Then spiral outwards
for ( n = 0 ; n < runlen ; n++ ) processPixel(++i,j); // Right
for ( n = 0 ; n < runlen ; n++ ) processPixel(i,++j); // Down
runlen++;
for ( n = 0 ; n < runlen ; n++ ) processPixel(--i,j); // L
for ( n = 0 ; n < runlen ; n++ ) processPixel(i,--j); // U

7. Ok. But i use the method Image1->Canvas->Pixels[i][j] is possible to use that you say on that?? And you use 4 for how the array will save the values??? Because you stop one for and then start another. The array with first 2 for will save some values and after?? will continue with second 2 for?? from where it stoped??
and what is ProcessPixels?? Is method?? What will be the array?? what is variable n??