Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

This question already has an answer here:

How Can we use PixelValue with pixel indices?

share|improve this question

marked as duplicate by Pickett, Sjoerd C. de Vries, rm -rf Jan 7 at 23:09

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new 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? –  rm -rf Jan 7 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}] –  Pickett Jan 7 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 at 22:29
    
@phdstudent Yes, you are right. –  Pickett Jan 7 at 22:40
    
@rm-rf, my question was not a duplicate one. In your link, they talked about ImageTake[]. –  phdstudent Jan 7 at 23:19
show 1 more comment

1 Answer 1

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 at 4:09
    
@MatthiasOdisio, sorry I forget just to add 1 to ImageDimensions[img][[2]]+1-y –  phdstudent Jan 8 at 4:16
add comment

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