torch_geometric.transforms.ToSLIC
- class ToSLIC(add_seg: bool = False, add_img: bool = False, **kwargs)[source]
Bases:
BaseTransformConverts an image to a superpixel representation using the
skimage.segmentation.slic()algorithm, resulting in atorch_geometric.data.Dataobject holding the centroids of superpixels indata.posand their mean color indata.x(functional name:to_slic).This transform can be used with any
torchvisiondataset.from torchvision.datasets import MNIST import torchvision.transforms as T from torch_geometric.transforms import ToSLIC transform = T.Compose([T.ToTensor(), ToSLIC(n_segments=75)]) dataset = MNIST('/tmp/MNIST', download=True, transform=transform)
- Parameters
add_seg (bool, optional) – If set to True, will add the segmentation result to the data object. (default:
False)add_img (bool, optional) – If set to True, will add the input image to the data object. (default:
False)**kwargs (optional) – Arguments to adjust the output of the SLIC algorithm. See the SLIC documentation for an overview.