image-processing

How to pixelate a binary (P6) PPM file

南楼画角 提交于 2020-07-22 21:39:53
问题 I am struggling to pixelate an image which is made up of RGB values stored in a binary (P6) PPM file. The steps to pixelate the image are as follows: Read in the binary data and store it in a 1-dimensional array Iterate through the data stored in this array, in cells of size 'c' (row x columns). This variable 'c' can be changed by the user, but for this program it's currently set to int c = 4; meaning it iterates through pixel data in block dimensions of 4 x 4 Now find the average colour

Color Detection not efficient on webcam images

风格不统一 提交于 2020-07-22 21:33:11
问题 I am working on a project where I'm trying to detect green and red circles on a specific surface (arena). When I try to do so with the digital version of that arena (PNG image), I can successfully detect both the colored circles. Here's the digital image of the surface: Now, I printed this arena on a flex(without those two colored circles ), and manually placed coloured circular coins on it. But after capturing its image through a 1.3 MP webcam, the color detection didn't work and gave false

Check if image is all white pixels with OpenCV

断了今生、忘了曾经 提交于 2020-07-22 02:51:38
问题 I am working on a script with OpenCV (Python) to split up an image into different sections in order to run OCR on each section on it later. I've got the script splitting up the source image into all the boxes I need, but it also comes along with a number of plain white images as well. I'm curious if there's a way to check if an image is only white pixels or not with OpenCV. I'm very new to this library, so any information on this would be helpful. Thanks! 回答1: Method #1: np.mean Calculate the

Tensorflow: Crop largest central square region of image

做~自己de王妃 提交于 2020-07-20 18:53:38
问题 My network takes images of size 100 x 100 pixels. Therefore I have to resize the images of my dataset which are of different size. I want to be able to extract the largest central square region from a given image and then resize it to 100 x 100 . To be more precisely, let's say an image has a width of 200 pixels and a height of 50 pixels. Then I want to extract the largest central square region which is in this example 50 x 50 followed by resizing the image to 100 x 100 pixels. What is the

Best way to detect if checkbox is ticked

余生长醉 提交于 2020-07-20 11:43:25
问题 My work: Scan the paper Check horizontal and vertical line Detect checkbox How to know checkbox is ticked or not At this point, I thought I could find it by using Hierarchical and Contours: Below is my work for i in range (len( contours_region)): #I already have X,Y,W,H of the checkbox through #print(i) #cv2.connectedComponentsWithStats x = contours_region[i][0][1] #when detecting checkbox x_1 = contours_region[i][2][1] y = contours_region[i][0][0] y_1 = contours_region[i][2][0] image_copy=

Convert 24-bit PNG files to 8-bit color indexed images with pypng

本小妞迷上赌 提交于 2020-07-19 12:05:27
问题 I'm trying to write a python script that takes in standard 24-bit pngs and converts them to 8-bit pngs for better compression. It looks like pypng can do this but I can't quite figure out how to use it. Image manipulation is a new area for me so this may seem silly. I have this currently: r=png.Reader(<myfile>) test = r.asRGBA8() This gives me tuples in return (the layers of the image I believe). However I can't seem to write or save this back to an image. What am I missing? Here's a test

undistortPoints, findEssentialMat, recoverPose: What is the relation between their arguments?

早过忘川 提交于 2020-07-17 13:02:52
问题 In the hope for a broader audience, I repost my question here which I asked on answers.opencv.org as well. TL;DR : What relation should hold between the arguments passed to undistortPoints , findEssentialMat and recoverPose ? I have code like the following in my program, with K and dist_coefficients being camera intrinsics and imgpts. matching feature points from 2 images. Mat mask; // inlier mask undistortPoints(imgpts1, imgpts1, K, dist_coefficients, noArray(), K); undistortPoints(imgpts2,

Square detection in image

倾然丶 夕夏残阳落幕 提交于 2020-07-17 10:15:15
问题 I am trying to detect all the squared shaped dice images so that i can crop them individually and use that for OCR. Below is the Original image: Here is the code i have got but it is missing some squares. def find_squares(img): img = cv2.GaussianBlur(img, (5, 5), 0) squares = [] for gray in cv2.split(img): for thrs in range(0, 255, 26): if thrs == 0: bin = cv2.Canny(gray, 0, 50, apertureSize=5) bin = cv2.dilate(bin, None) else: _retval, bin = cv2.threshold(gray, thrs, 255, cv2.THRESH_BINARY)

Square detection in image

本秂侑毒 提交于 2020-07-17 10:14:01
问题 I am trying to detect all the squared shaped dice images so that i can crop them individually and use that for OCR. Below is the Original image: Here is the code i have got but it is missing some squares. def find_squares(img): img = cv2.GaussianBlur(img, (5, 5), 0) squares = [] for gray in cv2.split(img): for thrs in range(0, 255, 26): if thrs == 0: bin = cv2.Canny(gray, 0, 50, apertureSize=5) bin = cv2.dilate(bin, None) else: _retval, bin = cv2.threshold(gray, thrs, 255, cv2.THRESH_BINARY)

Calculating the shortest path between two points in a bitmap in python

ぃ、小莉子 提交于 2020-07-17 06:41:26
问题 I have a black and white bitmap image shown here: The image size is 200,158. I want to pick two points that fall on the white path and calculate the shortest distance between those two points following only the white pixels. I am not sure how to approach this problem. I want to create a function that I call with 2 sets of x,y coordinates and it returns the number of pixels following the shortest route along the white pixels only. Any pointers would be greatly appreciated. 回答1: As stated in