I need to digitize the extent of an ecw raster image where the RGB value is not black.(see attatchment)ie. not the envelope, just the area where the image is shown without the border areas. The black areas are not always 0,0,0 which is the main problem. Is there any way to snap to the cell edges?

Available Software:ArcInfo, FME, GDAL

Aerial image

  • How are you going to do the digitisation? Unsupervised classification? – Simbamangu Feb 21 '14 at 8:07

the image look like there is not much dark areas inside. So you could start by computing the intensity of your RGB image (band 1 + band 2 + band 3) e.g. using raster calculator in ArcGIS, then you set a threshold (e.g. Con (intensity < 10 , 1, 0) using raster calculator). You can also do more complex testing such as directly Con(("band1" < 5) and ("band2" < 5) and ("band3" < 5), 1, 0). With gdal you can use "nearblack".

At this point, you have a nearly clean delineation of your area out of image. But for instance there could be some issues like on the top right of your image where you have something like 2 cloud shadows. One way to remove those artefacts is to combine a shrink and an expand (morphological mathematics). You erode your result by, lets say, 100 pixels, then you dilate it by 100 pixels. Small artefacts should disappear.

You could also convert to polygon and select only the polygon that are "large enough", but this will not correct the errors connected to the boundary. It would be quite fast to remove errors manually, though. Note that when you convert back to raster, you should specify in the environment seeting of the tools (processing extent) that you snap to the pixels of your image.

  • Nearblack didn´t work because the format is ecw. This is a propreitary format and GDAL can´t write to this format. – Robert Buckley Feb 21 '14 at 8:51
  • why use ecw ? maybe you could use jp2000 instead (another wavelet based lossy compression which can be written by GDAL) – radouxju Feb 21 '14 at 9:00
  • From your previous post you are converting to ECW first and you are thereby making life hard for yourself. Simply change the order of your workflow and convert to ECW last - see my answer here) or use jp2000 instead as radouxju suggests. – MappaGnosis Feb 21 '14 at 9:22
  • I can´t convert to ecw last, because this would mean creating a mosaic from TIF which fails in ArcGIS and FME - error being that the size of the file will be over 4GB – Robert Buckley Feb 21 '14 at 20:49
  • I actually tested the senario with one ecw mosaic and a shapefile mask digitized to the raster edges. Even after clipping the image, the same artifacts were left again. It seems that this is one of the downfalls of ecw. If I could work out how to create a clipping mask in fme to define the area which needs to be worked on, maybe I could do it. – Robert Buckley Feb 21 '14 at 20:54

This looks like a follow up on your previous post. I still advocate using 'nearblack' as I suggested there. I would do all the mosaicing, and nearblack etc in GDAL and leave converting to ECW as a final step. If you have a lot of rasters to do then you could script all of this in one script by importing both ArcPy and GDAL modules. Have a function for mosaicing, one for nearblack and then pass off the raster to a function that calls ArcPy to get access to the ECW functionality.

However, here are a few ideas for your digitizing conundrum:

  1. If you have access to ArcScan, you can digitize vectors and snap to a raster.
  2. You could create a fishnet with an origin coincident with your raster and a line spacing equivalent to your raster resolution (the easy way would be to set the numbers of rows and columns of the fishnet to be identical to the raster) and then snap to the fishnet. The only problem here is that the fishnet could be rather large, although this approach wold work in either Arc or QGIS (Vector->Research Tools->Vector Grid or Regular Points).
  3. In QGIS, you could use the Improved Polygon Capturing plugin. This tool allows you to exactly specify the angle and distance of your next point while digitizing. So, starting from LL I would set the first point using the Numerical Digitize tool to be exactly at the LL of your image. Then using the Improved Polygon Capturing I would set the angle to zero and the distance to my raster cell size. Then you can just keep clicking until a vertex reaches the start of the black area. The set the angle to 90 to start heading north (just one click - the angle is always relative to the last point so reset to zero when you are travelling north). Keep clicking until you reach the next 'turn' (where you need to head east again) and set the angle of the next click to -90... and so on. This method is a little more "click-intensive" and you will get a polygon with a lot of redundant vertices but it will be a lot smaller than a fishnet.

I would use a two step approach to 1) reassign raster values <3, for example, to NoData and 2) draw a polygon around the data portions of the raster dataset. For the first part, you can use Set Null (Spatial Analyst) with a statement like the following:

OutRas = SetNull(InRas1 >= 3, InRas1)

For the second step you can use Raster Domain (3D Analyst).

enter image description here

  • Reassigning raster values less than 3 will create no data values inside the image. I tried something similar with the fme RasterExpressionEvaluator. I ended up with white dots all over the place – Robert Buckley Feb 21 '14 at 20:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.