image-processing

How to remove all portrait pictures from a document

风格不统一 提交于 2021-02-10 06:47:14
问题 I am working on OCRing a document image. I want to detect all pictures and remove from the document image. I want to retain tables in the document image. Once I detect pictures I will remove and then want to OCR. I tried to find contour tried to detect all the bigger areas. unfortunately it detects tables also. Also how to remove the objects keeping other data in the doc image. I am using opencv and python Here's my code import os from PIL import Image import pytesseract img = cv2.imread(

Image translation using numpy

对着背影说爱祢 提交于 2021-02-10 06:34:05
问题 I want to perform image translation by a certain amount (shift the image vertically and horizontally). The problem is that when I paste the cropped image back on the canvas, I just get back a white blank box. Can anyone spot the issue here? Many thanks img_shape = image.shape # translate image # percentage of the dimension of the image to translate translate_factor_x = random.uniform(*translate) translate_factor_y = random.uniform(*translate) # initialize a black image the same size as the

PIL change color channel intensity

你离开我真会死。 提交于 2021-02-10 06:28:26
问题 I want to make a color picker, which recolors a png texture while preserving transparency in python3. I only want the brighter parts of the image to be recolored, but also keep the gradient. The only option the I could think of was to adjust the color channel intensity, however I did not find anything like that in the PIL docs. How do I change the color channel intensity? My PNG texture is loaded in ARGB mode and can be found >>here<<. Original Image: 回答1: I dreamt up an approach for this:

Displaying php generated image on a page

可紊 提交于 2021-02-10 06:00:31
问题 I have a function i use in modifying my images, and i want to display thos images on my page alongside other page content. PHP Image Function : <?php function dynamicImage($nw, $nh, $source, $stype, $dest) { $size = getimagesize($source); $w = $size[0]; $h = $size[1]; switch($stype) { case 'gif': $simg = imagecreatefromgif($source); break; case 'jpg': $simg = imagecreatefromjpeg($source); break; case 'png': $simg = imagecreatefrompng($source); break; } $dimg = imagecreatetruecolor($nw, $nh);

How to repair incomplete grid cells and fix missing sections in image

孤人 提交于 2021-02-10 05:59:11
问题 I used Hough lines to get intersection of horizontal and vertical lines in this image: but the complexity grows with the grid cells count significantly. Is there any simple way to complete the grid without using line detection ? Thank you. 回答1: Here's a potential solution using morphological operations with OpenCV Obtain binary image. Load image, grayscale, Gaussian blur, Otsu's threshold Obtain horizontal/vertical lines masks. Create horizontal/vertical kernel and isolate horizontal/vertical

How to repair incomplete grid cells and fix missing sections in image

怎甘沉沦 提交于 2021-02-10 05:56:49
问题 I used Hough lines to get intersection of horizontal and vertical lines in this image: but the complexity grows with the grid cells count significantly. Is there any simple way to complete the grid without using line detection ? Thank you. 回答1: Here's a potential solution using morphological operations with OpenCV Obtain binary image. Load image, grayscale, Gaussian blur, Otsu's threshold Obtain horizontal/vertical lines masks. Create horizontal/vertical kernel and isolate horizontal/vertical

Convert gray image to colored image using feature extraction method in ML

江枫思渺然 提交于 2021-02-10 05:33:07
问题 I have a feature array which is created from ORB with this code part: orb = cv2.ORB_create() #keypoints and descriptors kpO, desO = orb.detectAndCompute(gray_image, None) I create this gray image from colored one. And des0.shape is (500,32). Also shape of my original image(colored one) is (422, 750, 3). And I want to decisionTreeRegression from these arrays for predict the colored version of grayscale image which is I created from colored version. But the problem is starting here , feature

Increase space between text lines in image

≡放荡痞女 提交于 2021-02-09 11:12:18
问题 I have an input image of a paragraph of text in single line spacing. I'm trying to implement something like the line spacing option to increase/decrease space between text lines in Microsoft Word. The current image is in single space, how can I convert the text into double space? Or say .5 space? Essentially I'm trying to dynamically restructure the spacing between text lines, preferably with an adjustable parameter. Something like this: Input image Desired result My current attempt looks

Increase space between text lines in image

*爱你&永不变心* 提交于 2021-02-09 11:11:59
问题 I have an input image of a paragraph of text in single line spacing. I'm trying to implement something like the line spacing option to increase/decrease space between text lines in Microsoft Word. The current image is in single space, how can I convert the text into double space? Or say .5 space? Essentially I'm trying to dynamically restructure the spacing between text lines, preferably with an adjustable parameter. Something like this: Input image Desired result My current attempt looks

How to extract only outer contours from an image (OpenCV)

给你一囗甜甜゛ 提交于 2021-02-09 09:21:36
问题 I am trying to extract digits from the below image using simple OpenCV contours approach, but I am getting overlapping bounding boxes over contours cv2.RETR_EXTERNAL should return only outer contours in the hierarchy but it’s not working as can be seen from the below output Code : from matplotlib import pyplot as plt import cv2 img = cv2.imread('image.png', 0) _, contours, _ = cv2.findContours(img, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE) imgRGB = cv2.cvtColor(img.copy(), cv2.COLOR