Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add RCropSize for a randomly placed CropSize #21

Closed
Evizero opened this issue Apr 18, 2018 · 2 comments
Closed

Add RCropSize for a randomly placed CropSize #21

Evizero opened this issue Apr 18, 2018 · 2 comments
Milestone

Comments

@Evizero
Copy link
Owner

Evizero commented Apr 18, 2018

for a bit more variation

@Evizero Evizero changed the title add RCropSize for a randomly placed CropSize Add RCropSize for a randomly placed CropSize Apr 18, 2018
@johnnychen94 johnnychen94 added this to the v0.7 milestone Dec 19, 2019
@johnnychen94
Copy link
Collaborator

johnnychen94 commented Dec 19, 2019

As a note to myself, here's something I've just made in my project

function generate_data(img;
                       noise_level=0.1,
                       patch_size=41)

    pl = ConvertEltype(Gray{Float32}) |>
         Either(NoOp(), Rotate90(), Rotate180(), Rotate270()) |>
         Either(0.5=>NoOp(), 0.25=>FlipX(), 0.25=>FlipY())
    noise = AdditiveWhiteGaussianNoise(noise_level)
    
    # randomly crop a valid 41*41 area
    w, h = map(collect.(axes(img))) do idx
        rand_idx = randperm(maximum(idx)-minimum(idx))
        idx_start = findfirst(x->x+patch_size<=maximum(idx), idx)
        idx_start = idx[idx_start]
        return idx_start:idx_start+patch_size-1
    end
    patch = augment(img, pl)[w, h]
    apply_noise!(patch, noise), patch # input, label
end

There're two places not so good/concise:

With regard to crop, probably we're making too many crop types here 😂 I guess some can be combined into one. Will take a look when I find some time.

@johnnychen94
Copy link
Collaborator

closed by #64

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants