Convert image pixels to quadruples [closed]

Example given an image which width and height is a power of two .

First step : Divide each image into Cartesian coordinate quadrants

 _____ _____
|     |     |
|  2  |  1  |
|_____|_____|
|     |     |
|  4  |  3  |
|_____|_____|


Second step : Divide each quadrant to another four quadrants and add new quadrant id after the old one , like this :

 _____ _____ _____ _____
|     |     |     |     |
|  22 |  21 |  12 |  11 |
|_____|_____|_____|_____|
|     |     |     |     |
|  23 |  24 |  13 |  14 |
|_____|_____|_____|_____|
|     |     |     |     |
|  32 |  31 |  42 |  41 |
|_____|_____|_____|_____|
|     |     |     |     |
|  33 |  34 |  43 |  44 |
|_____|_____|_____|_____|


And so on...

 _____ _____ _____ _____ _____ _____ _____ _____
|     |     |     |     |     |     |     |     |
| 222 | 221 | 212 | 211 | 122 | 121 | 112 | 111 |
|_____|_____|_____|_____|_____|_____|_____|_____|
|     |     |     |     |     |     |     |     |
| 223 | 224 | 213 | 214 | 123 | 124 | 113 | 114 |
|_____|_____|_____|_____|_____|_____|_____|_____|
|     |     |     |     |     |     |     |     |
| 232 | 231 | 242 | 241 | 132 | 131 | 142 | 141 |
|_____|_____|_____|_____|_____|_____|_____|_____|
|     |     |     |     |     |     |     |     |
| 233 | 234 | 243 | 244 | 133 | 134 | 143 | 144 |
|_____|_____|_____|_____|_____|_____|_____|_____|
|     |     |     |     |     |     |     |     |
| 322 | 321 | 312 | 311 | 422 | 421 | 412 | 411 |
|_____|_____|_____|_____|_____|_____|_____|_____|
|     |     |     |     |     |     |     |     |
| 323 | 324 | 313 | 314 | 423 | 424 | 413 | 414 |
|_____|_____|_____|_____|_____|_____|_____|_____|
|     |     |     |     |     |     |     |     |
| 332 | 331 | 342 | 341 | 432 | 431 | 442 | 441 |
|_____|_____|_____|_____|_____|_____|_____|_____|
|     |     |     |     |     |     |     |     |
| 333 | 334 | 343 | 344 | 433 | 434 | 443 | 444 |
|_____|_____|_____|_____|_____|_____|_____|_____|


Until number of quadrants is equal to the number of pixels

Should return a 2d array of quadruple coordinates .

Inspired from : https://imgur.com/a/QWMGi

closed as unclear what you're asking by Howard, John Dvorak, Mhmd, ace, Heiko OberdiekApr 20 '14 at 12:26

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

• So what is the input and output? – ace Apr 20 '14 at 11:05
• Did you mean "power of two" height and width instead of "even" ? – Michael M. Apr 20 '14 at 11:16
• Suggestion for input: the side length of the image, in pixels. – Dan the Man Apr 20 '14 at 11:27
• What do you mean by "given an image"? Are we given the filename of the image? Or is the binary data of the image piped to the stdin of our program? What is the format of this image (e.g. jpg, png, gif)? If we are to "return a 2d array", does this mean we only have to write a function, not a complete program? P.S. it's "divide", not "devide". – ace Apr 20 '14 at 11:56
• I don't see the problem you guys have. If input and output aren't clearly specified, you're free to choose what's convenient. The problem itself is clearly specified in my opinion. – Martin Ender Apr 20 '14 at 12:32

Mathematica, 95 86 bytes

Since the method of input has not been specified, I'm simply expecting the resolution to be saved as an integer in the variable n

r={{""}};Do[r=ArrayFlatten[r/.q_String:>{{q<>"2",q<>"1"},{q<>"3",q<>"4"}}],{Log2@n}];r


With indentation:

r = {{""}};
Do[
r = ArrayFlatten[
r /. q_String :> {{q <> "2", q <> "1"}, {q <> "3", q <> "4"}}
],
{Log2@n}
];
r