PixelValue with pixel indices [duplicate]

How Can we use PixelValue with pixel indices?

-

marked as duplicate by C. E., Sjoerd C. de Vries, R. M.♦Jan 7 '14 at 23:09

This question was marked as an exact duplicate of an existing question.

Can you be more specific than just a one liner that repeats the title? Specifically, how is this not addressed by the documentation for PixelValue? – R. M. Jan 7 '14 at 22:03
You can define a new function that uses indices instead of pixel coordinates: getPixelValue[img_, {x_, y_}] := PixelValue[img, {First@ImageDimensions[img] - y, x}] – C. E. Jan 7 '14 at 22:12
@Anon, I think that getPixelValue[img_, {x_, y_}] := PixelValue[img, {First@ImageDimensions[img] - y, x}] is not correct and you have to correct like this getPixelValue[img_, {x_, y_}] := PixelValue[img, {x , ImageDimensions[img][[2]]-y}] – phdstudent Jan 7 '14 at 22:29
@phdstudent Yes, you are right. – C. E. Jan 7 '14 at 22:40
@rm-rf, my question was not a duplicate one. In your link, they talked about ImageTake[]. – phdstudent Jan 7 '14 at 23:19

getPixelValue[img_, {x_, y_}] := PixelValue[img, {x , ImageDimensions[img][[2]]+1-y}]

If this answer solves your problem, that's good. But why do you want to introduce another coordinate system? There are already three... If x is supposed to be a column index from 1 to width and y a row index from 1 to height, then your formula should be PixelValue[img, {x, height + 1 - y}]. You may want to check out the section "Coordinate Systems" from this tutorial (reference.wolfram.com/mathematica/tutorial/ImageProcessing.html). – Matthias Odisio Jan 8 '14 at 4:09
@MatthiasOdisio, sorry I forget just to add 1 to ImageDimensions[img][[2]]+1-y – phdstudent Jan 8 '14 at 4:16