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 three operations for random changing image brightness color and contrast #110

Merged
merged 2 commits into from May 7, 2018

Conversation

CarkusL
Copy link

@CarkusL CarkusL commented May 7, 2018

Hi, I add three operations for random changing image brightness color and contrast.
It can be used like the following code.

`
import Augmentor
p = Augmentor.Pipeline("/path/to/images")
p.random_color(probablility=1,min_factor=0.5,max_factor=1.5)
p.random_contrast(probablility=1,min_factor=0.5,max_factor=1.5)
p.random_brightness(probablility=1,min_factor=0.5,max_factor=1.5)

`

@mdbloice
Copy link
Owner

mdbloice commented May 7, 2018

Hi @deanzhanggit, looks good, thanks a lot for the efforts: one thing I did notice that would need to be fixed before I could merge it is where you randomise stuff (I'll add a few comments in your code). Any randomised assignment performed in the Operation sub-classes needs to be done outside of the do(image) function. Basically it should be done within perform_operation(image) but outside of do(image).
This is essential for the proper functioning of the ground truth related features.
M.


def do(image):

factor = np.random.uniform(self.min_factor, self.max_factor)
Copy link
Owner

@mdbloice mdbloice May 7, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The line above would need to be moved to outside of the scope of do() to somewhere within perform_operation().

Copy link
Author

@CarkusL CarkusL May 7, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mdbloice Thank you for pointing out my mistake. I have moved the
factor = np.random.uniform(self.min_factor, self.max_factor)
out of function do()


def do(image):

factor = np.random.uniform(self.min_factor, self.max_factor)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same goes for this. It would have to be outside of do(), again because we may pass multiple images through here in the case of any ground truth augmentation and we need for them to have the same parameters applied to them all.

@mdbloice mdbloice merged commit fdc2de8 into mdbloice:master May 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants