Ask Your Question
0

Python Function Similiar to Matlab's rangefilt()

asked 2016-05-14 05:35:14 -0600

Taseer gravatar image

Hi, I am working on machine learning where I have to extract certain features. One of these is to find the mean and standard deviation of the image range. The above task can be easily done in MatLab using the rangefilt() function, which returns the range of a 3x3 neighborhood.

Is there any thing similar in Python or OpenCV to help me do the above mentioned task ?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2016-05-14 09:05:47 -0600

LorenaGdL gravatar image

The Matlab rangefilt() function does, according to its documentation, a what it's called morphological gradient. The morphological gradient is the operation resultant from applying over an image a dilation followed by an erosion (see more details here). Such thing is easily achievable with OpenCV function morphologyEx():

morphologyEx(input, output, MORPH_GRADIENT, Mat());   //C++, Python equivalent available

The Mat() kernel is simply the 3x3 neighborhood. As in Matlab, you can change such neighborhood to the one desired by creating a structuring element (with getStructuringElement()).

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2016-05-14 05:35:14 -0600

Seen: 449 times

Last updated: May 14 '16