code: def _deinterlace(self, raw):
          
  
          # Values per row (of the target image)
          vpr = self.width * self.planes
  
          # Values per image
          vpi = vpr * self.height
          # Interleaving writes to the output array randomly
          # (well, not quite), so the entire output array must be in memory.
          # Make a result array, and make it big enough.
          if self.bitdepth > 8:
              a = array('H', [0] * vpi)
          else:
              a = bytearray([0] * vpi)
          source_offset = 0
  
          for lines in adam7_generate(self.width, self.height):
              # The previous (reconstructed) scanline.
              # `None` at the beginning of a pass
              # to indicate that there is no previous line.
              recon = None
              for x, y, xstep in lines:
                  # Pixels per row (reduced pass image)
                  ppr = int(math.ceil((self.width - x) / float(xstep)))
                  # Row size in bytes for this pass.
                  row_size = int(math.ceil(self.psize * ppr))
  
                  filter_type = raw[source_offset]
                  source_offset += 1
                  scanline = raw[source_offset: source_offset + row_size]
                  source_offset += row_size
                  recon = self.undo_filter(filter_type, scanline, recon)
                  # Convert so that there is one element per pixel value
                  flat = self._bytes_to_values(recon, width=ppr)
                  if xstep == 1:
                      assert x == 0
                      offset = y * vpr
                      a[offset: offset + vpr] = flat
                  else:
                      offset = y * vpr + x * self.planes
                      end_offset = (y + 1) * vpr
                      skip = self.planes * xstep
                      for i in range(self.planes):
                          a[offset + i: end_offset: skip] = \
                              flat[i:: self.planes]
  
          return a
docs: Read raw pixel data, undo filters, deinterlace, and flatten.
          Return a single array of values.