Search code examples
imageimage-processingcolorsimage-editing

Easy way to convert color range to another?


I would like to convert the purple color in this image:

enter image description here to blue such as:

enter image description here

Is there an easy way to accomplish this? If not, is there an easy way to replicate the same effect?

Thanks


Solution

  • You could separate the image in R,G and B channels, and replace the red channel by zeroes, leaving only the G and B channels.

    Example in Mathematica:

    i = Import["http://tinyurl.com/3wqklof"];
    ColorCombine@{ImageSubtract[#[[1]], #[[1]]], #[[2]], #[[3]]} &@ ColorSeparate@i
    

    enter image description here

    Edit

    Or, If you need an "exact" blue image, separate in the "HSB" color space, replacing all non zero values of the H matrix by 2/3 (blue), leaving the S and B components untouched.

    Example:

    ColorCombine[{Image[2/3 ImageData@ImageAdd[#[[1]], #[[1]]]], #[[2]], #[[3]]} &@
                  ColorSeparate[i, "HSB"], "HSB"]
    

    enter image description here