Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Transformations for polarimetric data augmentation

License

NotificationsYou must be signed in to change notification settings

hahnec/polar_augment

Repository files navigation

Description

This repository provides polarimetric image augmentations such as anSO(2) rotation.

Example showing polarimetric azimuth maps after SO(2) rotation

RotationAnimationRotationAnimationGT
spatial-only rotationspatial + polarimetric rotationground truth

Colorbar

Installation

$ git clone github.com/hahnec/polar_augment$cd polar_augment$ bash install.sh

Usage

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)

[8]ページ先頭

©2009-2025 Movatter.jp