improve kfactor support
This commit is contained in:
@ -35,6 +35,7 @@ struct Config
|
|||||||
bool quiet = false;
|
bool quiet = false;
|
||||||
bool interactive = false;
|
bool interactive = false;
|
||||||
bool simpleStich = false;
|
bool simpleStich = false;
|
||||||
|
float kFactor = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
const char *argp_program_version = "0.2";
|
const char *argp_program_version = "0.2";
|
||||||
@ -56,6 +57,7 @@ static struct argp_option options[] =
|
|||||||
{"interactive", 'i', 0, 0, "interactivly process multiple commands" },
|
{"interactive", 'i', 0, 0, "interactivly process multiple commands" },
|
||||||
{"simpe-stich", 'a', 0, 0, "Use non blending sticher" },
|
{"simpe-stich", 'a', 0, 0, "Use non blending sticher" },
|
||||||
{"curve", 'c', "File Name", 0, "curve file name" },
|
{"curve", 'c', "File Name", 0, "curve file name" },
|
||||||
|
{"kfactor", 'k', "Value", 0, "set the kfactor" },
|
||||||
{ 0 }
|
{ 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -78,7 +80,7 @@ error_t parse_opt (int key, char *arg, struct argp_state *state)
|
|||||||
config->norm.assign(arg);
|
config->norm.assign(arg);
|
||||||
break;
|
break;
|
||||||
case 's':
|
case 's':
|
||||||
config->minSize=atol(arg);
|
config->minSize=strtod(arg, nullptr);
|
||||||
break;
|
break;
|
||||||
case 'r':
|
case 'r':
|
||||||
config->harris = true;
|
config->harris = true;
|
||||||
@ -98,6 +100,9 @@ error_t parse_opt (int key, char *arg, struct argp_state *state)
|
|||||||
case 'c':
|
case 'c':
|
||||||
config->curve.assign(arg);
|
config->curve.assign(arg);
|
||||||
break;
|
break;
|
||||||
|
case 'k':
|
||||||
|
config->kFactor=strtod(arg, nullptr);
|
||||||
|
break;
|
||||||
case ARGP_KEY_ARG:
|
case ARGP_KEY_ARG:
|
||||||
config->commandsFiles = &state->argv[state->next-1];
|
config->commandsFiles = &state->argv[state->next-1];
|
||||||
state->next = state->argc;
|
state->next = state->argc;
|
||||||
|
12
src/main.cpp
12
src/main.cpp
@ -242,12 +242,14 @@ int perfromOperation(int operation, char** fileNames, const Config& config)
|
|||||||
{
|
{
|
||||||
cv::imshow( "Viewer", remaped.image );
|
cv::imshow( "Viewer", remaped.image );
|
||||||
cv::waitKey(0);
|
cv::waitKey(0);
|
||||||
cv::imshow( "Viewer", remaped.angleX);
|
cv::imshow( "Viewer", remaped.angle);
|
||||||
cv::waitKey(0);
|
cv::waitKey(0);
|
||||||
cv::imshow( "Viewer", remaped.angleY);
|
}
|
||||||
cv::waitKey(0);
|
|
||||||
applyKfactor(remaped.image, remaped.angleX, 3);
|
applyKfactor(remaped.image, remaped.angle, config.kFactor);
|
||||||
cv::imshow( "remaped.image", remaped.image );
|
if(config.verbose)
|
||||||
|
{
|
||||||
|
cv::imshow("Viewer", remaped.image );
|
||||||
cv::waitKey(0);
|
cv::waitKey(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -176,41 +176,43 @@ void applyKfactor(cv::Mat& image, const cv::Mat& angleMat, float kFactor)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void generateAngleMats(const cv::Mat& xMat, const cv::Mat& yMat, cv::Mat& xStrech, cv::Mat& yStrech)
|
static void generateAngleMats(const cv::Mat& xMat, const cv::Mat& yMat, cv::Mat& greatestAngle)
|
||||||
{
|
{
|
||||||
xStrech.create(xMat.rows, xMat.cols-1, CV_32FC1);
|
std::cout<<xMat<<std::endl;
|
||||||
yStrech.create(yMat.rows-1, xMat.cols, CV_32FC1);
|
greatestAngle.create(xMat.rows-1, xMat.cols-1, CV_32FC1);
|
||||||
for(int y = 0; y < xMat.rows; y++)
|
double max = 0;
|
||||||
|
for(int y = 0; y < xMat.rows-1; y++)
|
||||||
{
|
{
|
||||||
const float* colx = xMat.ptr<float>(y);
|
|
||||||
float max = 0;
|
|
||||||
for(int x = 0; x < xMat.cols-1; x++)
|
for(int x = 0; x < xMat.cols-1; x++)
|
||||||
{
|
{
|
||||||
float strech = std::abs(colx[x]-colx[x+1]);
|
cv::Point2f pA(xMat.at<float>(y,x), yMat.at<float>(y,x));
|
||||||
if(strech > max)
|
cv::Point2f pB(xMat.at<float>(y,x+1), yMat.at<float>(y,x+1));
|
||||||
max = strech;
|
cv::Point2f pC(xMat.at<float>(y+1,x), yMat.at<float>(y+1,x));
|
||||||
}
|
double normX = cv::norm(pA-pB);
|
||||||
if(y == 0)
|
double normY = cv::norm(pA-pC);
|
||||||
Log(Log::DEBUG)<<"AngleX on x";
|
|
||||||
for(int x = 0; x < xMat.cols-1; x++)
|
if(normX > max)
|
||||||
{
|
max = normX;
|
||||||
xStrech.at<float>(y,x) = 1-std::abs(colx[x]-colx[x+1])/max;
|
if(normY > max)
|
||||||
if(y == 0)
|
max = normY;
|
||||||
Log(Log::DEBUG)<<xStrech.at<float>(y,x);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int x = 0; x < yMat.cols; x++)
|
for(int y = 0; y < xMat.rows-1; y++)
|
||||||
{
|
{
|
||||||
float max = 0;
|
for(int x = 0; x < xMat.cols-1; x++)
|
||||||
for(int y = 0; y < yMat.rows-1; y++)
|
|
||||||
{
|
{
|
||||||
float strech = yMat.at<float>(y,x) - yMat.at<float>(y+1,x);
|
cv::Point2f pA(xMat.at<float>(y,x), yMat.at<float>(y,x));
|
||||||
if(strech > max)
|
cv::Point2f pB(xMat.at<float>(y,x+1), yMat.at<float>(y,x+1));
|
||||||
max = strech;
|
cv::Point2f pC(xMat.at<float>(y+1,x), yMat.at<float>(y+1,x));
|
||||||
|
double normX = cv::norm(pA-pB);
|
||||||
|
double normY = cv::norm(pA-pC);
|
||||||
|
|
||||||
|
greatestAngle.at<float>(y,x) = 1-(std::min(normX, normY)/max);
|
||||||
|
|
||||||
|
if(y == 0)
|
||||||
|
Log(Log::DEBUG)<<greatestAngle.at<float>(y,x);
|
||||||
}
|
}
|
||||||
for(int y = 0; y < yMat.rows-1; y++)
|
|
||||||
yStrech.at<float>(y,x) = 1-std::abs(yMat.at<float>(y,x) - yMat.at<float>(y+1,x))/max;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -223,13 +225,10 @@ RemapedImage applyRemap(const cv::Mat& image, const RemapMap &map)
|
|||||||
cv::Rect noBorderRoi(map.outputCellSize/2, map.outputCellSize/2,
|
cv::Rect noBorderRoi(map.outputCellSize/2, map.outputCellSize/2,
|
||||||
outputSize.width-map.outputCellSize, outputSize.height-map.outputCellSize);
|
outputSize.width-map.outputCellSize, outputSize.height-map.outputCellSize);
|
||||||
|
|
||||||
generateAngleMats(map.xMat, map.yMat, out.angleX, out.angleY);
|
generateAngleMats(map.xMat, map.yMat, out.angle);
|
||||||
cv::Mat angleXResized;
|
cv::Mat angleResized;
|
||||||
cv::Mat angleYResized;
|
cv::resize(out.angle, angleResized, outputSize, cv::INTER_LINEAR);
|
||||||
cv::resize(out.angleX, angleXResized, outputSize, cv::INTER_LINEAR);
|
out.angle = angleResized(noBorderRoi);
|
||||||
cv::resize(out.angleY, angleYResized, outputSize, cv::INTER_LINEAR);
|
|
||||||
out.angleX = angleXResized(noBorderRoi);
|
|
||||||
out.angleY = angleYResized(noBorderRoi);
|
|
||||||
|
|
||||||
cv::resize(map.xMat, xMapResized, outputSize, cv::INTER_LINEAR);
|
cv::resize(map.xMat, xMapResized, outputSize, cv::INTER_LINEAR);
|
||||||
cv::resize(map.yMat, yMapResized, outputSize, cv::INTER_LINEAR);
|
cv::resize(map.yMat, yMapResized, outputSize, cv::INTER_LINEAR);
|
||||||
|
@ -25,8 +25,7 @@
|
|||||||
struct RemapedImage
|
struct RemapedImage
|
||||||
{
|
{
|
||||||
cv::Mat image;
|
cv::Mat image;
|
||||||
cv::Mat angleX;
|
cv::Mat angle;
|
||||||
cv::Mat angleY;
|
|
||||||
cv::Point2i origin;
|
cv::Point2i origin;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user