Riitters et al. (2000) proposed a quick approach to measure the degree of forest fragmentation that could be relatively easily implemented and which only required a map with forest and non-forest. Following their approach, Sylla consult created a shell script for GRASS GIS 6.4 to create a raster layer with six categories (non-forest, patch, transitional, edge, perforated, interior and undetermined) as a measure of forest fragmentation. See their blog post with an explanation how the script works or the above-cited article for a more in-depth description.
I adapted the script to make it work on GRASS 7.0, including some further improvements, such as the option to select the size of the moving window, the option to trim the output layer to avoid the edge effect that comes with moving-window calculations and the option to keep intermediate layers.
I have now rewritten the script as a Python addon. See here for the manual page. Apart from some minor changes, the main advantage is that you can now install the addon directly using the wxGUI Extension Manager (Settings -> Addon extensions -> Install extensions from addons) or g.extension.
If you want to give it a try, you can install it in GRASS 7+ using the extension manager (I just tried it and it installed successfully on my computer; see the screenshot above. If anybody want to test it on Windows, let me know if it works).