Q:

What's wrong when I use ImageApplyIndexed?

I am reading a ebook called Basic image processing in Mathematica which can download free in the iBooks.
   In the page 114,it introduce a function ImageApplyIndexed.
i = ConstantImage[Black, {50, 50}];
{width, height} = ImageDimensions@i;
Clear[f];
f[pixel_, pos_] := 
Module[{dis = Norm[{width/2, height/2} - pos]}, 
pixel + dis/Norm[Min[width/2, height/2]]];
ImageApplyIndexed[f, i]

output:

But if I change the ImageSize of i:
 i = ConstantImage[Black, {100, 50}];

output:
I don't know why the center of the black circle not in the center of the image?

A:

ImageApplyIndexed passes an index to your function, not X/Y coordinates, i.e. a list containing the row index and the column index (in that order). So you need to you Norm[{height/2, width/2} - pos. Because height is the number of rows, and width is the number of columns.

