Giter Site home page Giter Site logo

Comments (5)

shaheryar1 avatar shaheryar1 commented on May 30, 2024 1

Got it. I guess this issue can occur in any of the augmentation type mismatch. There should be a away to restrict this

from augraphy.

kwcckw avatar kwcckw commented on May 30, 2024

gemma

Sorry but do you mean gamma? Gamma correction with Power Law transformation should be useful in adjusting the image intensity and hence giving a better visualization.

from augraphy.

shaheryar1 avatar shaheryar1 commented on May 30, 2024

Yes Gamma. Sorry for typos. I will work on my next PR to add this feature in repo

from augraphy.

jboarman avatar jboarman commented on May 30, 2024

I went ahead and merged this in since it looks pretty straightforward. I'll hold off on publishing to PyPI until someone else has had a chance to test it out.

from augraphy.

kwcckw avatar kwcckw commented on May 30, 2024

I tested it and looks fine, but one thing to take note is this augmentation is only working at post phase, and we will getting error if we put it in paper or ink phase, so it is better to add some notes and code to avoid the error if user put it at ink or paper phase. For example, adding evaluation of post data:

   class GammaAugmentation(Augmentation):
      def __init__(self, range=(0.5, 1.5), probability=0.5):
        super().__init__(probability=probability)
        self.range = range
    
      def __repr__(self):
        return f"GammaAugmentation(range={self.range}, probability={self.probability})"
    
      def __call__(self, data,force=False):
        if data['post']:
            img = data['post'][-1].result
            img = img.astype(np.uint8)
            value = random.uniform(self.range[0], self.range[1])
            invGamma = 1.0 / value
            table = np.array([((i / 255.0) ** invGamma) * 255
                              for i in np.arange(0, 256)]).astype("uint8")
            print(table.shape,img.shape)
            frame= cv2.LUT(img, table)
            data['post'].append(AugmentationResult(self, frame))

Example with gamma of 0.5 amd 2:

image

from augraphy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.