Ask Your Question
0

Light up Edges of a distorted Picture like gimp

asked 2013-09-11 07:04:47 -0600

Hello,

I photograph an paper from a distance of 280mm with a 5Mpix b/w cam and a 4,2mm Lens. The Undistortion after the Calibration works great but the edges of the picture must be lighten up, because they are too dark.

After the image correction is done a ocr software shoud read the Text. In Gimp i have an option to light up the edges but i cant use gimp because it is too slow.

Can I use the cameraMatrix and distCoeffs to do this?

Thank for your Help

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2013-09-11 16:24:27 -0600

You can sharpen the image edge with the below code.

void sharpen(const cv::Mat &image, cv::Mat &result) {
// allocate if necessary
result.create(image.size(), image.type());
for (int j= 1; j<image.rows-1; j++) { // for all rows
// (except first and last)
const uchar* previous=
image.ptr<const uchar>(j-1); // previous row
const uchar* current=
image.ptr<const uchar>(j); // current row
const uchar* next=
image.ptr<const uchar>(j+1); // next row
uchar* output= result.ptr<uchar>(j); // output row
for (int i=1; i<image.cols-1; i++) {
*output++= cv::saturate_cast<uchar>(
5*current[i]-current[i-1]
-current[i+1]-previous[i]-next[i]);
}
}
// Set the unprocess pixels to 0
result.row(0).setTo(cv::Scalar(0));
result.row(result.rows-1).setTo(cv::Scalar(0));
result.col(0).setTo(cv::Scalar(0));
result.col(result.cols-1).setTo(cv::Scalar(0));
}
edit flag offensive delete link more

Question Tools

Stats

Asked: 2013-09-11 07:04:47 -0600

Seen: 336 times

Last updated: Sep 11 '13