Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

copy half image

Hello All.

I have an image:

MAt gray which the size is 480*640 and its 1 channel and I need to copy the half images:

Mat edges1 (480/2, 640/2, CV_8U); Mat edges2 (480/2,640/2, CV_8U);

for(int i=0;i<480;i++) { for(int j=0;j<640/2;j++) {

edges1.at<uchar>(i,j)=gray.at<uchar>(i,j);

} }

for(int i=0;i<480;i++) { for(int j=640/2;j<640;j++) {

edges2.at<uchar>(i,j)=gray.at<uchar>(i,j);

} } imwrite("bordes1.png", edges1,compression_params); imwrite("bordes2.png", edges2,compression_params); return 1; }

But I got Segmentation fault. What can it be?

copy half image

Hello All.

I have an image:

MAt gray which the size is 480*640 and its 1 channel and I need to copy the half images:

Mat edges1 (480/2, (480, 640/2, CV_8U); Mat edges2 (480/2,640/2, (480,640/2, CV_8U);

for(int i=0;i<480;i++) { for(int j=0;j<640/2;j++) {

edges1.at<uchar>(i,j)=gray.at<uchar>(i,j);

} }

for(int i=0;i<480;i++) { for(int j=640/2;j<640;j++) {

edges2.at<uchar>(i,j)=gray.at<uchar>(i,j);

} } imwrite("bordes1.png", edges1,compression_params); imwrite("bordes2.png", edges2,compression_params); return 1; }

But I got Segmentation fault. What can it be?

copy half image

Hello All.

I have an image:

MAt gray which the size is 480*640 and its 1 channel and I need to copy the half images:

Mat edges1 (480, 640/2, CV_8U); Mat edges2 (480,640/2, CV_8U);

for(int i=0;i<480;i++) { for(int j=0;j<640/2;j++) {

edges1.at<uchar>(i,j)=gray.at<uchar>(i,j);

} }

for(int i=0;i<480;i++) { for(int j=640/2;j<640;j++) {

edges2.at<uchar>(i,j)=gray.at<uchar>(i,j);

} } imwrite("bordes1.png", edges1,compression_params); imwrite("bordes2.png", edges2,compression_params); return 1; }

But I got Segmentation fault. What can it be?