Exemple #1
0
            # if os.path.getsize(refineGridMosaic) == 0:
            #  print("Refine grid failed for {0}. Using fft mosaic {1} instead.".format(
            #    refineGridMosaic, fftOutputMosaic))
            #  refineGridMosaic = fftOutputMosaic
            refineGridMosaic = fftOutputMosaic

            assmblOutImg = "{0}/{1}{2}".format(testRoot, outputStem, outputImageExtension)
            ############################################
            # Assembling of images
            ############################################
            print("Assembling image...")
            print("   {0}".format(assmblOutImg))
            seg3d2.assemblefilter(
                layerid=layerid,
                input_mosaic=refineGridMosaic,
                output_image=assmblOutImg,
                directory=imageDir,
                shrink_factor=1,
            )
            imageDirList.append(imageDir)
            outputMosaicList.append(assmblOutImg)  # refineGridMosaic)
            sliceNums.append(index)
        except:
            e = sys.exc_info()[0]
            print("Error: {0}".format(e))
# sys.exit()
outputStosList = []

for i in range(len(sliceNums) - 1):
    index = sliceNums[i]
    nextIndex = sliceNums[i + 1]
    seg3d2.fftfilter(layerid=layerid,
                     shrink_factor=shrinkFactor,
                     overlap_min=overlapMin,
                     overlap_max=overlapMax,
                     pixel_spacing=pixelSpacing,
                     images=files,
                     directory=enhancedDir,
                     output_mosaic=fftMosaic,
                     iterations_per_level=pyramidIterations,
                     pyramid_levels=pyramidLevels)

    imageOutputFile = "{0}/{1}{2}".format(resultsDir, outputName,
                                          outputImageExtension)
    seg3d2.assemblefilter(layerid=layerid,
                          shrink_factor=shrinkFactor,
                          pixel_spacing=pixelSpacing,
                          input_mosaic=fftMosaic,
                          output_image=imageOutputFile,
                          directory=testRoot)

    files = []

for index in range(rangeMin, stosRangeMax):
    next_index = index + 1
    print('index={0}, next_index={1}'.format(index, next_index))
    outputName = "{0}_{1}".format(datasetName, index)
    nextOutputName = "{0}_{1}".format(datasetName, next_index)

    mosaicFixed = "{0}/{1}{2}".format(fftDir, outputName, mosaicExtension)
    if not os.path.isfile(mosaicFixed):
        break
    mosaicMoving = "{0}/{1}{2}".format(fftDir, nextOutputName, mosaicExtension)
    print(fftOutputMosaic)
    outputMosaicList.append(fftOutputMosaic)

    seg3d2.fftfilter(layerid=layerid,
                     directory=imageDir,
                     output_mosaic=fftOutputMosaic,
                     shrink_factor=shrinkFactor)

    assembleOutputImage = '{0}/results/{1}{2}'.format(testOutputRoot,
                                                      outputStem,
                                                      outputImageExtension)
    print(assembleOutputImage)

    seg3d2.assemblefilter(layerid=layerid,
                          input_mosaic=fftOutputMosaic,
                          output_image=assembleOutputImage,
                          directory=imageDir,
                          shrink_factor=shrinkFactor,
                          feathering="blend")

fixedIndex = 1
inputFixed = outputMosaicList[0]
print(inputFixed)
outputStosList = []

for index in range(firstIndex, lastIndex):
    nextIndex = index + 1
    inputMoving = outputMosaicList[index]
    print(inputMoving)
    outputStos = '{0}/stos/mv{1}{2}.stos'.format(testRoot2, fixedIndex,
                                                 nextIndex)
    print(outputStos)
    #iterations_per_level=pyramidIterations, pyramid_levels=pyramidLevels

    #refineGridMosaic="{0}/{1}{2}".format(refineGridDir, outputName, mosaicExtension)
    #seg3d2.refinegridfilter(layerid=layerid, shrink_factor=shrinkFactor, pixel_spacing=pixelSpacing, iterations=refineGridIterations, input_mosaic=fftMosaic, output_mosaic=refineGridMosaic, directory=testRoot, cell_size=cellSize)

    # in case refine grid failed:
    #if os.path.getsize(refineGridMosaic) == 0:
    #  print("Refine grid failed for {0}. Using fft mosaic {1} instead.".format(refineGridMosaic, fftMosaic))
    refineGridMosaic = fftMosaic

    imageOutputFile = "{0}/{1}{2}".format(resultsDir, outputName,
                                          outputImageExtension)
    seg3d2.assemblefilter(layerid=layerid,
                          shrink_factor=1,
                          pixel_spacing=pixelSpacing,
                          input_mosaic=refineGridMosaic,
                          output_image=imageOutputFile,
                          directory=testRoot,
                          feathering=blendEdges)

    files = []
#sys.exit()
for index in range(rangeMin, stosRangeMax):
    next_index = index + 1
    print('index={0}, next_index={1}'.format(index, next_index))
    outputName = "{0}_{1}".format(datasetName, index)
    nextOutputName = "{0}_{1}".format(datasetName, next_index)

    mosaicFixed = "{0}/{1}{2}".format(fftDir, outputName, mosaicExtension)
    if not os.path.isfile(mosaicFixed):
        break
    imageDir = "{0}/{1}".format(testRoot, index)
    imageDirList.append(imageDir)
    testOutputRoot = "{0}/test".format(imageDir)
    fftOutputMosaic = "{0}/fft/{1}.mosaic".format(testOutputRoot, outputStem)
    print(fftOutputMosaic)
    outputMosaicList.append(fftOutputMosaic)

    seg3d2.fftfilter(layerid=layerid, directory=imageDir, output_mosaic=fftOutputMosaic, shrink_factor=shrinkFactor)

    assembleOutputImage = "{0}/results/{1}{2}".format(testOutputRoot, outputStem, outputImageExtension)
    print(assembleOutputImage)

    seg3d2.assemblefilter(
        layerid=layerid,
        input_mosaic=fftOutputMosaic,
        output_image=assembleOutputImage,
        directory=imageDir,
        shrink_factor=shrinkFactor,
        feathering="blend",
    )

