image-processing

Drawing contours from label_image

孤街浪徒 提交于 2021-01-28 09:40:45
问题 I have a label_image array and I am deriving the outlines/boundaries of the objects on that array. Currently I am doing that by getting all unique labels, iterating over them and then find the contours of each object. Like in the loop below, where I am populating a dict with keys the label and values the contours import cv2 import pandas as pd import numpy as np def extract_borders(label_image): labels = np.unique(label_image[label_image > 0]) d = {} for label in labels: y = label_image ==

Extract text with strikethrough from image

风流意气都作罢 提交于 2021-01-28 09:03:46
问题 Here's an example image -> I would like to extract text that has text-decoration/styling of strikethrough. So for the above image I would like to extract - de location How would I do this ? Here's what I have so far using OpenCV and python : import cv2 import numpy as np import matplotlib.pyplot as plt im = cv2.imread(<image>) kernel = np.ones((1,44), np.uint8) morphed = cv2.morphologyEx(im, cv2.MORPH_CLOSE, kernel) plt.imshow(morphed) This gives me the horizontal lines -> I am new to image

histogram equalization using python and opencv without using inbuilt functions

寵の児 提交于 2021-01-28 08:28:17
问题 I have used formula: ((L-1)/MN) ni where L is total no of graylevels,M N is size of image, ni is cumulative frequency But I am getting full black image always.I have tried with other images as well. import numpy as np import cv2 path="C:/Users/Arun Nambiar/Downloads/fingerprint256by256 (1).pgm" img=cv2.imread(path,0) #To display image before equalization cv2.imshow('image',img) cv2.waitKey(0) cv2.destroyAllWindows() a=np.zeros((256,),dtype=np.float16) b=np.zeros((256,),dtype=np.float16)

How to correctly format PIL.Image.frombytes using external usb camera data

十年热恋 提交于 2021-01-28 08:28:07
问题 I've had hard time to read data I received from a USB camera and display it correctly. I succeeded, but I worry that I'm doing something wrong because my solution is hacky. The usb camera I'm using (ui-1640le) returns a byte array that I want to display. I used PIL.Image.frombytes("RGB", (imageWidth, imageHeight), image_bytes) But the image I got was in black and white and repeated itself: Image result I tried using the "L" format. PIL.Image.frombytes("L", (imageWidth, imageHeight), image

How to merge images as transparent layers?

天大地大妈咪最大 提交于 2021-01-28 05:09:21
问题 I am working on video editor for raspberry pi, and I have a problem with speed of placing image over image. Currently, using imagemagick it takes up to 10 seconds just to place one image over another, using 1080x1920 png images, on raspberry pi, and that's way too much. With the number of images time goes up as well. Any ideas on how to speed it up? Imagemagick code: composite -blend 90 img1.png img2.png new.png Video editor with yet slow opacity support here --------EDIT-------- slightly

Laplacian does not give desired output

断了今生、忘了曾经 提交于 2021-01-28 05:05:27
问题 Here is my code: int Factor=3,offset=0,k,l,p,q; IplImage * image = cvCreateImage(cvSize(img->width, img->height),img->depth, img->nChannels); cvCopy (img, image, 0); long double mean=0,nTemp=0,c,sum=0,n=0,s=0,d=0; int i=0,j=0,krow,kcol; kernel[0][0]=kernel[0][2]=kernel[2][0]=kernel[2][2]=0; kernel[0][1]=kernel[1][0]=kernel[1][2]=kernel[2][1]=1; kernel[1][1]=-4; uchar* temp_ptr=0 ; int rows=image->height,cols=image->width,row,col; //calculate the mean of image and deviation for ( row = 1; row

3D convolution in python

眉间皱痕 提交于 2021-01-28 05:04:10
问题 I need to wite a code to perform a 3D convolution in python using numpy, with 3x3 kernels. I've done it right for 2D arrays like B&W images but when i try to extend it to 3D arrays like RGB is a mess. I need help to improve my method. Here is the 2D code: def convolucion_3x3(arreglo, kernel): (dim_x, dim_y) = arreglo.shape (ker_x, ker_y) = kernel.shape matriz_convolucionada = np.zeros((dim_x, dim_y)) for i in range(dim_x): for j in range(dim_y): resultado = 0 for x in range(-1, 2): try: if i

How can I get my Express app to respect the Orientation EXIF data on upload?

只谈情不闲聊 提交于 2021-01-28 05:02:26
问题 I have an Express application that uses multer to upload images to an S3 bucket. I'm not doing anything special, just a straight upload, but when they are displayed in the browser some of the iPhone images are sideways. I know this is technically a browser bug and Firefox now supports the image-orientation rule, but Chrome still displays the images on their side. Is there a way I can have Express read the EXIF data and just rotate them before uploading? 回答1: Right, I figured it out. I used a

How to blur/ feather the edges of an object in an image using Opencv?

↘锁芯ラ 提交于 2021-01-28 04:25:17
问题 The objective is to blur the edges of a selected object in an image. I've done the steps to obtain the contours of the object by using the following code: image = cv2.imread('path of image') gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) thresh = cv2.threshold(gray, 60, 255, cv2.THRESH_BINARY)[1] im, contours, hierarchy = cv2.findContours(thresh.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE) I am also able to plot the contour using: cv2.drawContours(image, contours, -1, (0, 255, 0), 2)

Applying a vector field to image in matlab

谁都会走 提交于 2021-01-28 04:07:29
问题 How do I apply a vector field obtained via quiver, to an image which causes the pixels to displace in the direction of the vectors (image is warped)? Also, if the vector field I have is 3 dimensional, how would I do this? Think of it as laying down a flat 2 dimensional image over a 3 dimensional terrain. How would I go about viewing this in matlab? Thank you for your time EDIT: I have to warp the image not just in the Z axis, but along the X and Y axes as well. 回答1: Laying down a flat 2