How to store the resulted image from OpenCV using Python in directory?
<p>I have experimenting with a python script which scales the images by 2 times and it is working fine, but the problem is how to store this resulted image in my disk so I can compare the results before and after.</p>

<pre><code>import cv2
import numpy as np

img = cv2.imread('input.jpg')

res = cv2.resize(img,None,fx=2, fy=2, interpolation = cv2.INTER_CUBIC)
</code></pre>

<p>Resultant is stored in res variable but it should be created as new image. How?</p>

<p>My desired output should be result.jpg</p>

<p>What i got when printed res</p>

<pre><code>&gt;&gt;&gt; res
array([[[ 39,  43,  44],
        [ 40,  44,  44],
        [ 41,  45,  46],
        ..., 
        [ 54,  52,  52],
        [ 52,  50,  50],
        [ 51,  49,  49]],

       [[ 38,  42,  44],
        [ 39,  43,  44],
        [ 41,  45,  46],
        ..., 
        [ 55,  53,  53],
        [ 54,  52,  52],
        [ 53,  51,  51]],

       [[ 37,  40,  43],
        [ 38,  41,  44],
        [ 40,  43,  46],
        ..., 
        [ 58,  56,  55],
        [ 56,  54,  54],
        [ 56,  53,  53]],

       ..., 
       [[ 52, 135,  94],
        [ 54, 137,  95],
        [ 59, 141,  99],
        ..., 
        [ 66, 139, 101],
        [ 62, 135,  96],
        [ 60, 133,  94]],

       [[ 47, 131,  89],
        [ 49, 133,  91],
        [ 55, 138,  96],
        ..., 
        [ 56, 129,  91],
        [ 54, 127,  89],
        [ 54, 127,  88]],

       [[ 44, 128,  86],
        [ 47, 130,  88],
        [ 53, 136,  94],
        ..., 
        [ 50, 123,  85],
        [ 50, 123,  85],
        [ 50, 123,  85]]], dtype=uint8)
</code></pre>

<p>You can use imwrite function. </p>

<p>You can find the description of this function <a href="http://docs.opencv.org/2.4.13/modules/highgui/doc/reading_and_writing_images_and_video.html" rel="nofollow">here</a></p>

python image python-2.7 opencv numpy