logo
down
shadow

How to remove border of microsoft word in text image in opencv with python?


How to remove border of microsoft word in text image in opencv with python?

By : Theodros Katzalis
Date : October 25 2020, 02:08 AM
With these it helps I have this picture which the border make by Microsoft word office : , I think the simpliest way would be using ROI as you did.
code :
cv::Mat workingRegion = img(cv::Rect(x_coord,y_coord,width,height), img.type());
cv::threshold(img,img,100,255, CV_THRESH_OTSU);


Share : facebook icon twitter icon
Python OpenCV: remove border from image

Python OpenCV: remove border from image


By : Azhar Hossain
Date : March 29 2020, 07:55 AM
To fix this issue I have a little hack for this. If you're falling low on thickness, repeat the process. Again, it's not the best way to do it, but it should work.
I want to remove a blurred Black Border from an image with openCv

I want to remove a blurred Black Border from an image with openCv


By : IronMan
Date : March 29 2020, 07:55 AM
This might help you you can try getting mean of vertical and horizontal lines if means smaller than 100 change blacks to white:
code :
import cv2
import numpy as np

img=cv2.imread("test.jpg",0).T #load image and transpose it(like rotate 90 degree)
sens=1.0 # (0-1]
meanofimg=np.mean(img)*sens #get avarage brightness of img
w,h=img.shape #get image's shape
for i in range(w): #for every horizontal line in transposed img(vertical line in normal)
    if np.mean(img[i])<meanofimg: #check if this line darker than avarage
        img[i]=(img[i]+255)%256 #add 255 for every pixel and get mod 256 this for make zeros 255 and do not touch others
        #img[i]=(img[i]*0+255) #for makin all pixels in line white
img=img.T #turn image to normal
for i in range(h): #every horizontal line in img
    if np.mean(img[i])<meanofimg: # if line darker than avarage
        img[i]=(img[i]+255)%256 #do same thing
        #img[i]=(img[i]*0+255) #for makin all pixels in line white

cv2.imwrite("output.jpg",img) #write img as output.jpg
import cv2
import numpy as np

img=cv2.imread("test.jpg",0).T
w,h=img.shape
sens=1.0 # (0-1]
meanofimg=np.mean(img)*sens
dataw=[w,0]
datah=[h,0]
for i in range(w):
    if np.mean(img[i])>meanofimg:
        if i<dataw[0]:
            dataw[0]=i
        else:
            dataw[1]=i
img=img.T
meanofimg=np.mean(img)*sens
for i in range(h):
    if np.mean(img[i])>meanofimg:
        if i<datah[0]:
            datah[0]=i
        else:
            datah[1]=i
img=img[datah[0]:datah[1],dataw[0]:dataw[1]]
cv2.imwrite("output.jpg",img)
How to remove internal and border contours from an image using OpenCV?

How to remove internal and border contours from an image using OpenCV?


By : user3075564
Date : March 29 2020, 07:55 AM
I wish did fix the issue. The function findContours detects contours around non-zero pixels. In your example the background is white, while the objects you are trying to detect are black, therefore the contours are detected around the background, not the objects as you expect. You can simply negate the image with cv2.bitwise_not function to make the background black, assuming that the background color is 255.
Now when you have correctly defined objects and background, you can use the flag CV_RETR_EXTERNAL for findContours function to detect only external contours. Note that this flag won't work if the background is white, because all those letters are internal contours for this one big contour on the image border.
code :
import numpy as np
import cv2 as cv

im = cv.imread('0.jpg')
imgray = cv.cvtColor(im, cv.COLOR_BGR2GRAY)
blur = cv.GaussianBlur(imgray, (5, 5), 0)
ret3, thresh = cv.threshold(blur, 0, 255, cv.THRESH_BINARY + cv.THRESH_OTSU)
thresh_inverse = cv.bitwise_not(imgray)
contours, hierarchy = cv.findContours(thresh_inverse, cv.RETR_EXTERNAL, cv.CHAIN_APPROX_SIMPLE)
cv.drawContours(im, contours, -1, (0, 0, 255), 1)
cv.imwrite('image.jpg', im)
ret3, thresh = cv.threshold(blur, 0, 255, cv.THRESH_BINARY_INV + cv.THRESH_OTSU)
How to remove border components in Python 2.7 using Opencv

