【发布时间】:2018-10-14 23:09:59
【问题描述】:
我有一个图像处理程序(canny-edge-detection),这里是其中一部分代码:
short int **magnitude;
int rows=320, cols=240;
//Allocate memory to store the image, warning if not successful
if((*magnitude = (short *) calloc(rows*cols, sizeof(short))) == NULL){
//some warning
}
我想使用一个数组来避免动态分配内存,因为它在我即将运行代码的系统上是不可行的。在这种情况下,数组的大小是多少?我以为
short int magnitude_arr[76800]
但是输出图像被切成两半。
【问题讨论】:
-
这里唯一可以确定的就是数组的大小肯定是76800,或者
rows*cols。 -
short int magnitude_arr[320*240];是正确的,也许你在程序的其他地方犯了错误
标签: c++ canny-operator