<html dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style id="owaParaStyle" type="text/css">P {margin-top:0;margin-bottom:0;}</style>
</head>
<body ocsi="0" fpstyle="1">
<div style="direction: ltr;font-family: Tahoma;color: #000000;font-size: 10pt;">Hi all,<br>
<br>
There definitely seems to be a problem with ITK-4.6, at least with the code that got installed while building Slicer. This was carried out with ITKV3_COMPATIBILITY off. I am doing some testing with this installation to try to understand why Slicer cannot
handle big tiffs (on my Windows 7 system).<br>
<br>
There is something a bit funny about the installed ITK-4.6, in that the compiler complained about some missing include files, vnl_*.h and others, which are in my ITK-4.0 installation but not in 4.6. I just copied them across - I hope this is not a problem.<br>
<br>
Anyway, I now find that my very simple program that uses ITK to create a tiff file now crashes when built with 4.6. What is a big clue is that it fails while creating the image, i.e. writing to the buffer, on page 73 - it's surely more than a coincidence that
Slicer fails when reading page 72 of a 4 GB tiff. In this case only 73 bytes have been written to buffer when it fails. The whole program is below. It fails having written x=0, y=0, z=0...73 to the console.<br>
<br>
Unless my code (which was fine with 4.0) is no longer OK with 4.6, this is a very basic bug, since all I do is set the image size, allocate memory, get a pointer to the buffer and start writing to it.<br>
<br>
The program is short enough to paste in its entirety, but the relevant section is just a few lines.<br>
<br>
#include <cstdio><br>
#include <vector><br>
<br>
#include <algorithm><br>
#include <math.h><br>
#include <string.h><br>
#include <string><br>
#include <sstream><br>
#include <assert.h><br>
#include <ctime><br>
<br>
#include "itkImage.h"<br>
#include "itkImageFileReader.h"<br>
#include "itkImageFileWriter.h"<br>
#include "itkSize.h"<br>
<br>
typedef itk::Image<unsigned char,3> ImageType;<br>
ImageType::Pointer im;<br>
unsigned char *p;<br>
<br>
#define V(a,b,c) p[(c)*xysize+(b)*width+(a)]<br>
<br>
int main(int argc, char**argv)<br>
{<br>
int x1, x2, y1, y2, z1, z2;<br>
int x0, y0, z0, dx, dy, dz;<br>
int x, y, z, xx, yy, zz, n, comp_flag;<br>
long long width, height, depth, xysize;<br>
int R, R2;<br>
bool use_compression;<br>
bool use_sphere = false;<br>
<br>
if (argc != 4) {<br>
printf("Usage: makebig tiff_file N compress\n");<br>
printf(" the image will be NxNxN\n");<br>
printf(" set compress=1 to use compression, =0 otherwise\n");<br>
return 1;<br>
}<br>
<br>
printf("Output image file: %s\n",argv[1]);<br>
sscanf(argv[2],"%d",&n);<br>
sscanf(argv[3],"%d",&comp_flag);<br>
use_compression = (comp_flag == 1);<br>
x0 = n/2;<br>
y0 = n/2;<br>
z0 = n/2;<br>
R = 5;<br>
R2 = R*R;<br>
width = n;<br>
height = n;<br>
depth = n;<br>
xysize = width*height;<br>
printf("Desired image dimensions: width, height, depth: %d %d %d\n",width,height,depth);<br>
<br>
ImageType::Pointer im = ImageType::New();<br>
ImageType::SizeType imsize; <br>
imsize[0] = width;<br>
imsize[1] = height;<br>
imsize[2] = depth;<br>
ImageType::IndexType imstart; <br>
imstart[0] = 0;<br>
imstart[1] = 0;<br>
imstart[2] = 0;<br>
ImageType::RegionType imregion; <br>
imregion.SetSize(imsize);<br>
imregion.SetIndex(imstart);<br>
im->SetRegions(imregion);<br>
im->Allocate();<br>
p = (unsigned char *)(im->GetBufferPointer());<br>
<br>
width = im->GetLargestPossibleRegion().GetSize()[0];<br>
height = im->GetLargestPossibleRegion().GetSize()[1];<br>
depth = im->GetLargestPossibleRegion().GetSize()[2];<br>
printf("Requested image dimensions: width, height, depth: %d %d %d\n",width,height,depth);<br>
<br>
for (x=0; x<width; x++) {<br>
printf("x: %d\n",x);<br>
for (y=0; y<height; y++) {<br>
printf("y: %d\n",y);<br>
for (z=0; z<depth; z++) {<br>
printf("z: %d\n",z);<br>
if (use_sphere) {<br>
dx = x - x0;<br>
dy = y - y0;<br>
dz = z - z0;<br>
if (dx*dx+dy*dy+dz*dz <= R2) {<br>
V(x,y,z) = 255;<br>
} else {<br>
V(x,y,z) = 0;<br>
}<br>
} else {<br>
if (x < x0-R || x > x0+R) {<br>
V(x,y,z) = 0;<br>
} else {<br>
V(x,y,z) = 255;<br>
}<br>
}<br>
}<br>
}<br>
}<br>
<br>
typedef itk::ImageFileWriter<ImageType> FileWriterType;<br>
FileWriterType::Pointer writer = FileWriterType::New();<br>
writer->SetFileName(argv[1]);<br>
writer->SetInput(im);<br>
if (use_compression) {<br>
writer->UseCompressionOn();<br>
}<br>
printf("Writing tiff file\n");<br>
try<br>
{<br>
writer->Update();<br>
}<br>
catch (itk::ExceptionObject &e)<br>
{<br>
std::cout << e << std::endl;<br>
return 4;<br>
}<br>
if (use_compression) {<br>
printf("Created compressed image file: %s\n",argv[1]);<br>
} else {<br>
printf("Created uncompressed image file: %s\n",argv[1]);<br>
}<br>
<br>
return 0;<br>
}<br>
<br>
</div>
</body>
</html>