Skip to content

Instantly share code, notes, and snippets.

@navenduagarwal
Created June 14, 2018 06:09
Show Gist options
  • Select an option

  • Save navenduagarwal/95269ee19462e07edb2b4704116d0c5d to your computer and use it in GitHub Desktop.

Select an option

Save navenduagarwal/95269ee19462e07edb2b4704116d0c5d to your computer and use it in GitHub Desktop.

Revisions

  1. navenduagarwal created this gist Jun 14, 2018.
    26 changes: 26 additions & 0 deletions dummyimage.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,26 @@
    import cv2
    import numpy as np


    def create_blank(width, height, rgb_color=(0, 0, 0)):
    """Create new image(numpy array) filled with certain color in RGB"""
    # Create black blank image
    image = np.zeros((height, width, 3), np.uint8)

    # Since OpenCV uses BGR, convert the color first
    color = tuple(reversed(rgb_color))
    # Fill image with color
    image[:] = color

    return image


    # Create new blank 300x300 red image
    width1, height1 = 300, 300

    red = (255, 0, 0)
    image = create_blank(width1, height1, rgb_color=red)
    cv2.imshow("Blank Image", image)
    cv2.imwrite('red.jpg', image)
    cv2.waitKey(0)
    cv2.destroyAllWindows()