title: Glitches in the image is observed after converting binary data into an Image using python
body: <blockquote>
    <p>I have video file in .bin format of frame resolution width=1280 and height=672.I have converted that binary data into an RGB format then re-scaling(width=900 &amp; height=600) and through wxImage viewer window it is displayed.</p>
  </blockquote>
  
  <pre><code>    def ret_frame(self, e, frame_num):
  
          self.total_frames, f
          #Reading a frame size data
          self.uyvy_size = self.img_height * self.img_width * 2
  
          assert (frame_num &lt;= self.total_frames and frame_num &gt;= 1), "frame number not in range"
  
          f.seek(self.uyvy_size * (frame_num - 1), os.SEEK_SET)
          uyvy = np.fromfile(f, count=self.uyvy_size, dtype=np.uint8)
  
          #String each uyvy component into a separate numpy array
          u = uyvy[::4].astype(dtype=np.float32)
          y1 = uyvy[1::4].astype(dtype=np.float32)
          v = uyvy[2::4].astype(dtype=np.float32)
          y2 = uyvy[3::4].astype(dtype=np.float32)
          #Logic to convert uyvy into rgb
          r1 = ((y1 + ((1.4065) * (v - 128))) * 0.85).astype(dtype=np.uint8)
          g1 = (((y1 - ((0.3455) * (u - 128)) - (0.7169 * (v - 128)))) * 0.85).astype(dtype=np.uint8)
          b1 = (((y1 + ((1.7790) * (u - 128)))) * 0.85).astype(dtype=np.uint8)
          r1[r1 &gt; 255] = 255
          g1[r1 &gt; 255] = 255
          b1[r1 &gt; 255] = 255
  
          r1[r1 &lt; 0] = 0
          g1[r1 &lt; 0] = 0
          b1[r1 &lt; 0] = 0
  
          r2 = (((y2 + ((1.4065) * (v - 128)))) * 0.85).astype(dtype=np.uint8)
          g2 = (((y2 - ((0.3455) * (u - 128)) - (0.7169 * (v - 128)))) * 0.85).astype(dtype=np.uint8)
          b2 = (((y2 + ((1.7790) * (u - 128)))) * 0.85).astype(dtype=np.uint8)
          r2[r2 &gt; 255] = 255
          g2[r2 &gt; 255] = 255
          b2[r2 &gt; 255] = 255
  
          r2[r2 &lt; 0] = 0
          g2[r2 &lt; 0] = 0
          b2[r2 &lt; 0] = 0
  
          img = np.dstack((r1, g1, b1, r2, g2, b2))
  
          self.image = wx.Image(self.img_width, self.img_height, img)
          #OpenCV show is used to clear the buffer otherwise after showing some frame ,the framework crashes
          dummy_img = np.zeros((0, 0, 3))
          cv2.imshow("asdf", 0)
          #Rescaling the image into smaller size image
          self.image = self.image.Rescale(900, 600, wx.IMAGE_QUALITY_HIGH)
          self.imageCtrl.SetBitmap(wx.Bitmap(self.image))
  </code></pre>