Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This question already has an answer here:

How Can we use PixelValue with pixel indices?

share|improve this question

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
1  
@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}]
share|improve this answer
1  
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

Not the answer you're looking for? Browse other questions tagged or ask your own question.