Quick C question
Josh ChaitinPollak
josh at offthehill.org
Wed Nov 16 11:25:29 EST 2005
Don't use multidimensional arrays for image processing. You'll take
huge speed hits and the compiler won't be able to optimize. Allocate
a single dimensional N*M array and do the math to get to the pixels
you need. You'll find it much easier to deal with in the long run.
Not to mention for loops to deallocate the sub-arrays will get very
old, very quickly.
Remember, C isn't Matlab.
-Josh
On Nov 16, 2005, at 10:54 AM, Anthony Gabrielson wrote:
> Thanks - That worked like a champ :).
>
> Anthony
>
> On Wed, 16 Nov 2005, Seth Gordon wrote:
>
>> Ooh! Ooh! Ooh! Mr. Kotter!
>>
>>> #include <stdio.h>
>>>
>>> #define D1 4
>>> #define D2 2
>>>
>>> int main(){
>>>
>>> int *array;
>>
>> Here you're defining "array" as a pointer to an int.
>>
>>>
>>> array = malloc(sizeof(int) * (D1 * D2));
>>>
>>> array[1][1] = 32;
>>
>> Here you're using "array" as a pointer *to a pointer* to an int.
>>
>>>
>>> printf("Elem[1][1] = %d\n",array[1][1]);
>>>
>>> free(array);
>>>
>>> return 0;
>>> }
>>
>> Try changing "int *array" to "int **array".
>> _______________________________________________
>> Discuss mailing list
>> Discuss at blu.org
>> http://olduvai.blu.org/mailman/listinfo/discuss
>>
> _______________________________________________
> Discuss mailing list
> Discuss at blu.org
> http://olduvai.blu.org/mailman/listinfo/discuss
More information about the Discuss
mailing list