コード例 #1
0
    def zwriter(self, imageslice, fname):
        if "OpenEXR" in self.backends:
            imageslice = numpy.flipud(imageslice)
            exr.save_depth(imageslice, fname)

        elif "VTK" in self.backends:
            height = imageslice.shape[1]
            width = imageslice.shape[0]

            file = open(fname, mode='w')
            file.write("Image type: L 32F image\r\n")
            file.write("Name: A cinema depth image\r\n")
            file.write("Image size (x*y): "+str(height) + "*" + str(width) + "\r\n")
            file.write("File size (no of images): 1\r\n")
            file.write(chr(26))
            imageslice.tofile(file)
            file.close()

        elif "PIL" in self.backends:
            imageslice = numpy.flipud(imageslice)
            pimg = PIL.Image.fromarray(imageslice)
            #TODO:
            # don't let ImImagePlugin.py insert the Name: filename in line two
            # why? because ImImagePlugin.py reader has a 100 character limit
            pimg.save(fname)

        else:
            print "Warning: need OpenEXR or PIL or VTK to write to " + fname
コード例 #2
0
    def zwriter(self, imageslice, fname):
        """takes in a depth buffer and writes it as a depth file"""

        if "OpenEXR" in self.backends:
            imageslice = numpy.flipud(imageslice)
            exr.save_depth(imageslice, fname)
            return

        #if self.dontCompressFloatVals:
        #    if "VTK" in self.backends:
        #        height = imageslice.shape[1]
        #        width = imageslice.shape[0]
        #
        #        file = open(fname, mode='w')
        #        file.write("Image type: L 32F image\r\n")
        #        file.write("Name: A cinema depth image\r\n")
        #        file.write("Image size (x*y): "+str(height) + "*" + str(width) + "\r\n")
        #        file.write("File size (no of images): 1\r\n")
        #        file.write(chr(26))
        #        imageslice.tofile(file)
        #        file.close()
        #        return
        #
        #    imageslice = numpy.flipud(imageslice)
        #    pimg = PIL.Image.fromarray(imageslice)
        #    #TODO:
        #    # don't let ImImagePlugin.py insert the Name: filename in line two
        #    # why? because ImImagePlugin.py reader has a 100 character limit
        #    pimg.save(fname)

        imageslice = numpy.flipud(imageslice)
        # Adjust the filename, replace .im with .npz
        baseName, ext = os.path.splitext(fname)
        adjustedName = baseName + ".npz"
        file = open(adjustedName, mode='w')
        numpy.savez_compressed(file, imageslice)
        file.close()
コード例 #3
0
ファイル: raster_wrangler.py プロジェクト: davidlni/ParaView
    def zwriter(self, imageslice, fname):
        """takes in a depth buffer and writes it as a depth file"""

        if "OpenEXR" in self.backends:
            imageslice = numpy.flipud(imageslice)
            exr.save_depth(imageslice, fname)
            return

        #if self.dontCompressFloatVals:
        #    if "VTK" in self.backends:
        #        height = imageslice.shape[1]
        #        width = imageslice.shape[0]
        #
        #        file = open(fname, mode='w')
        #        file.write("Image type: L 32F image\r\n")
        #        file.write("Name: A cinema depth image\r\n")
        #        file.write("Image size (x*y): "+str(height) + "*" + str(width) + "\r\n")
        #        file.write("File size (no of images): 1\r\n")
        #        file.write(chr(26))
        #        imageslice.tofile(file)
        #        file.close()
        #        return
        #
        #    imageslice = numpy.flipud(imageslice)
        #    pimg = PIL.Image.fromarray(imageslice)
        #    #TODO:
        #    # don't let ImImagePlugin.py insert the Name: filename in line two
        #    # why? because ImImagePlugin.py reader has a 100 character limit
        #    pimg.save(fname)

        imageslice = numpy.flipud(imageslice)
        # Adjust the filename, replace .im with .npz
        baseName, ext = os.path.splitext(fname)
        adjustedName = baseName + ".npz"
        file = open(adjustedName, mode='w')
        numpy.savez_compressed(file, imageslice)
        file.close()