Lecture Note
University
University of California San DiegoCourse
DSC 207R | Python for Data SciencePages
2
Academic year
2023
anon
Views
19
Live Code, Satellite Example Part A Here we provide you with a numpy notebook for basic image processing using numpy. Ifyou're looking for the notebook, you need to go to your victory folder and find the satelliteimage analysis notebook. Please locate the WIFIRE folder with the data in there as well. Wepicked satellite imagery because satellite imagery is very interesting image data to exercisethis. Let's begin by gathering our tools together. Like our other notebooks, we'll start by importingnumpy as np, scipy, and matplotlib in this particular case. We go ahead and run that usingshift and enter. The imread function will then be used to read our satellite image as an ndarray. Python givesus access to this function. We'll use the imread function to import a data package in thiscase, which is the WIFIRE folder containing the three-layer image you already have. If you look at the type of this data, we'll see that it's an ndarray. As we talked about before,this is an RGB image and the type is ndarray because it will be turned into an ndarray withthree dimensions. We use the type function to display that type that it shows us ndarray ofcourse. Let's now plot the image in our notebook to see it before we do anything with it. Before setup a frame size of 15 15. You can change that frame size the way you like if your notebook ishigh resolution and things like that. We'll use the imshow function in ski image to display it. We see that the image shows up. That's great. We see our colorful satellite image now. Butwhat are the dimensions of the ndarray? Like I said, it's a three-dimensional one, andbeneath the user shape function, type function won't be enough for that. Let's run photo datawhich is the name we gave to this array and shape as a function. We see that 3725, 300 70025 is the height and width is 4797 and it has three layers for RGB. Those are our threelayers. There's something interesting about this image. Like many other visualizations, the colors ineach RGB layer mean something. For example, the intensity of the red will be an indicationof altitude of the geographical data point in the pixel. The intensity of blue will indicate ameasure of aspect and the green will indicate slope. To a trained eye, to a geo-scientist, or afield modeler, these colors will help to communicate this information in a quicker and moreeffective way rather than showing numbers. So let's go to the n4 line and uncomment that print function if we needed to display thenumbers, for instance. We would observe a variety of figures. If you didn't have to use it, itdoesn't really mean much. It would be challenging to simply comprehend the statistics. Askilled eye can already determine the altitude, slope, and aspect of this vivid image bysimply glancing at it. The objective is to give these hues additional significance to denote amore scientific meaning.
Once we load the image, we can start exploring with it. Let's check its size. We use the sizefunction of the ndarray for that. Like many other things we do, we'll check the maximum andminimum of the data values and maybe the average pixel value. Here, we use ndarray'sminimum function and maximum function. These values are important to verify since theeight-bit color intensity is, cannot be outside of the 0 to 255 range. Let's now discuss some fundamental NumPy image processing methods. NumPy gives usthe tools we need to manipulate our image in a number of ways. Scaling of images is one ofthe procedures. Picture sizing is advantageous.
Satellite Example Part A
Please or to post comments