Memory and images
First, we will check how opening images affects random access memory (RAM) usage. In our first example, we will try to open band 8 of the Landsat data using the same technique as before:
Prepare the working environment for Chapter 9 by making a copy of the
Chapter8
folder in yourgeopy
project. Name the copied folder asChapter9
.In
Chapter9
folder, open theexperiments
folder and delete all the files inside it.In the
experiments
folder, create a new Python file and name itimages.py
. Open it for editing.Now type the following code in this file:
# coding=utf-8 import cv2 as cv def open_image(img_path): image = cv.imread(img_path) print(type(image)) raw_input("Press any key.") if __name__ == '__main__': image_path = "../../data/landsat/LC80140282015270LGN00_B8.TIF" open_image(image_path)
Run the code. Press Alt + Shift + F10 and select the images on the list.
Depending on your computer's memory and the OpenCV version, you may succeed. Otherwise, you will...