Giter Site home page Giter Site logo

Comments (4)

kwcckw avatar kwcckw commented on May 30, 2024 1

Thanks, i will test it again the patch it in the next update.

from augraphy.

proofconstruction avatar proofconstruction commented on May 30, 2024

I merged PR #57 which seems to work fine and not throw bugs 1 and 2 above, but also we now only test with images larger than 30x30.

However , we are still getting an error in some runs of Folding.

from augraphy.

kwcckw avatar kwcckw commented on May 30, 2024

I merged PR #57 which seems to work fine and not throw bugs 1 and 2 above, but also we now only test with images larger than 30x30.

However , we are still getting an error in some runs of Folding.

Thanks for testing it out . I couldn't get a similar error but I'm getting a different error instead. Could you try again to replace the apply_folding function with this and check whether you facing error with image size < 30 and >1?

# Apply perspective transform 2 times and get single folding effect
def apply_folding(self, img, ysize, xsize, gradient_width, gradient_height, fold_noise):
     

    min_fold_x = min(np.ceil(gradient_width[0] * xsize),xsize).astype('int')
    max_fold_x = min(np.ceil(gradient_width[1] * xsize),xsize).astype('int')
    fold_width_one_side = int(random.randint(min_fold_x, max_fold_x)/2)      # folding width from left to center of folding, or from right to center of folding
    
    # test for valid folding center line
    if (xsize-fold_width_one_side-1) < (fold_width_one_side+1):
        print("Folding augmentation is not applied, please increase image size")
        return img
    fold_x = random.randint(fold_width_one_side+1, xsize-fold_width_one_side-1) # center of folding
    
    fold_y_shift_min = min(np.ceil(gradient_height[0] * ysize),ysize).astype('int')
    fold_y_shift_max = min(np.ceil(gradient_height[1] * ysize),ysize).astype('int')
    fold_y_shift = random.randint(fold_y_shift_min, fold_y_shift_max) # y distortion in folding (support positive y value for now)
    
    # test for valid folding width and folding distortion
    if (fold_width_one_side != 0) and (fold_y_shift !=0) :
        img_fold_l = self.warp_fold_left_side(img, ysize, fold_noise, fold_x, fold_width_one_side, fold_y_shift)
        img_fold_r = self.warp_fold_right_side(img_fold_l, ysize, fold_noise, fold_x, fold_width_one_side, fold_y_shift)
        return img_fold_r
    else:
        if (fold_width_one_side != 0):
            print("Folding augmentation is not applied, please increase gradient width or image size")
        else:
            print("Folding augmentation is not applied, please increase gradient height or image size")    
        return img

from augraphy.

proofconstruction avatar proofconstruction commented on May 30, 2024

Fixed with PR #59

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.