expected unqualified-id before ‘-’ token [closed]

asked 2016-03-27 12:57:16 -0600

tinted gravatar image

updated 2016-03-27 13:17:35 -0600

I am trying to write a basic program for image processing and i am stuck at defining the kernel, i am getting the above error and i dont know what i am doing wrong. i tried to search and did not find anything and i am little new to both c++ and opencv

the error pops up from the second "c" in kernel i defined and also i tried using array like

int i,j;
for( i=0; i<3; ++i){
    for( j=0; j<3; ++j){
    kernel[i][j] = -1*c;
    }
}
kernel[2][2] = 8*c+1;

then also i am getting

expected unqualified-id before ‘for’ token

'i' does not have a type

expected unqualified-id before '++’ token

the code i have wrote is

#include "opencv2/core/core.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "iostream"

using namespace cv;
using namespace std;


int c = 1;
int *c_Address = &c;
int initialsharp = 1;
Mat kernel = Mat_<double>(3,3) << -c, -c, -c, -c, 8*c+1, -c, -c, -c, -c ;

void trackbarPosSharp(int pos, void *y)
{
*c_Address = pos;
Mat src = imread( "blurry_moon.tif", CV_LOAD_IMAGE_GRAYSCALE );
Mat dst = Mat::zeros( src.size(), src.type() );
filter2D(src, dst, -1, kernel);
imshow("Output", dst);
 }

 int main( )
 {
Mat src = imread( "blurry_moon.tif", CV_LOAD_IMAGE_GRAYSCALE );

//equalizeHist( channel[0], channel[0] );

namedWindow( "Original image", CV_WINDOW_AUTOSIZE );
imshow( "Original image", src );
src.release();

namedWindow("Output", CV_WINDOW_AUTOSIZE);
createTrackbar("Shrapening level ","Output", &initialsharp, 10, trackbarPosSharp);
trackbarPosSharp(1, 0);
waitKey(0);
return 0;
}
edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by sturkmen
close date 2020-10-04 02:54:12.419803

Comments

1

Try with:

Mat kernel = (Mat_<double>(3,3) << -c, -c, -c, -c, 8*c+1, -c, -c, -c, -c);
Eduardo gravatar imageEduardo ( 2016-03-27 13:12:31 -0600 )edit

that worked like a charm, thanks and also small doubt i have edited the question a little and added a little code and the errors so can you look into that once thanks again

tinted gravatar imagetinted ( 2016-03-27 13:23:12 -0600 )edit