OpenCV Q&A Forum - RSS feedhttp://answers.opencv.org/questions/OpenCV answersenCopyright <a href="http://www.opencv.org">OpenCV foundation</a>, 2012-2018.Tue, 10 Dec 2013 09:38:28 -0600Digital Image Gradienthttp://answers.opencv.org/question/25114/digital-image-gradient/Greetings .
I want to implement the Fast Radial Symmetry Transform (described here http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.97.4064&rep=rep1&type=pdf) to identify nuclei of cells in histological images of breast cancer for this I need to first calculate the gradient of the image. Until now he had not reviewed very afond what the gradient of a digital image is itself. Now I have several questions I would like to clarify:
(1) According understand the gradient of each point of a function is a vector formed by the partial derivatives of each variable, so for a digital image (which is a discretization of a 2D function) the gradient at each point in the image? which is exactly?. I guess it should be a two-channel digital image or am I wrong?
(2) How I can calculate or approximate the gradient of an image?
(3) Is there a function in OpenCV to compute or approximate the gradient of an image?
Thanks in advance for any help and/or suggestions and I apologize if my questions seem silly or too elementary .Sun, 08 Dec 2013 00:58:55 -0600http://answers.opencv.org/question/25114/digital-image-gradient/Answer by Spas Hristov for <p>Greetings .</p>
<p>I want to implement the Fast Radial Symmetry Transform (described here <a href="http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.97.4064&rep=rep1&type=pdf">http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.97.4064&rep=rep1&type=pdf</a>) to identify nuclei of cells in histological images of breast cancer for this I need to first calculate the gradient of the image. Until now he had not reviewed very afond what the gradient of a digital image is itself. Now I have several questions I would like to clarify:</p>
<p>(1) According understand the gradient of each point of a function is a vector formed by the partial derivatives of each variable, so for a digital image (which is a discretization of a 2D function) the gradient at each point in the image? which is exactly?. I guess it should be a two-channel digital image or am I wrong?</p>
<p>(2) How I can calculate or approximate the gradient of an image?</p>
<p>(3) Is there a function in OpenCV to compute or approximate the gradient of an image?</p>
<p>Thanks in advance for any help and/or suggestions and I apologize if my questions seem silly or too elementary .</p>
http://answers.opencv.org/question/25114/digital-image-gradient/?answer=25233#post-id-25233In opencv you can use sobel functions, or write your own functions:
For horizontal gradient compare pixelwit coordinates (x-1,y) and (x+1,y)
i.e. gard(x,y)=abs(image(x-1,y)-image.(x+1,y));
Analogously for the Y gradient.
p.p.
Here, that are my functions for calculating gradient on gray scale image. They are working with a pointer to the data stored in the matrix. The output matrices are 64bit, but 16 will do the job too, just change the cast and the constructor.
void gradx (Mat input, Mat &output)
{
output=Mat::zeros(input.size(),CV_64FC1);
for(int y=0;y<input.rows;y++)
{
for(int x=1;x<input.cols-1;x++)
{
*((double*)output.data+y*output.cols+x)=(double)(*(input.data+y*input.cols+x+1)-*(input.data+y*input.cols+x-1))/2;
}
}
}
void grady (Mat input, Mat &output)
{
output=Mat::zeros(input.size(),CV_64FC1);
for(int y=1;y<input.rows-1;y++)
{
for(int x=0;x<input.cols;x++)
{
*((double*)output.data+y*output.cols+x)=(double)(*(input.data+(y+1)*input.cols+x)-*(input.data+(y-1)*input.cols+x))/2;
}
}
}Tue, 10 Dec 2013 09:38:28 -0600http://answers.opencv.org/question/25114/digital-image-gradient/?answer=25233#post-id-25233Answer by SR for <p>Greetings .</p>
<p>I want to implement the Fast Radial Symmetry Transform (described here <a href="http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.97.4064&rep=rep1&type=pdf">http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.97.4064&rep=rep1&type=pdf</a>) to identify nuclei of cells in histological images of breast cancer for this I need to first calculate the gradient of the image. Until now he had not reviewed very afond what the gradient of a digital image is itself. Now I have several questions I would like to clarify:</p>
<p>(1) According understand the gradient of each point of a function is a vector formed by the partial derivatives of each variable, so for a digital image (which is a discretization of a 2D function) the gradient at each point in the image? which is exactly?. I guess it should be a two-channel digital image or am I wrong?</p>
<p>(2) How I can calculate or approximate the gradient of an image?</p>
<p>(3) Is there a function in OpenCV to compute or approximate the gradient of an image?</p>
<p>Thanks in advance for any help and/or suggestions and I apologize if my questions seem silly or too elementary .</p>
http://answers.opencv.org/question/25114/digital-image-gradient/?answer=25120#post-id-25120http://en.wikipedia.org/wiki/Image_gradientSun, 08 Dec 2013 04:40:46 -0600http://answers.opencv.org/question/25114/digital-image-gradient/?answer=25120#post-id-25120