sparkfish / augraphy

Augmentation pipeline for rendering synthetic paper printing, faxing, scanning and copy machine processes
https://github.com/sparkfish/augraphy
MIT License
356 stars 46 forks source link

DirtyScreen doesnt work and crashes jupyterlabs #429

Closed nkemter closed 7 months ago

nkemter commented 7 months ago

I want to use DirtyScreen as the description sounds very useful. However the example picture in the documentation doesn't show any effect. And when using it in my Jupyterlabs it doesnt work there either. It also crashes jupyterlabs (it opens a "DirtyScreen" subprocess/window that freezes instantly. After that I need to restart the kernel). Im using python 3.11.8

im basically only using different provided examples of you

dirtyscreen = DirtyScreen(n_clusters = (50,100),
                                                      n_samples = (2,20),
                                                      std_range = (1,5),
                                                      value_range = (150,250),
                                                      p=1.0
                          )

image_augmented = dirtyscreen(image)
cv2.imshow("dirtyscreen", image_augmented)
# create borders
ysize, xsize = image.shape[:2]
image[0,:] = 0
image[ysize-1,:] = 0
image[:, 0] = 0
image[:, xsize-1] = 0

# create borders
ysize, xsize = image_augmented.shape[:2]
image_augmented[0,:] = 0
image_augmented[ysize-1,:] = 0
image_augmented[:, 0] = 0
image_augmented[:, xsize-1] = 0

plt.figure()
plt.subplot(1,2,1)
plt.imshow(image, cmap="gray")
plt.title("input")
plt.axis('off')

plt.subplot(1,2,2)
plt.imshow(image_augmented, cmap="gray")
plt.title("augmented")
plt.axis('off')

fname = "../Data/output/augraphy_punkte.png"
if os.path.isfile(fname):
    os.remove(fname)
plt.imsave(fname, image_augmented, cmap="gray")
kwcckw commented 7 months ago

Hi, the dirty screen effect may not be very distinct, but if you zoom it, you will be able to see those tiny blobs. Here's the zoomed image from the documentation output:

image

Also i tried your similar code with JupyterLab 4.0.11 and python 3.11, looks like i didn't getting any problem.

image

Have you try with the other function? Is it crash on all functions or just dirty screen?

nkemter commented 7 months ago

Thanks for the fast answer. After wasting quite a lot of time, I figured out that the crash was completely my fault and not related to dirtyscreen. I misunderstood "cv2.imshow()"

You can close it :)