I am working in python analyzing 2D arrays and I am looking for a filter or some other routine that would provide a linear expansion of an region boundaries in a 2D array with binary regions (i.e. a black/white image). For example given this star image:

Unfiltered image

I would like to apply a filter that expands a region's borders with a radial, linear decrease from a maximal value (i.e. black) to the surrounding value. Graphically represented as:

Conceptual effect of filter

So that the resulting image/array is something like:

enter image description here

  • $\begingroup$ I did not got your problem, by expansion do you mean you'd like to to enlarge the image (i.e. scale up)? $\endgroup$ – MimSaad Jan 28 '20 at 15:24
  • $\begingroup$ Hi MimSaad, I do not want to change the values in the original region, but I want a bordering region that changes linearly towards the values in the surrounding region. This is shown schematically in the middle figure of my post. $\endgroup$ – Robert Clement Jan 28 '20 at 15:32
  • $\begingroup$ The linear constraint is the hard one. Mainly since it is 2D world so it should be linear in which direction? If you mean smooth, than any blur should do it. $\endgroup$ – Royi Feb 28 '20 at 8:36

Simply resize the binarized image to a larger image but do not use any high order interpolation in resizing and instead use 'nearest neighbor'interpolation technique. In MATLAB:

im2 = imresize(image, 10, 'nearest')

part of 10x expanded image:

enter image description here

and a raster of the image:

enter image description here

  • $\begingroup$ Hi MimSaad Unfortunately that will not work because I need to retain the original scale of the array and the original dimensions/positions of the unfiltered regions of the array (image). $\endgroup$ – Robert Clement Jan 28 '20 at 15:44

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.