Image Magick Problem

Discussion in 'Mac Programming' started by BobRon, Aug 11, 2013.

  1. macrumors member

    Oct 13, 2012
    I am using imagemagick to detect the color of one pixel of an image. I need a program in bash that matches the discovered hex cold to the nearest of 11 pre-definded pixels. Is this possible? Or do i need to write if/else statements for every possible tint of purple.:(
  2. mwb
    macrumors newbie

    Jul 21, 2011
    Once you have defined a suitable a way of measuring distance between colours, all you need to do is loop through your 11 pre-defined pixels and choose the (or 'a' in some cases) closest one. Not sure why you'd dream of creating millions if/else statements!

    Depending on your overall goal, you might want to try Image Magick's C++ API. Furthermore, if you're just looking up pixel values then maybe you should be using OpenImageIO.

Share This Page