Problem in OpenCV
Jul 7, 2011 at 11:54pm
Hi,
I'm Hatem Faheem
An Egyptian student in Computer Engineering, Cairo university
I have a small problem in implementing a code that sharpen an image
here is the code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
void Sharpen(const cv::Mat& myImage,cv::Mat& Result)
{
Result.create(myImage.size(),myImage.type());
for(int j=1;j<myImage.rows-1;j++)
{
const uchar* previous = myImage.ptr<uchar>(j-1);
const uchar* current = myImage.ptr<uchar>(j);
const uchar* next = myImage.ptr<uchar>(j+1);
uchar* output = Result.ptr<uchar>(j);
for(int i=1;i<myImage.cols-1;i++)
{
*output++ = cv::saturate_cast<uchar>(5*current[i]-current[i-1]-previous[i]-next[i]);
}
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));
}
}
|
when I apply this function to a gray-level image just abput 20% of it appears on the left the rest of the image is disappeared
here's an image shows the original image and the output image
http://www.imageupload.org/?d=1A0AC61F1
Thank You,
Last edited on Jul 7, 2011 at 11:55pm
Topic archived. No new replies allowed.