fixedIndex = 1
inputFixed = outputMosaicList[0]
print(inputFixed)
outputStosList = []

for index in range(firstIndex, lastIndex):
    nextIndex = index + 1
    inputMoving = outputMosaicList[index]
    print(inputMoving)
    outputStos = "{0}/stos/mv{1}{2}.stos".format(testRoot2, fixedIndex, nextIndex)
    print(outputStos)
    files.append(filename)

  print(files)

  for f in files:
    inputImage = "{0}/{1}".format(testRoot, f)
    outputImage = "{0}/{1}".format(enhancedDir, f)
    seg3d2.clahefilter(layerid=layerid, shrink_factor=claheShrinkFactor, input_image=inputImage, output_image=outputImage, window_x=window[0], window_y=window[1])

  outputName = "{0}_{1}".format(datasetName, index)

  fftMosaic = "{0}/{1}{2}".format(fftDir, outputName, mosaicExtension)
  seg3d2.fftfilter(layerid=layerid, shrink_factor=shrinkFactor, overlap_min=overlapMin, overlap_max=overlapMax, pixel_spacing=pixelSpacing, images=files, directory=enhancedDir, output_mosaic=fftMosaic, iterations_per_level=pyramidIterations, pyramid_levels=pyramidLevels)

  imageOutputFile = "{0}/{1}{2}".format(resultsDir, outputName, outputImageExtension)
  seg3d2.assemblefilter(layerid=layerid, shrink_factor=shrinkFactor, pixel_spacing=pixelSpacing, input_mosaic=fftMosaic, output_image=imageOutputFile, directory=testRoot) 

  files = []

for index in range(rangeMin, stosRangeMax):
  next_index = index + 1
  print('index={0}, next_index={1}'.format(index, next_index))
  outputName = "{0}_{1}".format(datasetName, index)
  nextOutputName = "{0}_{1}".format(datasetName, next_index)

  mosaicFixed = "{0}/{1}{2}".format(fftDir, outputName, mosaicExtension)
  if not os.path.isfile(mosaicFixed):
      break
  mosaicMoving = "{0}/{1}{2}".format(fftDir, nextOutputName, mosaicExtension)
  if not os.path.isfile(mosaicMoving):
      break
Exemple #7
0
            #if os.path.getsize(refineGridMosaic) == 0:
            #  print("Refine grid failed for {0}. Using fft mosaic {1} instead.".format(
            #    refineGridMosaic, fftOutputMosaic))
            #  refineGridMosaic = fftOutputMosaic
            refineGridMosaic = fftOutputMosaic

            assmblOutImg = '{0}/{1}{2}'.format(testRoot, outputStem,
                                               outputImageExtension)
            ############################################
            #Assembling of images
            ############################################
            print('Assembling image...')
            print("   {0}".format(assmblOutImg))
            seg3d2.assemblefilter(layerid=layerid,
                                  input_mosaic=refineGridMosaic,
                                  output_image=assmblOutImg,
                                  directory=imageDir,
                                  shrink_factor=1)
            imageDirList.append(imageDir)
            outputMosaicList.append(assmblOutImg)  #refineGridMosaic)
            sliceNums.append(index)
        except:
            e = sys.exc_info()[0]
            print("Error: {0}".format(e))
#sys.exit()
outputStosList = []

for i in range(len(sliceNums) - 1):
    index = sliceNums[i]
    nextIndex = sliceNums[i + 1]
    inputFixed = outputMosaicList[i]
                   images=files,
                   directory=testRoot,
                   output_mosaic=fftMosaic)
  #iterations_per_level=pyramidIterations, pyramid_levels=pyramidLevels

  #refineGridMosaic="{0}/{1}{2}".format(refineGridDir, outputName, mosaicExtension)
  #seg3d2.refinegridfilter(layerid=layerid, shrink_factor=shrinkFactor, pixel_spacing=pixelSpacing, iterations=refineGridIterations, input_mosaic=fftMosaic, output_mosaic=refineGridMosaic, directory=testRoot, cell_size=cellSize)


  # in case refine grid failed:
  #if os.path.getsize(refineGridMosaic) == 0:
  #  print("Refine grid failed for {0}. Using fft mosaic {1} instead.".format(refineGridMosaic, fftMosaic))
  refineGridMosaic = fftMosaic

  imageOutputFile="{0}/{1}{2}".format(resultsDir, outputName, outputImageExtension)
  seg3d2.assemblefilter(layerid=layerid, shrink_factor=1, pixel_spacing=pixelSpacing, input_mosaic=refineGridMosaic, output_image=imageOutputFile, directory=testRoot, feathering=blendEdges)

  files = []
#sys.exit()
for index in range(rangeMin, stosRangeMax):
  next_index = index + 1
  print('index={0}, next_index={1}'.format(index, next_index))
  outputName = "{0}_{1}".format(datasetName, index)
  nextOutputName = "{0}_{1}".format(datasetName, next_index)

  mosaicFixed="{0}/{1}{2}".format(fftDir, outputName, mosaicExtension)
  if not os.path.isfile(mosaicFixed):
      break
  mosaicMoving="{0}/{1}{2}".format(fftDir, nextOutputName, mosaicExtension)
  if not os.path.isfile(mosaicMoving):
      break