How to remove border components in Python 2.7 using Opencv


By : goushi khan
Date : March 29 2020, 07:55 AM
I hope this helps you . There is no direct method in openCV to do that. You can write a function using the method floodFill and loop over for border pixels as seed points.
floodFill(dstImg,seed,Scalar (0));
Remove border of license plates with OpenCV (python)

Remove border of license plates with OpenCV (python)


By : 何遠城
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further I have a naïve solution for one image. You have to tune some parameters to generalize it for the other images.
I chose the third image due to its clarity.
Related Posts Related Posts :
  • antlr4 + python: debug token match
  • How to 'blit' sprites onto window for a set time
  • Program that checks if a number is prime number
  • python pandas time line graph
  • Reading a text file with OpenCV in Python
  • PyGame in MacOSX: CGContextDrawImage: invalid context 0x0
  • Twisted chat server demo exits immediately
  • How to calculate block averages in pandas DataFrame
  • how to change a list to a specific string.
  • Overlapping text when saving multiple Matplotlib images with text in a loop
  • How do I scrape ONLY <div class ='quotetext'> from a website using python?
  • Python: Float Object is not Iterable
  • ValueError: need more than 3 values to unpack
  • Evaluate while loop at certain point?
  • RxPy - Why are emissions interleaved with merging operators?
  • Spyder - hints disappear too fast
  • Creating a |N| x |M| matrix from a hash-table
  • daily data, resample every 3 days, calculate over trailing 5 days efficiently
  • How to do this program without a counter?
  • Saving a data frame with a column of list in python
  • Python newbie - refactor string function
  • TypeError: deafultdict must have first arguments callable
  • Zero padding not performed properly I think
  • When to bind to attributes that populated with kv-file?
  • Python - Adding "hidden" values to tuples
  • Multselecting in Pandas using .loc
  • python - checking if an array consisting of N integers is a permutation
  • How do you set the outer bg colour of a plot in matplotlib
  • Checking if an input is formatted correctly in Python 3
  • How to restrict two columns not to have the same value using Django?
  • Using turtle in Python to draw six-pointed stars with different side lengths
  • QAbstractListModel does not get updated with values when data is loaded from CSV, but it does when using hardcoded value
  • Python - Modify dictionary from function
  • django-ldap-auth user profile in django > 1.7
  • Rate Limit API Calls to Shopify API with Django on Google App Engine
  • TypeError: decoding str is not supported
  • Regular expression behaves unexpectedly when using some specific words
  • Counting uppercase letters in a list excluding the first capital in a word
  • Use socket.io to display realtime data
  • How to neatly print dictionaries with dictionaries inside
  • sorting dictionary by numeric value
  • How to find HDF5 file groups/keys within Python?
  • Cannot access nested dictionary in python
  • How to add a code fix for infinite loop while adding two integers using bitwise operations
  • Stuck in while loop
  • In Tensorflow, do I need to add new op for "sinc" or "gaussian" activation functions?
  • Conditional statment regarding various regex and length of a list in python
  • log2 axis doesn't work for histograms in matplotlib/seaborn
  • Selenium using Python - Geckodriver executable needs to be in PATH
  • Adding legend to a radarchart in Python
  • Detect same words using different alphabets?
  • What representation of chat text data should I use for user classification?
  • 'sqlite3.Cursor' object has no attribute '__getitem__' Error in Python Flask
  • Python Numpy: Coalesce and return first nonzero observation
  • Dowloading data from quandl.com and want to know how I include my API key with my request?
  • How to set python version on windows platform for matlab?
  • AttributeError: 'function' object has no attribute 'index'
  • Difficulty using subprocess.check_output with command line argument in many parts
  • Can someone tell me what are the mistakes in this code?
  • Convert 16 bytes of random data to integer in Python
  • shadow
    Privacy Policy - Terms - Contact Us © soohba.com