Home > other >  how can we calculate gradients for rgb and apply it for sobel
how can we calculate gradients for rgb and apply it for sobel

Time:10-08

I am trying to write a sobel filter.I made a gray filter for that and started to write sobel filter but I do not understand some things.I found calculating gx and gy but nobody tells about applying it.What should I do for using them for r,g,b?I am so confused.When I use gradinet(gradient = Math.Abs(gx) Math.Abs(gy);) should I apply it on a pixel for every r,g,b?I mean if I should do that which way can I use?I could not find any code.By the way when we apply this method matrix is getting smaller.I am so confused about applying this on code.

CodePudding user response:

You cannot apply a sobel filter to an rgb image. Usually you apply it to each of the color channels or you convert the rgb image to grayscale first.

The resulting image of a convolution is always smaller. Either live with it, enlarge your image prior to convolution or after it. There are countless methods to achieve this.

  • Related