¿Alguien me puede ayudar a convertir el tipo escalar de openCV a tipos básicos como float o double?opencv: convertir escalar a flotante o tipo doble
Scalar Sum1=sum(arg1),Sum2=sum(arg2);
theta.at<float>(i,j)=0.5*atan(Sum1/Sum2);
tengo que resumir todos los elementos de la estera objetos arg1
y arg2
(suma barrio), entonces tengo que llevar a cabo su división de encontrar campo de orientación en cada uno de píxeles. Realicé suma, pero como tengo que aplicar la función arctan, el tipo escalar no encaja. ¿Alguien puede ayudarme a convertir el tipo escalar a tipos básicos?
realidad estoy tratando de aplicar el filtro y el código que he hecho hasta ahora-Gabor log es:
//function to enhance fingerprint by log-gabor filter
void filter(Mat src, Mat finalImage)
{
//Sobel derivatives for orientation estimation
Mat grad_x,grad_y,grad2_x,grad2_y,fImage;
src.convertTo(fImage, CV_32F);
//1st and second order gradient
Sobel(fImage,grad_x,CV_32F,1,0,3);
Sobel(fImage,grad_y,CV_32F,0,1,3);
Sobel(fImage,grad2_x,CV_32F,2,0,3);
Sobel(fImage,grad2_y,CV_32F,0,2,3);
//orientation estimation
Mat theta=Mat::zeros(fImage.size(),CV_32F);
Size block=Size(12,12);
copyMakeBorder(grad_x, grad_x, block.height/2, block.height/2,
block.width/2,block.width/2 , BORDER_CONSTANT, Scalar::all(0));
copyMakeBorder(grad2_x, grad2_x, block.height/2, block.height/2,
block.width/2,block.width/2 , BORDER_CONSTANT, Scalar::all(0));
copyMakeBorder(grad_y, grad_y, block.height/2, block.height/2,
block.width/2,block.width/2 , BORDER_CONSTANT, Scalar::all(0));
copyMakeBorder(grad2_y, grad2_y, block.height/2, block.height/2,
block.width/2,block.width/2 , BORDER_CONSTANT, Scalar::all(0));
Size imgSz=grad_x.size();
for(int i=block.width/2;i<imgSz.width-block.width/2;++i)
for(int j=block.height/2;j<imgSz.height-block.height/2;++j)
{
Mat roi_gradX=grad_x(Range(i-block.width/2,i+block.width/2),
Range(j-block.width/2,j+block.width/2));
Mat roi_gradY=grad_y(Range(i-block.width/2,i+block.width/2),
Range(j-block.width/2,j+block.width/2));
Mat roi_gradX2=grad2_x(Range(i-block.width/2,i+block.width/2),
Range(j-block.width/2,j+block.width/2));
Mat roi_gradY2=grad2_y(Range(i-block.width/2,i+block.width/2),
Range(j-block.width/2,j+block.width/2));
Mat arg1,arg2;
multiply(roi_gradX,roi_gradY,arg1);
arg1*=2;
subtract(roi_gradX2,roi_gradY2,arg2);
Scalar Sum1=sum(arg1),Sum2=sum(arg2);
theta.at<float>(i,j)=0.5*atan(Sum1/Sum2);
}
}
estoy tratando de aplicar el filtro para la mejora de la huella digital-Gabor ingrese ..... He editado mi post y añadido el código ..... – bistaumanga