Skip to content

Conversation

@2prime
Copy link

@2prime 2prime commented Jul 28, 2017

Adding different types of padding: symmetric, edge, reflect

2prime added 2 commits July 28, 2017 13:46
Adding different types of padding: symmetric, edge, reflect
Copy link
Contributor

@alykhantejani alykhantejani left a comment

Choose a reason for hiding this comment

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

I've left some inline comments, as a general comment though - do we want to add separate transforms for these (MirrorPad, SymetricPad etc.)?

assert (type in ["constant","edge","symmetric","reflect"])
self.type = type

def __expand_reflect(slef,image, border=0):

This comment was marked as off-topic.

assert isinstance(fill, numbers.Number) or isinstance(fill, str) or isinstance(fill, tuple)
self.padding = padding
self.fill = fill
assert (type in ["constant","edge","symmetric","reflect"])

This comment was marked as off-topic.

scale = Scale(self.size, interpolation=self.interpolation)
crop = CenterCrop(self.size)
return crop(scale(img))

This comment was marked as off-topic.

import types
import collections

import functools

This comment was marked as off-topic.

"""

def __init__(self, padding, fill=0):
def __init__(self, padding, fill=0,type="constant"):

This comment was marked as off-topic.

@alykhantejani
Copy link
Contributor

Also, we should add some tests for these new pad variants.

Copy link
Member

@fmassa fmassa left a comment

Choose a reason for hiding this comment

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

Thanks for the PR and sorry for the delay in replying.
I agree with @alykhantejani comments, and also made some more. Could you look into addressing those issues?

:return: An image.
"""
img = np.asarray(image)
img = np.pad(img, pad_width=border, mode="reflect")

This comment was marked as off-topic.

"""
img = np.asarray(image)
img = np.pad(img, pad_width=border, mode="reflect")
return Image.fromarray(np.uint8(img))

This comment was marked as off-topic.

return ImageOps.expand(img, border=self.padding, fill=self.fill)
if self.type == "constant":
return ImageOps.expand(img, border=self.padding, fill=self.fill)
elif self.type == "symmetric":

This comment was marked as off-topic.

@fmassa
Copy link
Member

fmassa commented Apr 4, 2018

Superseded by #460

@fmassa fmassa closed this Apr 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants