Page 1 of 1

Tiff format

Posted: 2010-04-19T08:46:42-07:00
by nicolas66
Hi there!

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);

	}
This works well except for TIFF images which are all black. ImageMagick was compiled with libTIFF. The variable "indexes" containing grayscale values is NULL. So, is there a specific way to load TIFF images or not?

Re: Tiff format

Posted: 2010-04-19T09:00:03-07:00
by magick
Its possible the image is stored as a truecolor image which means the grayscale values are here: p.red;