Ask Your Question

tinted's profile - activity

2016-07-14 09:57:12 -0600 answered a question libopencv_core.so.3.0.0: undefined reference to ippiCopy_32s_C4MR

tried with opencv 3.1 as well and same error

https://github.com/opencv/opencv/issu...

2016-03-27 14:16:55 -0600 commented question kernel is not defined in this scope?

ok, i just figured that i am not returning the matrix which i dont know how to do it or how can i create pointer to matrix, i mean i dont know if it is just like other variables or not. i will post again if i find anything

2016-03-27 14:04:21 -0600 asked a question kernel is not defined in this scope?

i am trying to write a code which does image sharpening and i was able to run the program and get the output with

** kernel [-c, -c, -c, -c, 8c+1, -c, -c, -c, -c]

but now i am trying to change the kernel with a trackbar and am getting an error that kernel is not defined in this scope

the code i am working is

i know that this is a lot of code to go but what you need to see is the trackbar declaration and the modeselection trackbar funtion thats all

#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 mode = 0;
int *mode_Address = &mode;
int *c_Address = &c;
int initialsharp = 0;

void modeSelection(int mode)
{
if(mode == 0){
    Mat kernel = (Mat_<double>(3,3) << -c, -c, -c, -c, 8*c+1, -c, -c, -c, -c);
}
else if(mode == 1){
    Mat kernel = (Mat_<double>(3,3) << 0, 0, 0, -c, 2*c+1, -c, 0, 0, 0);
}
else if(mode == 2){
    Mat kernel = (Mat_<double>(3,3) << 0, -c, 0, 0, 2*c+1, 0, 0, -c, 0);
}
else if(mode == 3){
    Mat kernel = (Mat_<double>(3,3) << 0, -c, 0, -c, 4*c+1, -c, 0, -c, 0);
}
else if(mode == 4){
    Mat kernel = (Mat_<double>(3,3) << -c, 0, 0, 0, 2*c+1, 0, 0, 0, -c);
}
else if(mode == 5){
    Mat kernel = (Mat_<double>(3,3) << 0, 0, 0, -c, 2*c+1, 0, -c, 0, 0);
}
else if(mode == 6){
    Mat kernel = (Mat_<double>(3,3) << -c, 0, -c, 0, 4*c+1, 0, -c, 0, -c);
}
}

void trackbarPosMode(int pos, void*y)
{
*mode_Address = pos;
modeSelection(mode);
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);
}

void trackbarPosSharp(int pos, void *y)
{

*c_Address = pos ;
modeSelection(mode);
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 );
namedWindow( "Original image", CV_WINDOW_AUTOSIZE );
imshow( "Original image", src );
src.release();

namedWindow("Output", CV_WINDOW_AUTOSIZE);
createTrackbar("Shrapening level ","Output", &initialsharp, 20, trackbarPosSharp);
createTrackbar("0:all 1:horizontal 2:vertical 3:Ver&Hor 4:left_diagonal 5:right_diagonal 6:both_Diag","Output", &initialsharp, 6, trackbarPosMode);
trackbarPosSharp(0, 0);
trackbarPosMode(0, 0);
waitKey(0);
return 0;
}
2016-03-27 13:23:12 -0600 commented question expected unqualified-id before ‘-’ token

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

2016-03-27 13:17:35 -0600 received badge  Editor (source)
2016-03-27 13:00:33 -0600 asked a question expected unqualified-id before ‘-’ token

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;
}