Ask Your Question

Revision history [back]

I lose some text while making scanner-like effect

Hey, My goal is to create scanner-like effect. I have image taken by the phone and my result should be make it look like it was scanned. My problem is that my code doesn't work on pictures, or big bold text. You can see that from the text/logo at the upper left corner of the original picture, only it's borders were left in the final result. I want it to be filled. How can I achieve that?

This is my original photo image description ![dasda] (https://imgur.com/a/eftHS9U)

dilated_img = cv2.dilate(img, np.ones((7, 7), np.uint8))

after this line I get this result image description

bg_img = cv2.medianBlur(dilated_img, 21)

I apply blur and get result like this image description

diff_img = 255 - cv2.absdiff(img, bg_img)

Then I take difference and get this result image description

norm_img = diff_img.copy() # Needed for 3.x compatibility
cv2.normalize(diff_img, norm_img, alpha=0, beta=255, norm_type=cv2.NORM_MINMAX, dtype=cv2.CV_8UC1)
_, thr_img = cv2.threshold(norm_img, 230, 0, cv2.THRESH_TRUNC)
cv2.normalize(thr_img, thr_img, alpha=0, beta=255, norm_type=cv2.NORM_MINMAX, dtype=cv2.CV_8UC1)

After normalization I get this, final, result image description

When comparing original image and the result you can clearly see that at the upper left corner from the text/logo only it's edges were left. How can I tweak my code so that that logo remains filled?

I lose some text while making scanner-like effect

Hey, My goal is to create scanner-like effect. I have image taken by the phone and my result should be make it look like it was scanned. My problem is that my code doesn't work on pictures, or big bold text. You can see that from the text/logo at the upper left corner of the original picture, only it's borders were left in the final result. I want it to be filled. How can I achieve that?

This ![This is my original photo image description ![dasda] photo] (https://imgur.com/a/eftHS9U)

dilated_img = cv2.dilate(img, np.ones((7, 7), np.uint8))

after this line I get this result image description![Dilated] (https://imgur.com/a/OgqB3sT)

bg_img = cv2.medianBlur(dilated_img, 21)

I apply blur and get result like this image description![Blurred] (https://imgur.com/a/DyflVny)

diff_img = 255 - cv2.absdiff(img, bg_img)

Then I take difference and get this result image description![Differences] (https://imgur.com/a/2kriaIo)

norm_img = diff_img.copy() # Needed for 3.x compatibility
cv2.normalize(diff_img, norm_img, alpha=0, beta=255, norm_type=cv2.NORM_MINMAX, dtype=cv2.CV_8UC1)
_, thr_img = cv2.threshold(norm_img, 230, 0, cv2.THRESH_TRUNC)
cv2.normalize(thr_img, thr_img, alpha=0, beta=255, norm_type=cv2.NORM_MINMAX, dtype=cv2.CV_8UC1)

After normalization I get this, final, result image description![Final Result] (https://imgur.com/a/eftHS9U)

When comparing original image and the result you can clearly see that at the upper left corner from the text/logo only it's edges were left. How can I tweak my code so that that logo remains filled?

I lose some text while making scanner-like effect

Hey, My goal is to create scanner-like effect. I have image taken by the phone and my result should be make it look like it was scanned. My problem is that my code doesn't work on pictures, or big bold text. You can see that from the text/logo at the upper left corner of the original picture, only it's borders were left in the final result. I want it to be filled. How can I achieve that?

![This is my original photo] (https://imgur.com/a/eftHS9U)

dilated_img = cv2.dilate(img, np.ones((7, 7), np.uint8))

after this line I get this result ![Dilated] (https://imgur.com/a/OgqB3sT)

bg_img = cv2.medianBlur(dilated_img, 21)

I apply blur and get result like this ![Blurred] (https://imgur.com/a/DyflVny)

diff_img = 255 - cv2.absdiff(img, bg_img)

Then I take difference and get this result ![Differences] (https://imgur.com/a/2kriaIo)

norm_img = diff_img.copy() # Needed for 3.x compatibility
cv2.normalize(diff_img, norm_img, alpha=0, beta=255, norm_type=cv2.NORM_MINMAX, dtype=cv2.CV_8UC1)
_, thr_img = cv2.threshold(norm_img, 230, 0, cv2.THRESH_TRUNC)
cv2.normalize(thr_img, thr_img, alpha=0, beta=255, norm_type=cv2.NORM_MINMAX, dtype=cv2.CV_8UC1)

After normalization I get this, final, result ![Final Result] (https://imgur.com/a/eftHS9U)

When comparing original image and the result you can clearly see that at the upper left corner from the text/logo only it's edges were left. How can I tweak my code so that that logo remains filled?

I lose some text while making scanner-like effect

Hey, My goal is to create scanner-like effect. I have image taken by the phone and my result should be make it look like it was scanned. My problem is that my code doesn't work on pictures, or big bold text. You can see that from the text/logo at the upper left corner of the original picture, only it's borders were left in the final result. I want it to be filled. How can I achieve that?

![This is my original photo] (https://imgur.com/a/eftHS9U)(https://imgur.com/a/BZ5LWt3)

dilated_img = cv2.dilate(img, np.ones((7, 7), np.uint8))

after this line I get this result ![Dilated] (https://imgur.com/a/OgqB3sT)

bg_img = cv2.medianBlur(dilated_img, 21)

I apply blur and get result like this ![Blurred] (https://imgur.com/a/DyflVny)

diff_img = 255 - cv2.absdiff(img, bg_img)

Then I take difference and get this result ![Differences] (https://imgur.com/a/2kriaIo)

norm_img = diff_img.copy() # Needed for 3.x compatibility
cv2.normalize(diff_img, norm_img, alpha=0, beta=255, norm_type=cv2.NORM_MINMAX, dtype=cv2.CV_8UC1)
_, thr_img = cv2.threshold(norm_img, 230, 0, cv2.THRESH_TRUNC)
cv2.normalize(thr_img, thr_img, alpha=0, beta=255, norm_type=cv2.NORM_MINMAX, dtype=cv2.CV_8UC1)

After normalization I get this, final, result ![Final Result] (https://imgur.com/a/eftHS9U)

When comparing original image and the result you can clearly see that at the upper left corner from the text/logo only it's edges were left. How can I tweak my code so that that logo remains filled?

I lose some text while making scanner-like effect

Hey, My goal is to create scanner-like effect. I have image taken by the phone and my result should be make it look like it was scanned. My problem is that my code doesn't work on pictures, or big bold text. You can see that from the text/logo at the upper left corner of the original picture, only it's borders were left in the final result. I want it to be filled. How can I achieve that?

![This is my original photo] (https://imgur.com/a/BZ5LWt3)(https://i.imgur.com/IwCV9Ai.jpg)

dilated_img = cv2.dilate(img, np.ones((7, 7), np.uint8))

after this line I get this result ![Dilated] (https://imgur.com/a/OgqB3sT)(https://i.imgur.com/XMv9oQH.jpg)

bg_img = cv2.medianBlur(dilated_img, 21)

I apply blur and get result like this ![Blurred] (https://imgur.com/a/DyflVny)(https://i.imgur.com/vP8UAaq.jpg)

diff_img = 255 - cv2.absdiff(img, bg_img)

Then I take difference and get this result ![Differences] (https://imgur.com/a/2kriaIo)(https://i.imgur.com/5mj2UWk.jpg)

norm_img = diff_img.copy() # Needed for 3.x compatibility
cv2.normalize(diff_img, norm_img, alpha=0, beta=255, norm_type=cv2.NORM_MINMAX, dtype=cv2.CV_8UC1)
_, thr_img = cv2.threshold(norm_img, 230, 0, cv2.THRESH_TRUNC)
cv2.normalize(thr_img, thr_img, alpha=0, beta=255, norm_type=cv2.NORM_MINMAX, dtype=cv2.CV_8UC1)

After normalization I get this, final, result ![Final Result] (https://imgur.com/a/eftHS9U)(https://i.imgur.com/orVZfwZ.jpg)

When comparing original image and the result you can clearly see that at the upper left corner from the text/logo only it's edges were left. How can I tweak my code so that that logo remains filled?

I lose some text while making scanner-like effect

Hey, My goal is to create scanner-like effect. I have image taken by the phone and my result should be make it look like it was scanned. My problem is that my code doesn't work on pictures, or big bold text. You can see that from the text/logo at the upper left corner of the original picture, only it's borders were left in the final result. I want it to be filled. How can I achieve that?

![This is my original photo] (https://i.imgur.com/IwCV9Ai.jpg)

dilated_img = cv2.dilate(img, np.ones((7, 7), np.uint8))

after this line I get this result ![Dilated] (https://i.imgur.com/XMv9oQH.jpg)

bg_img = cv2.medianBlur(dilated_img, 21)

I apply blur and get result like this ![Blurred] (https://i.imgur.com/vP8UAaq.jpg)

diff_img = 255 - cv2.absdiff(img, bg_img)

Then I take difference and get this result ![Differences] (https://i.imgur.com/5mj2UWk.jpg)

norm_img = diff_img.copy() # Needed for 3.x compatibility
cv2.normalize(diff_img, norm_img, alpha=0, beta=255, norm_type=cv2.NORM_MINMAX, dtype=cv2.CV_8UC1)
_, thr_img = cv2.threshold(norm_img, 230, 0, cv2.THRESH_TRUNC)
cv2.normalize(thr_img, thr_img, alpha=0, beta=255, norm_type=cv2.NORM_MINMAX, dtype=cv2.CV_8UC1)

After normalization I get this, final, result ![Final Result] (https://i.imgur.com/orVZfwZ.jpg)

When comparing original image and the result you can clearly see that at the upper left corner from the text/logo only it's edges were left. How can I tweak my code so that that logo remains filled?

I lose some text while making scanner-like effect

Hey, My goal is to create scanner-like effect. I have image taken by the phone and my result should be make it look like it was scanned. My problem is that my code doesn't work on pictures, or big bold text. You can see that from the text/logo at the upper left corner of the original picture, only it's borders were left in the final result. I want it to be filled. How can I achieve that?

![This is my original photo] (https://i.imgur.com/IwCV9Ai.jpg)This is my original photo

dilated_img = cv2.dilate(img, np.ones((7, 7), np.uint8))

after this line I get this result ![Dilated] (https://i.imgur.com/XMv9oQH.jpg)Dilated

bg_img = cv2.medianBlur(dilated_img, 21)

I apply blur and get result like this ![Blurred] (https://i.imgur.com/vP8UAaq.jpg)Blurred

diff_img = 255 - cv2.absdiff(img, bg_img)

Then I take difference and get this result ![Differences] (https://i.imgur.com/5mj2UWk.jpg)Differences

norm_img = diff_img.copy() # Needed for 3.x compatibility
cv2.normalize(diff_img, norm_img, alpha=0, beta=255, norm_type=cv2.NORM_MINMAX, dtype=cv2.CV_8UC1)
_, thr_img = cv2.threshold(norm_img, 230, 0, cv2.THRESH_TRUNC)
cv2.normalize(thr_img, thr_img, alpha=0, beta=255, norm_type=cv2.NORM_MINMAX, dtype=cv2.CV_8UC1)

After normalization I get this, final, result ![Final Result] (https://i.imgur.com/orVZfwZ.jpg)Final Result

When comparing original image and the result you can clearly see that at the upper left corner from the text/logo only it's edges were left. How can I tweak my code so that that logo remains filled?

I lose some text while making scanner-like effect

Hey, My goal is to create scanner-like effect. I have image taken by the phone and my result should be make it look like it was scanned. My problem is that my code doesn't work on pictures, or big bold text. You can see that from the text/logo at the upper left corner of the original picture, only it's borders were left in the final result. I want it to be filled. How can I achieve that?

This is my original photo

dilated_img = cv2.dilate(img, np.ones((7, 7), np.uint8))

after this line I get this result Dilated

bg_img = cv2.medianBlur(dilated_img, 21)

I apply blur and get result like this Blurred

diff_img = 255 - cv2.absdiff(img, bg_img)

Then I take difference and get this result Differences

norm_img = diff_img.copy() # Needed for 3.x compatibility
cv2.normalize(diff_img, norm_img, alpha=0, beta=255, norm_type=cv2.NORM_MINMAX, dtype=cv2.CV_8UC1)
_, thr_img = cv2.threshold(norm_img, 230, 0, cv2.THRESH_TRUNC)
cv2.normalize(thr_img, thr_img, alpha=0, beta=255, norm_type=cv2.NORM_MINMAX, dtype=cv2.CV_8UC1)

After normalization I get this, final, result Final Result

When comparing original image and the result you can clearly see that at the upper left corner from the text/logo only it's edges were left. How can I tweak my code so that that logo remains filled?