MCPcopy Create free account
hub / github.com/Robbyant/lingbot-map / segment_sky

Function segment_sky

demo_render/rgbd_render/data/sky.py:234–254  ·  view source on GitHub ↗

Segment sky from an image file, returning continuous non-sky confidence in [0, 1].

(
    image_path: str,
    skyseg_session,
    output_path: Optional[str] = None,
)

Source from the content-addressed store, hash-verified

232
233
234def segment_sky(
235 image_path: str,
236 skyseg_session,
237 output_path: Optional[str] = None,
238) -> np.ndarray:
239 """Segment sky from an image file, returning continuous non-sky confidence in [0, 1]."""
240 image = cv2.imread(image_path)
241 if image is None:
242 raise ValueError(f"Failed to read image: {image_path}")
243
244 result_map = run_skyseg(skyseg_session, _SKYSEG_INPUT_SIZE, image)
245 result_map = cv2.resize(result_map, (image.shape[1], image.shape[0]), interpolation=cv2.INTER_LINEAR)
246 mask = _result_map_to_non_sky_conf(result_map)
247
248 if output_path is not None:
249 output_dir = os.path.dirname(output_path)
250 if output_dir:
251 os.makedirs(output_dir, exist_ok=True)
252 cv2.imwrite(output_path, _mask_to_uint8(mask))
253
254 return mask
255
256
257# ---------------------------------------------------------------------------

Callers

nothing calls this directly

Calls 3

run_skysegFunction · 0.70
_mask_to_uint8Function · 0.70

Tested by

no test coverage detected