- Notifications
You must be signed in to change notification settings - Fork0
Transformations for polarimetric data augmentation
License
NotificationsYou must be signed in to change notification settings
hahnec/polar_augment
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
This repository provides polarimetric image augmentations such as anSO(2) rotation.
![]() | ![]() | ![]() |
---|---|---|
spatial-only rotation | spatial + polarimetric rotation | ground truth |
$ git clone github.com/hahnec/polar_augment$cd polar_augment$ bash install.sh
The provided transforms expect the image dimensions to be in PyTorch styleCxHxW
.
importtorch# direct applicationfrompolar_augment.rotation_mmimportRandomMuellerRotationrotate=RandomMuellerRotation(degrees=45,p=float('inf'))mm_img=torch.randn([128,128,4,4]).flatten(2,3).permute(2,0,1)mm_img_rotated=rotate(mm_img)print(mm_img_rotated.shape)# application for calibration matrices (dataloader-friendly for raw data)frompolar_augment.rotation_rawimportRandomPolarRotationrotate=RandomPolarRotation(degrees=45,p=float('inf'))mm_img=torch.randn([128,128,4*3,4]).flatten(2,3).permute(2,0,1)mm_img_rotated=rotate(mm_img)print(mm_img_rotated.shape)
Alternatively, the transforms can be integrated during dataloading as for example by
fromtorchvision.transformsimportToTensorfrompolar_augment.flip_rawimportRandomPolarFlipfrompolar_augment.rotation_rawimportRandomPolarRotationfrompolar_datasetimportPolarimetryDataset# define list of transformstransforms= [ToTensor(),RandomPolarRotation(degrees=180,p=.5),# rotationRandomPolarFlip(orientation=0,p=.5),# horizontal flipRandomPolarFlip(orientation=1,p=.5),# vertical flipRandomPolarFlip(orientation=2,p=.5),# combined horizontal and vertical flip ]# pass transforms to your datasetPolarimetryDataset(some_file_path,transforms=transforms)
where the augmentation can then be applied to frames and labels within thePolarimetryDataset
classPolarimetryDataset(Dataset):def__init__(self,path,transforms=[], ):self.load_file_paths(path)self.transforms=transformsdef__getitem__(self,i):frame=load_file(self.frame_paths[i])label=load_file(self.label_paths[i])fortransforminself.transforms:frame,label=transform(frame,label=label)
About
Transformations for polarimetric data augmentation