Problem 839. Compute the dilation of a binary image
A basic operation in image analysis is the dilation. Given an image where each pixel is either on or off (black/white, true/false), and a neighbourhood, the result of the operation at one pixel is 'on' (white/true) if any of the pixels covered by the neighbourhood, when centred on that pixel, is 'on'.
Take for example a 3x3 neighbourhood. When centring it on any one pixel, it covers that pixel plus its 8 direct neighbours. If any of those 9 pixels is 'on' in the input, that pixel will be 'on' in the output. Looking at it in another way, any 'on' pixel in the input will cause all its 8 direct neighbours to be 'on' in the output.
Your task is to write an algorithm that takes a matrix with 1s and 0s, and computes the dilation. Do not use any toolbox functions, the test suite checks against them (don't use variable names containing things like 'dilate' or 'conv' or 'filt'!).
Solution Stats
Problem Comments
-
1 Comment
@Cris Luengo, filter2 is not a toolbox function, (I am not aware if it was earlier or not) and should be allowed now.
Solution Comments
Show commentsProblem Recent Solvers51
Suggested Problems
-
Find the numeric mean of the prime numbers in a matrix.
8993 Solvers
-
Extract leading non-zero digit
2175 Solvers
-
Given a window, how many subsets of a vector sum positive
857 Solvers
-
Find out missing number from a vector of 9 elements
302 Solvers
-
Natural numbers in string form
1639 Solvers
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!