I try to resize Pixel segments exported from eCognition. The goal is to erode the segments for one pixel of the boarder.

So for example if the segment is 30px x 30px the result should be a new area with 28px x 28px. The Problem is that every Segment got an ID, so it should work for every single Segment especially when there are connected. I'm working with QGIS 2.12 and probably it is possible with the raster calculator right?

I found a solution in eCognition: enter image description here enter image description here

  • I'm not sure to understand. Is your layer a raster, or a vector layer (polygons)? If you are dealing with a vector layer, you could try the Buffer tool (and set a negative buffer).
    – ArMoraer
    Commented Mar 21, 2016 at 14:35
  • Thx for your post. I Need a function for a raster layer. For the vector layer with the same data your´re right with the negative buffer. That is working. Commented Mar 21, 2016 at 15:22

1 Answer 1


As far as I know there is no native way to do morphological operations in QGIS, but there are two tools in the Processing Toolbox that can help you (I have never used them). Both require to install another software, though:

  • if you install SAGA, you'll have access to the "Morphological filter" tool, which allows you to perform basic morphological operations (namely erosion, dilatation, opening and closing).

  • otherwise, you can install Orfeo ToolBox (OTB) which gives you slightly more advanced tools. For example, there are a BinaryMorphologicalOperation (erode) and a GrayScaleMorphologicalOperation (erode) tools. The latter might be the best suited to your problem.

Of course, you can use SAGA and OTB on their own, without QGIS; but I find it more convenient to do all my work in QGIS.

  • I found a solution in eCognition. The tool is called "pixel based object resizing" Commented Mar 22, 2016 at 20:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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