14
$\begingroup$

In a picture, there are many different colors. How can I just want to find the position of one color. In the following picture, if I would like to find the coordinates of the position of blue, how can I achieve that? Thank you very much! enter image description here

$\endgroup$
2
  • $\begingroup$ By Blue you mean RGBColor[0,0,1]? Is PixelValuePositions ok? $\endgroup$
    – Kuba
    Oct 31, 2013 at 7:17
  • $\begingroup$ @Kuba I think that is a good answer. image = Import["1wEvU.jpg"]; PixelValuePositions[image, Blue, 0.4] gave me {{1605, 810}, {1606, 810}, {1604, 809}, {1605, 809}, ... $\endgroup$
    – Nasser
    Oct 31, 2013 at 7:22

1 Answer 1

17
$\begingroup$
image = Import["http://i.stack.imgur.com/1wEvU.jpg"];

Look for anything within 0.3 of Blue:

pv = PixelValuePositions[image, Blue, .3]

{{1614, 784}}

Just one pixel is that close to pure Blue. To display it:

HighlightImage[image, pv, "HighlightColor" -> White, 
  Method -> {"DiskMarkers", 20}]

It's over by the Balloon(?).

image

$\endgroup$
6
  • 2
    $\begingroup$ Ooh, I've never come across HighlightImage before. +1, but why is it community wiki? $\endgroup$ Oct 31, 2013 at 10:35
  • $\begingroup$ @SimonWoods :) Too long to be yet another comment-as-answer, but didn't want to snatch credit away from commenters... $\endgroup$
    – cormullion
    Oct 31, 2013 at 10:37
  • $\begingroup$ @cormullion Can PixelValuePositions be used to find some "strange" color? $\endgroup$
    – KathyLL
    Oct 31, 2013 at 21:35
  • $\begingroup$ @kathyLL any color will work, if you know its RGB values. But strangeness needs defining! :) $\endgroup$
    – cormullion
    Oct 31, 2013 at 21:51
  • $\begingroup$ @cormullion Thanks a lot! $\endgroup$
    – KathyLL
    Nov 1, 2013 at 18:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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