Когда я запускаю следующую программу с scalefactory выше 1,5, программа выдает EXC_BAD_ACCESS. Программа масштабирует изображение.Доступ к матрице OpenCV создает EXC_BAD_ACCESS
#include <iostream>
#include <OpenCV/cv.h>
#include <OpenCV/highgui.h>
#include <cmath>
using namespace std;
using namespace cv;
int scale (int xyvalue, float scalefactor) {
return ceil(xyvalue/scalefactor);
}
int main() {
Mat input;
float scalefactorx = 1.5;
float scalefactory = 1.5;
Mat output;
input = imread("/tmp/plum_grey_scale_MC_.low.jpg", 0);
output = cvCreateMat(input.size().height*scalefactory, input.size().width*scalefactorx, input.type());
for (int y = 0; y<output.size().height; y++)
{
for (int x = 0; x<output.size().width; x++)
{
output.data[y*output.size().width+x] = input.data[scale(y,scalefactory)*input.size().width + scale(x,scalefactorx)];
}
}
namedWindow("pic1", CV_WINDOW_AUTOSIZE);
imshow("pic1", output);
cvWaitKey(0);
cvDestroyWindow("BlomsterBillede");
return 0;
}
Если, например, Я установил scalefactorx = 5, scalefactory = 2, он оборвался вокруг x = 1356 и y = 409.
Надеюсь, вы можете мне помочь.
+1: привилегии читаемость, всегда :) –
Эй, Том, Он «работает», когда я использую свой метод, но каждый 2. строки пикселей выходного изображения отсутствует. – spangs