title: the speed is too slow for vtkWindowToImageFilter, how to speed it?
body: <p>Currently, we need to use vtk in my project. We want to obtain the off sreen rendering picture and show it. We use vtkWindowToImageFilter to obtain the rendering picture. However, we find it's too slow. My code is:</p>
  
  <pre><code>from PyQt5.QtWidgets import *
  from PyQt5.QtGui import *
  from PyQt5.QtCore import *
  import sys, os
  import numpy as np
  import vtk, qimage2ndarray
  
  class vtkLabel(QLabel):
      def __init__(self):
          super(vtkLabel, self).__init__()
          cone = vtk.vtkConeSource()
          mapper = vtk.vtkPolyDataMapper()
          mapper.SetInputConnection(cone.GetOutputPort())
          actor = vtk.vtkActor()
          actor.SetMapper(mapper)
  
          ren = vtk.vtkRenderer()
          ren.AddActor(actor)
          renWin = vtk.vtkRenderWindow()
          renWin.AddRenderer(ren)
          renWin.SetOffScreenRendering(1)
          imageFilter = vtk.vtkWindowToImageFilter()
          imageFilter.SetInput(renWin)
  
          self.ren = ren
          self.renWin = renWin
          self.imageFilter = imageFilter
  
      def resizeEvent(self, QMouseEvent):
          super(vtkLabel, self).resizeEvent(QMouseEvent)
          print(self.width(), self.height())
          self.renWin.SetSize(self.width(), self.height())
          self.renWin.Render()
          self.imageFilter.Modified()
          self.imageFilter.Update()
          displayImg = self.imageFilter.GetOutput()
  
          dims = displayImg.GetDimensions()
          from vtk.util.numpy_support import vtk_to_numpy
          numImg = vtk_to_numpy(displayImg.GetPointData().GetScalars())
          numImg = numImg.reshape(dims[1], dims[0], 3)
          numImg = numImg.transpose(0, 1, 2)
          numImg = np.flipud(numImg)
  
          displayQImg = qimage2ndarray.array2qimage(numImg)
          pixmap = QPixmap.fromImage(displayQImg)
          self.pixmap = pixmap
  
      def paintEvent(self, QPaintEvent):
          super(vtkLabel, self).paintEvent(QPaintEvent)
          painter = QPainter(self)
          width = self.width()
          height = self.height()
          painter.drawPixmap(QPoint(0, 0), self.pixmap, QRect(0, 0, width, height))
  
  class MainWindow(QMainWindow):
      def __init__(self, parent=None):
          super(MainWindow, self).__init__(parent)
          self.resize(500,500)
          self.imageLabel = vtkLabel()
          self.setCentralWidget(self.imageLabel)
  
  app = QApplication(sys.argv)
  window = MainWindow()
  window.show()
  app.exec_()
  </code></pre>
  
  <p>In this code, we find the speed is slow when we change the window size. And the weird thing is that the speed would be fast if I delete/comment the code "renWin.SetOffScreenRendering(1)".</p>
  
  <p>How can I speed up this code? Any suggestion is appreciated.</p>