title: How to convert list of pixel into image using python
body: <p>I want to change specific pixel value in whole image.I have converted image into List using img.getdata() function.now after processing i want to convert that list into image format.please suggest me if you know any way to do so.</p>
  
  <pre><code>import cv2
  import numpy as np
  
  from PIL import Image
  img = Image.open('test.jpg','r')
  pix=list(img.getdata())
  for i in pix:
      if i ==(254,0,0):
          print("found",i)
          pi=np.array(pix)
          pi=Image.fromarray(pi)
          cv2.imshow("img",pi)
  </code></pre>
  
  <p>Error is</p>
  
  <pre><code>
  Traceback (most recent call last):
    File "C:\Python38\pixels.py", line 19, in &lt;module&gt;
      cv2.imshow("img",pi)
  TypeError: Expected Ptr&lt;cv::UMat&gt; for argument 'mat'
  
  </code></pre>
  
  <p>i have tried some other way also but not able to see image.</p>