0

I want to preprocess images so as to create a black and white image that contains the magnitude of the color gradient at each pixel.

Let me describe the problem in detail.

Assume we have 2 pixels P_1, P_2

if P_1 = [255, 0, 0] and P_2 = [0,255,0] Their grayscale values on a naive grayscale are P_1 = 255/3, P_2 = 255/3

if P_1 =[255,0,0] and P2 = [255,0,0] once again P_1 = P_2 = 255/3

However if we look at an approximation of the gradient at those pixels.

For the first case G = P_1 - P2 = [255, -255, 0] for the second case G = [0,0,0]

Clearly those 2 are different.

I need to get this saliency map due to the following problem with grayscaling:

Original image

enter image description here

Zoom:

enter image description here

Gray scale:

enter image description here

As you can see, when grayscaling, 2 regions with different colors get mapped to the same grey value.

My goal is to enhance edge detection, so what I want is to accentuate regions where there is a change in color, the opposite of what may happen when grayscaling.

For this effect I used opencv laplacian function to get the gradients, and then I turned the gradient's vector magnitude into a scalar. Which gives the following result:

enter image description here

It is better, but I want to know if there are other things I can do in addition to this, for example a deconvolution algorithm.

Community
  • 1
  • 1
Makogan
  • 5,325
  • 3
  • 18
  • 70
  • You can compute edges in the single channel images (only red, only blue, only green) and (for example) sum them, or you can do a HSV transformation and do the same. Some related discussion took place [here](http://answers.opencv.org/question/174239/any-method-to-extract-edges-from-a-color-image-directly-without-converting-it-into-grayscale-image/) – Antonio Feb 06 '19 at 19:09
  • Possible duplicate of [Edge detection on colored background using OpenCV](https://stackoverflow.com/questions/47899132/edge-detection-on-colored-background-using-opencv) – Antonio Feb 06 '19 at 19:10
  • Also related https://stackoverflow.com/questions/29156091/opencv-edge-border-detection-based-on-color – Antonio Feb 06 '19 at 19:17

0 Answers0