I am actually following the instructions of a paper:

The input is supposed to be a binary "edge" image. The output should be a new image, modified by the instructions in the paper. My understanding of the instructions is, that one takes the gradient image of the edge image and modifies it and creates a new image with the modified gradient. Therefore is there a possibility in MATLAB/OpenCV of creating the same image with a new gradient?
Reference to the paper: Li, Hongyu, and Lei Chen. "Removal of false positive in object detection with contour-based classifiers." ICIP. 2010.
The formula displayed, I suppose, converts the gradient orientation form radians to pixel intensity ranging from 0 to 255 (standard for many images format). In matlab, if you have the Image Processing Toolbox, you can get the image gradient direction as follows:
[Gmag, Gdir]=imgradient(YourImage);
Now, as said in the manual, Gdir contains angles in degrees within the range [-180 180]. If you wish to have them in the [0 255] range to follow what is in this paper, do as the formula says:
GdirI=(Gdir+180)*(255/360);
You can also display an angle plot in its original format using imagesc(Gdir).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With