+
+ GDCM_NAME_SPACE::FileHelper *fh = GDCM_NAME_SPACE::FileHelper::New(f);
+ void *imageData;
+ int dataSize;
+
+
+ // =======================================================================
+ int subImDimX = nX;
+ int subImDimY = nY;
+
+
+ if (roi)
+ {
+ std::cout << " " << boundRoiVal[0] << " " << boundRoiVal[1] << " " << boundRoiVal[2] << " " <<
+ boundRoiVal[3] <<std::endl;
+ if (boundRoiVal[0]<0 || boundRoiVal[0]>=nX)
+ {
+ std::cout << "xBegin out of bounds; 'roi' ignored" << std::endl;
+ fail = true;
+ }
+ if (boundRoiVal[1]<0 || boundRoiVal[1]>=nX)
+ {
+ std::cout << "xEnd out of bounds; 'roi' ignored" << std::endl;
+ fail = true;
+ }
+ if (boundRoiVal[0] > boundRoiVal[1])
+ {
+ std::cout << "xBegin greater than xEnd; 'roi' ignored" << std::endl;
+ fail = true;
+ }
+
+ if (boundRoiVal[2]<0 || boundRoiVal[2]>=nY)
+ {
+ std::cout << "yBegin out of bounds; 'roi' ignored" << std::endl;
+ fail = true;
+ }
+ if (boundRoiVal[3]<0 || boundRoiVal[3]>=nY)
+ {
+ std::cout << "yEnd out of bounds; 'roi' ignored" << std::endl;
+ fail = true;
+ }
+ if (boundRoiVal[2] > boundRoiVal[3])
+ {
+ std::cout << "yBegin greater than yEnd; 'roi' ignored" << std::endl;
+ fail = true;
+ }
+
+ }
+ else
+ {
+
+ boundRoiVal = new int[4];
+ boundRoiVal[0] = 0;
+ boundRoiVal[1] = nX-1;
+ boundRoiVal[2] = 0;
+ boundRoiVal[3] = nY-1;
+ }
+
+ subImDimX = boundRoiVal[1]-boundRoiVal[0]+1;
+ subImDimY = boundRoiVal[3]-boundRoiVal[2]+1;
+
+ // =======================================================================
+ if (rgb)
+ {
+ dataSize = fh->GetImageDataSize();
+ imageData = fh->GetImageData(); // somewhat important... can't remember
+ fh->SetWriteModeToRGB();
+ }
+ else
+ {
+ dataSize = fh->GetImageDataRawSize();
+ imageData = fh->GetImageDataRaw();// somewhat important... can't remember
+ fh->SetWriteModeToRaw();
+ }
+
+ if ( imageData == 0 ) // to avoid warning
+ {
+ std::cout << "Was unable to read pixels " << std::endl;
+ }
+
+