Hi everyone,
Are there any ways in c++ I can access Mat structure like colone in Matlab.
in Matlab
image(i,j-one_count:j-1)=0;
how can I write the same thing in C++?
Thank
1 | initial version |
Hi everyone,
Are there any ways in c++ I can access Mat structure like colone in Matlab.
in Matlab
image(i,j-one_count:j-1)=0;
how can I write the same thing in C++?
Thank
2 | No.2 Revision |
Hi everyone,
Are there any ways in c++ I can access Mat structure like colone colon in Matlab.
in Matlab
image(i,j-one_count:j-1)=0;
how can I write the same thing in C++?
Thank
3 | retagged |
Hi everyone,
Are there any ways in c++ I can access Mat structure like colon in Matlab.
in Matlab
image(i,j-one_count:j-1)=0;
how can I write the same thing in C++?
Thank
4 | No.4 Revision |
Hi everyone,
Are there any ways in c++ I can access Mat structure like colon in Matlab.
in Matlab
image(i,j-one_count:j-1)=0;
how can I write the same thing in C++?
EDIT The whole code
int hor_thres = 22;
int one_count = 0;
int zero_flag = 0;
Mat tmpImg = Mat(Img.size(), CV_8UC1, Scalar(0, 0, 0));
for (int i = 0; i<Img.rows; i++){
for (int j = 0; j<Img.cols; i++){
if (Img.at<uchar>(j, i) == 0)
{
if (zero_flag == 1)
{
if (one_count <= hor_thres)
{
tmpImg(cv::Range(i, i + 1), cv::Range(j - one_count, j - 1)).setTo(cv::Scalar::all(0));
}
else
{
zero_flag = 1;
}
one_count = 0;
}
zero_flag = 1;
}
else
{
if (zero_flag == 1)
{
one_count = one_count + 1;
}
}
}
}
I got this error
Unhandled exception at 0x000007FEFCDF940D in ConsoleApplication1.exe: Microsoft C++ exception: cv::Exception at memory location 0x00000000001DD490.
Anyidea???
Thank
5 | No.5 Revision |
Hi everyone,
Are there any ways in c++ I can access Mat structure like colon in Matlab.
in Matlab
image(i,j-one_count:j-1)=0;
how can I write the same thing in C++?
EDIT The whole code
int hor_thres = 22;
int one_count = 0;
int zero_flag = 0;
Mat tmpImg = Mat(Img.size(), CV_8UC1, Scalar(0, 0, 0));
for (int i = 0; i<Img.rows; i++){
for (int j = 0; j<Img.cols; i++){
j++){
if (Img.at<uchar>(j, i) == 0)
{
if (zero_flag == 1)
{
if (one_count <= hor_thres)
{
tmpImg(cv::Range(i, i + 1), cv::Range(j - one_count, j - 1)).setTo(cv::Scalar::all(0));
1)).setTo(cv::Scalar::all(0));
// I want to do the same thing in Matlab as this image(i,j-one_count:j-1)=0;
}
else
{
zero_flag = 1;
}
one_count = 0;
}
zero_flag = 1;
}
else
{
if (zero_flag == 1)
{
one_count = one_count + 1;
}
}
}
}
I got this error
Unhandled exception at 0x000007FEFCDF940D in ConsoleApplication1.exe: Microsoft C++ exception: cv::Exception at memory location 0x00000000001DD490.
Anyidea???
Thank
6 | No.6 Revision |
Hi everyone,
Are there any ways in c++ I can access Mat structure like colon in Matlab.
in Matlab
image(i,j-one_count:j-1)=0;
how can I write the same thing in C++?
EDIT The whole code
int hor_thres = 22;
int one_count = 0;
int zero_flag = 0;
Mat tmpImg = Mat(Img.size(), CV_8UC1, Scalar(0, 0, 0));
for (int j = 0; j<Img.rows; j++){
for (int i = 0; i<Img.rows; i++){
for (int j = 0; j<Img.cols; i<Img.cols; j++){
if (Img.at<uchar>(j, i) == 0)
{
if (zero_flag == 1)
{
if (one_count <= hor_thres)
{
tmpImg(cv::Range(i, i + 1), cv::Range(j - one_count, j - 1)).setTo(cv::Scalar::all(0));
// I want to do the same thing in Matlab as this image(i,j-one_count:j-1)=0;
}
else
{
zero_flag = 1;
}
one_count = 0;
}
zero_flag = 1;
}
else
{
if (zero_flag == 1)
{
one_count = one_count + 1;
}
}
}
}
I got this error
Unhandled exception at 0x000007FEFCDF940D in ConsoleApplication1.exe: Microsoft C++ exception: cv::Exception at memory location 0x00000000001DD490.
Anyidea???
Thank
7 | No.7 Revision |
Hi everyone,
Are there any ways in c++ I can access Mat structure like colon in Matlab.
in Matlab
image(i,j-one_count:j-1)=0;
how can I write the same thing in C++?
EDIT
According to Running length smoothing algorithm The whole code
MatLabCode
for i=1:m
for j=1:n
if(tmpImg(i,j)==1)
if(zero_flag==1)
if(one_count<=hor_thresh)
tmpImg(i,j-one_count:j-1)=1;
else
zero_flag=1;
end
one_count=0;
end
zero_flag=1;
else
if(zero_flag==1)
one_count=one_count+1;
end
end
end
end
I tried to implement in C++ Code
int hor_thres = 22;
int one_count = 0;
int zero_flag = 0;
Mat tmpImg = Mat(Img.size(), CV_8UC1, Scalar(0, 0, 0));
for (int j = 0; j<Img.rows; j++){
for (int i = 0; i<Img.cols; j++){
if (Img.at<uchar>(j, i) == 0)
{
if (zero_flag == 1)
{
if (one_count <= hor_thres)
{
tmpImg(cv::Range(i, i + 1), cv::Range(j tmpText(cv::Range(j - one_count, j - 1)).setTo(cv::Scalar::all(0));
zero_count, j), cv::Range(i, i+1)).setTo(cv::Scalar::all(255));
// I want to do the same thing in Matlab as this image(i,j-one_count:j-1)=0;
}
else
{
zero_flag = 1;
}
one_count = 0;
}
zero_flag = 1;
}
else
{
if (zero_flag == 1)
{
one_count = one_count + 1;
}
}
}
}
I got this This time no error but the result is not expected ..
The issue is the way i want to write c++ code the same thing as
Matlab
Unhandled exception at 0x000007FEFCDF940D in ConsoleApplication1.exe: Microsoft C++ exception: cv::Exception at memory location 0x00000000001DD490.
tmpImg(i,j-one_count:j-1)=0;
C++
tmpText(cv::Range(j - zero_count, j), cv::Range(i, i+1)).setTo(cv::Scalar::all(255));
Anyidea???
Thank
8 | retagged |
Hi everyone,
Are there any ways in c++ I can access Mat structure like colon in Matlab.
in Matlab
image(i,j-one_count:j-1)=0;
how can I write the same thing in C++?
EDIT
According to Running length smoothing algorithm The whole code
MatLabCode
for i=1:m
for j=1:n
if(tmpImg(i,j)==1)
if(zero_flag==1)
if(one_count<=hor_thresh)
tmpImg(i,j-one_count:j-1)=1;
else
zero_flag=1;
end
one_count=0;
end
zero_flag=1;
else
if(zero_flag==1)
one_count=one_count+1;
end
end
end
end
I tried to implement in C++ Code
int hor_thres = 22;
int one_count = 0;
int zero_flag = 0;
Mat tmpImg = Mat(Img.size(), CV_8UC1, Scalar(0, 0, 0));
for (int j = 0; j<Img.rows; j++){
for (int i = 0; i<Img.cols; j++){
if (Img.at<uchar>(j, i) == 0)
{
if (zero_flag == 1)
{
if (one_count <= hor_thres)
{
tmpText(cv::Range(j - zero_count, j), cv::Range(i, i+1)).setTo(cv::Scalar::all(255));
// I want to do the same thing in Matlab as this image(i,j-one_count:j-1)=0;
}
else
{
zero_flag = 1;
}
one_count = 0;
}
zero_flag = 1;
}
else
{
if (zero_flag == 1)
{
one_count = one_count + 1;
}
}
}
}
This time no error but the result is not expected ..
The issue is the way i want to write c++ code the same thing as
Matlab
tmpImg(i,j-one_count:j-1)=0;
C++
tmpText(cv::Range(j - zero_count, j), cv::Range(i, i+1)).setTo(cv::Scalar::all(255));
Anyidea???
Thank
9 | No.9 Revision |
Hi everyone,
Are there any ways in c++ I can access Mat structure like colon in Matlab.
in Matlab
image(i,j-one_count:j-1)=0;
how can I write the same thing in C++?
EDIT
According to Running length smoothing algorithm The whole code
MatLabCode
hor_thresh=20;
zeros_count=0;
one_flag=0;
hor_image=image;
for i=1:m
i=1:m
for j=1:n
if(tmpImg(i,j)==1)
if(zero_flag==1)
if(one_count<=hor_thresh)
tmpImg(i,j-one_count:j-1)=1;
j=1:n
if(image(i,j)==1)
if(one_flag==1)
if(zeros_count<=hor_thresh)
hor_image(i,j-zeros_count:j-1)=1;
else
zero_flag=1;
one_flag=0;
end
one_count=0;
zeros_count=0;
end
zero_flag=1;
else
if(zero_flag==1)
one_count=one_count+1;
one_flag=1;
else
if(one_flag==1)
zeros_count=zeros_count+1;
end
end
end
end
I tried to implement in C++ Code
int hor_thres = 22;
int one_count = 0;
int zero_flag = 0;
Mat tmpImg = Mat(Img.size(), CV_8UC1, Scalar(0, 0, 0));
for (int j = 0; j<Img.rows; j++){
for (int i = 0; i<Img.cols; j++){
if (Img.at<uchar>(j, i) == 0)
{
if (zero_flag == 1)
{
if (one_count <= hor_thres)
{
tmpText(cv::Range(j - zero_count, j), cv::Range(i, i+1)).setTo(cv::Scalar::all(255));
// I want to do the same thing in Matlab as this image(i,j-one_count:j-1)=0;
}
else
{
zero_flag = 1;
}
one_count = 0;
}
zero_flag = 1;
}
else
{
if (zero_flag == 1)
{
one_count = one_count + 1;
}
}
}
}
This time no error but the result is not expected ..
The issue is the way i want to write c++ code the same thing as
Matlab
tmpImg(i,j-one_count:j-1)=0;
C++
tmpText(cv::Range(j - zero_count, j), cv::Range(i, i+1)).setTo(cv::Scalar::all(255));
Anyidea???
Thank