Mathematica (version 9), 166165 bytes
The nice, short ConvexHullMesh function that Greg Martin used was only introduced in Mathematica version 10, so I thought I'd make an attempt without it, using my ancient Mathematica version 9. I managed to get it slightly shorter, though! It's a function that takes and returns a list of strings (with ., # and o as the symbols).
f@m_:=m(1-m[[2,2]])CrossMatrix@1;""<>#&""<>#&/@("o"MorphologicalComponents[#"o"MorphologicalTransform[MorphologicalComponents[#,Method->"ConvexHull"]~MorphologicalTransform~f+"#"#>"ConvexHull"],Max[#(1-#[[2,2]])CrossMatrix@1]&]+"#"#/.{0->"."})&[Characters@#/.{"."->0,"#"->1}]&
Explanation:
- First,
Characters@# /. {"."->0, "#"->1}turns the input into a matrix of0s and1s. "o" MorphologicalComponents[#"o"MorphologicalTransform[MorphologicalComponents[#, Method->"ConvexHull"] ~MorphologicalTransform~ f + "#" #,Max[#(1-#[[2,2]])CrossMatrix@1]&]+"#"#then uses Mathematica's powerful (but extremely byte-heavy…) image processing capabilities to first fill in the island's convex hull (which is the shape you'd get if you stretched a piece of string around it), and then take its boundary (using the functionf@m_:=m(1-m[[2,2]])CrossMatrix@1). We then multiply this matrix by the string"o"to get a matrix of0s and"o"s (thanks to Mathematica's impressive adaptability about types), and add this to"#"times the matrix of the island.- Finally,
""<>#& /@ (... /. {0->"."})turns this matrix of"o"s,"#"s and0s into a matrix of"o"s,"#"s and"."s, and joins each row into a string.
When we test this on example B, we get the output
{"....oo..",
"...o##o.",
"..o####o",
".o###..o",
"o#####o.",
"o#####o.",
".o##oo..",
"..oo...."}
[Edit, thanks to Greg Martin:] If we're allowed to use arrays of characters instead of lists of strings, we can trim this down to 145144 bytes:
f@m_:=m"o"MorphologicalTransform[MorphologicalComponents[#,Method->"ConvexHull"],Max[#(1-m[[2#[[2,2]])CrossMatrix@1;"o"MorphologicalComponents[#,Method->"ConvexHull"]~MorphologicalTransform~f+"#"#CrossMatrix@1]&]+"#"#/.{0->"."}&[#/.{"."->0,"#"->1}]&