I have the following pice of code to load a sequence of images in a folder :
Code: Select all
for( k=0; k<sz; k++ )
{
fscanf(fp, "%s", buffer);
sprintf(image_info->filename, "%s/%s", path, buffer);
printf("image read %s\n", image_info->filename);
image = ReadImage(image_info,exception);
if( image == (Image*)NULL )
err_msg(3, "volume3D - unable to read image");
if( k == 0 )
{
vol = new_volume3D(image->columns, image->rows, sz);
vol->resolution[0] = resolution[0];
vol->resolution[1] = resolution[1];
vol->resolution[2] = resolution[2];
if( (prefix = prefix_string(filename)) != NULL )
{
set_name_volume3D(&vol, prefix);
free(prefix), prefix=(NULL);
}
}
p = AcquireImagePixels(image, 0, 0, image->columns, image->rows, exception);
/* pour lire le noir */
indexes = GetIndexes(image);
if( indexes != NULL )
{
for( i=0, index=(k*vol->sx*vol->sy); i<(vol->sx*vol->sy); i++, index++ )
vol->values[index] = (float)indexes[i];
}
image = DestroyImage(image);
}