image-processing

Tesseract image_to_string is empty

我们两清 提交于 2020-05-13 07:35:16
问题 I have a simple text in an image image_ball.png . Usually OCR of Tesseract works well, but for this certain image it returns always an empty string. In [1]: from PIL import Image In [2]: from pytesseract import image_to_string In [3]: img = Image.open("image_ball.png") In [4]: image_to_string(img) Out[5]: u'' I could not find a workaround up-to-now. How could I figure out what is going wrong with this image? The versions are: In [6]: import PIL In [7]: PIL.__version__ Out[7]: '4.0.0' $

Naive Implementation of Convolution algorithm

我们两清 提交于 2020-05-12 01:43:08
问题 Currently learning about computer vision and machine learning through the free online course by stanford CS131. Came across some heavy math formulas and was wondering if anyone could explain to me how one would go on about in implementing a naive 4 nested for loops for the convolution algorithm using only knowing the image height, width and kernel height and width. I was able to come up with this solution by researching online. image_padded = np.zeros((image.shape[0] + 2, image.shape[1] + 2))

Extract artwork from table game card image with OpenCV

痞子三分冷 提交于 2020-05-10 04:20:30
问题 I wrote a small script in python where I'm trying to extract or crop the part of the playing card that represents the artwork only, removing all the rest. I've been trying various methods of thresholding but couldn't get there. Also note that I can't simply record manually the position of the artwork because it's not always in the same position or size, but always in a rectangular shape where everything else is just text and borders. from matplotlib import pyplot as plt import cv2 img = cv2

Image Processing: What are occlusions?

岁酱吖の 提交于 2020-05-09 17:37:05
问题 I'm developing an image processing project and I come across the word occlusion in many scientific papers, what do occlusions mean in the context of image processing? The dictionary is only giving a general definition. Can anyone describe them using an image as a context? 回答1: Occlusion means that there is something you want to see, but can't due to some property of your sensor setup, or some event. Exactly how it manifests itself or how you deal with the problem will vary due to the problem

How to save lossless jpg in java?

老子叫甜甜 提交于 2020-05-02 05:30:14
问题 I have to save a jpeg image lossless. I am work on a steganography project but Java compressing and saving my result. I research every forums and try everything but it didn't work. Here my example code for lossless save a jpeg image: BufferedImage image = ImageIO.read(new File("sources/image.jpg")); ImageWriter writer = ImageIO.getImageWritersByFormatName("JPEG").next(); JPEGImageWriteParam jpegParams = new JPEGImageWriteParam(null); jpegParams.setCompressionMode(ImageWriteParam.MODE_EXPLICIT

Why multiple openings/closing with a same kernel does not have effect?

此生再无相见时 提交于 2020-04-30 07:43:45
问题 I know about closing and opening, but there is still one question to me! According to the "Digital Image Processing, 3rd edition", by Gonzales, The multiple application of opening/closing doesn't have any effect after the first time you apply it! I couldn't figure it out? Can anyone help? 回答1: This is expected behavior since openings and closings are idempotent operations. An operation is idempotent if, whenever it is applied twice to any value, it gives the same result as if it were applied

OpenCV - How to determine whether a given point is within a contour?

懵懂的女人 提交于 2020-04-30 07:36:27
问题 Given a random contour, how can I say if a given input point lies within the contour or not? I am sorry if it has a simple solution, but I am unable to figure it out. One idea I had was to use equation of lines, connect points and see if it is greater or smaller, etc. But that doesn't get me anywhere, as it depends on the position of line. 回答1: You can find a full solution to this problem using OpenCV here /// Get the contours vector<vector<Point> > contours; vector<Vec4i> hierarchy; Mat src

How can I avoid exceeding the max call stack size during a flood fill algorithm?

不打扰是莪最后的温柔 提交于 2020-04-30 06:31:08
问题 I am using a recursive flood fill algorithm in javascript and I am not sure how to avoid exceeding the max call stack size. This is a little project that runs in the browser. I got the idea from here: https://guide.freecodecamp.org/algorithms/flood-fill/ I chose this algorithm because it's easy to understand and so far I like it because it's pretty quick. x and y are the 2-d coordinates from the top-left, targetColor and newColor are each a Uint8ClampedArray , and id = ctx.createImageData(1,1

to concatenate 4 images using np.concatenate (two vertically and two horizontally)

牧云@^-^@ 提交于 2020-04-30 06:25:24
问题 I have four images and I want to concatenate them into 1 image.I tried using concatenate function but there are multiple images and from them i need only in a batch of 4 images. Actually the images are named as 0.jpg, 1.jpg,2.jpg and 3.jpg Below is the code which contains four images and concatenates them to be one image. But i am having around 500 images in a folder and I want to group them in a pair of four based on the range like first4 then second 4 and so on. import numpy as np import

How to initialize sample weights for multi-class segmentation?

假装没事ソ 提交于 2020-04-28 21:07:55
问题 I'm working on multi-class segmentation using Keras and U-net. I have as output of my NN 12 classes using soft max Activation function. the shape of my output is (N,288,288,12). to fit my model I use sparse_categorical_crossentropy. I want to initialize weights of my model for my unbalanced dataset. I found this useful link and try it to implement it; since class_weight in Keras does not work for more than 2 classes, I used sample weights My code is : inputs = tf.keras.layers.Input((IMG_WIDHT