2017-02-24 18:30:41 -0600 | asked a question | cv2.split(img)[3] fails on RGB[A?] S'up OpenCVers. Although the title of the question (my first!) is quite sparse, the question itself requires some reasonably detailed background... so here goes. I'm working with reasonably large (max size 131GB; usual size ~11GB) ECW aerial images. The images have spatial metadata that includes the co-ordinate system, and the coordinates of the top-left and bottom-right corners and centre, plus details on the colour bands. There is always an Alpha band (which is useful later). The process uses As you might imagine, not all property boundaries are rectangular - and of those that are rectangular, a lot of them are not oriented 'north-south'. All bounding boxes are rectangular and oriented N-S. What this means is that the amount of NODATA in each cut image varies with the degree of tilt of the property boundary away from 'vertical'. Generalising this to non-rectangular images, it varies with the difference between the minimum bounding rectangle of the geometry, and the bounding box. The aim is to get a set of images with minimal NODATA, in order to run them against an image classifier. So the next stage is to take each of the output 'cut' images, and orient them 'as vertically as possible'. The second stage uses
The process is two scripts:
It's two scripts because the job is separable: the cut-up images are produced faster than the 'rotating' happens, and so it makes sense to have one script pumping out 'cut' images and the second script following behind 'rotating' the results (as opposed to doing the cut-and-rotate process to each image). I've done this same task a dozen times (I wrote it to begin with, before there was a Python API for gdal - which meant 3 million Today the 'cut' process worked perfectly, but the 'rotate' failed at the When I look at the images in QGIS ... (more) |