Image Gradient: Light to Dark, Dark to Light From link: 


  Black-to-White transition is taken as Positive slope (it has a
  positive value) while White-to-Black transition is taken as a Negative
  slope (It has negative value). So when you convert data to np.uint8,
  all negative slopes are made zero. In simple words, you miss that
  edge.


So all i want is to write a function so i can keep negative gradient values.
I know how to use Sobel.

Here is the sobel link where I got to know light-to-dark, dark-to-light are gradient directions, which are also referred as $+\text ve$ and $-\text ve$ directions.

IMPROVED Question:
Please Suggest me a logic of the function to retain only $-\text ve$ values and clip $+\text ve$ values to zero?

My code: 

Sobel(grayImg, grad, CV_16S, 0, 1, -1, BORDER_DEFAULT);
         gradCpy = grad.clone();
         for(uint64_t i=0; i &lt;(gradCpy.rows); i++)
    {
        for(uint64_t j=0; j&lt;(gradCpy.cols); j++)
        {
            if ((gradCpy.data[((gradCpy.step/gradCpy.elemSize()))*i+j]) &gt; 0) {(gradCpy.data[(gradCpy.step/gradCpy.elemSize())*i+j]) = (int32_t)-0.0;} ///nega gradient img
            //if ((gradCpy.data[((gradCpy.step/gradCpy.elemSize()))*i+j]) &lt; 0.0) {gradCpy.data[((gradCpy.step/gradCpy.elemSize()))*i+j] = (int16_t)+0.0;}   ///pos gradient img
        } 
    }
    convertScaleAbs(gradCpy, opImg2);
    imshow("negative grad", opImg2);


But i am not getting expected results. As per Sobel link, I want to get edge at black-to-white that is $+\text ve$ gradient and another one at white-to-black that is $-\text ve$ gradient
The UINT8 type is limited to integer numbers on the range [0, 1, 2, ..., 255].
Hence negative values are clipped into 0.  

A solution could be wither use other types (Floating Points) or scale and shift.

For instance, given a Floating Point image with values imageMax and imageMean you can scale it into the [0, 1, 2, ..., 255] by doing:


Create only positive numbers: image - imageMin.
Scale it into the range: round(255 * (image - imageMin) / (imageMax - imageMin)).


Now the conversion won't loose data.

Others have different approach, set 128 to be zero.
Namely, add 128 to the image, clip it into [0, 255] and then convert to UINT8.

Enjoy.