image-processing

Object dimension measurement

血红的双手。 提交于 2020-12-15 04:54:12
问题 The following image is of a coin (for reference) and a pill. I need to measure the pill's dimensions. The objects are back-illuminated. I followed pyimagesearch.com tutorial for object height and width measurement. The coin has a diameter of 24.97 mm, and the actual dimensions of the pill are 9.43 mm x 19.33 mm. I am getting results with some error ranging from 0.5 mm to 2 mm. As mentioned on the website this is because of distortion and it is to be corrected. Can someone help me in

OpenCV - Blob/ Defect/ Anomaly Detection - Continued - Draw Contours

谁说胖子不能爱 提交于 2020-12-15 03:43:40
问题 OpenCV - Blob/ Defect/ Anomaly Detection If you need the image it's in the original link above. My current code is as follows, import cv2 import numpy as np import imutils # Read in the image in YCrCb, also show default img = cv2.imread('/home/pi/Downloads/divot1.jpeg', cv2.IMREAD_COLOR) imgS = cv2.resize(img, (768, 1024)) aimg = cv2.imread('/home/pi/Downloads/divot1.jpeg', cv2.COLOR_BGR2YCrCb) blur = cv2.blur(aimg,(6,6)) rblur = cv2.resize(blur, (384, 512)) #Statistics based approach mean =

Lanczos Interpolation in Python with 2D images

╄→гoц情女王★ 提交于 2020-12-13 05:39:12
问题 I try to rescale 2D images (greyscale). The image size is 256x256 and the desired output is 224x224. The pixel values range from 0 to 1300. I tried 2 approaches to rescale them with Lanczos Interpolation: First using PIL Image: import numpy as np from PIL import Image import cv2 array = np.random.randint(0, 1300, size=(10, 256, 256)) array[0] = Image.fromarray(array[0]).resize(size=(224, 224), resample=Image.LANCZOS) resulting in the error message: ValueError: image has wrong mode And then

OpenCV Segmentation of Largest contour in Breast Mammograms

ε祈祈猫儿з 提交于 2020-12-13 03:09:28
问题 This might be a bit too "general" question, but how do I perform GRAYSCALE image segmentation and keep the largest contour? I am trying to remove background noise (i.e. labels) from breast mammograms, but I am not successful. Here is the original image: First, I applied AGCWD algorithm (based on paper "Efficient Contrast Enhancement Using Adaptive Gamma Correction With Weighting Distribution") in order to get better contrast of the image pixels, like so: Afterwards, I tried executing

Node.js convert HEIC file

五迷三道 提交于 2020-12-12 05:13:49
问题 I need a way to use Node.js to convert a photo from HEIC format to either jpg or png. I have searched and cannot seem to find anything that works. 回答1: npm -i heic-convert const convert = require('heic-convert'); async function heicToJpg(file, output) { console.log(file, output); const inputBuffer = await promisify(fs.readFile)(file); const outputBuffer = convert({ buffer: inputBuffer, // the HEIC file buffer format: 'PNG', // output format }); return promisify(fs.writeFile)(output,

Node.js convert HEIC file

本秂侑毒 提交于 2020-12-12 05:12:07
问题 I need a way to use Node.js to convert a photo from HEIC format to either jpg or png. I have searched and cannot seem to find anything that works. 回答1: npm -i heic-convert const convert = require('heic-convert'); async function heicToJpg(file, output) { console.log(file, output); const inputBuffer = await promisify(fs.readFile)(file); const outputBuffer = convert({ buffer: inputBuffer, // the HEIC file buffer format: 'PNG', // output format }); return promisify(fs.writeFile)(output,

How to get the background from multiple images by removing moving objects?

天大地大妈咪最大 提交于 2020-12-11 08:54:44
问题 I have taken multiple images of the same scene with a fixed camera which has moving objects in it. I don't understand how can I use these images in Python to retrieve the background image by removing all the moving objects. Any help would be appreciated. Thanks! Images have been attached below: In this case, I would expect the final image to be without any hands in it. image1: image2: image3: 回答1: Updated Answer I worked out how to do what I suggested below in Python - but there may be better

3d sobel algorithm in python?

僤鯓⒐⒋嵵緔 提交于 2020-12-10 05:33:15
问题 I'm trying to calculate a 3d sobel filter in python. I have a pretty good code for 2d image which is below. btw. my original image is uint8 type. preSobel = preSobel.astype('int32') dx = ndimage.sobel(preSobel, 0) # horizontal derivative dy = ndimage.sobel(preSobel, 1) # vertical derivative mag = numpy.hypot(dx, dy) # magnitude mag *= 255.0 / numpy.max(mag) # normalize (Q&D) img[i,:,:]=mag but from my understanding of the wiki page for calculating 2d, i should have multiplied the 1d sobel

3d sobel algorithm in python?

别来无恙 提交于 2020-12-10 05:29:21
问题 I'm trying to calculate a 3d sobel filter in python. I have a pretty good code for 2d image which is below. btw. my original image is uint8 type. preSobel = preSobel.astype('int32') dx = ndimage.sobel(preSobel, 0) # horizontal derivative dy = ndimage.sobel(preSobel, 1) # vertical derivative mag = numpy.hypot(dx, dy) # magnitude mag *= 255.0 / numpy.max(mag) # normalize (Q&D) img[i,:,:]=mag but from my understanding of the wiki page for calculating 2d, i should have multiplied the 1d sobel

Pillow ImageDraw text coordinates to center

余生颓废 提交于 2020-12-08 10:41:22
问题 The code below brings the text in the center of x, but i don't know how to calculate the center for the y coordinate... it is not (imgH-h)/2! (The right y-coordinate is -80) from PIL import Image, ImageDraw, ImageFont font= './fonts/BebasNeue-Regular.ttf' color = (255, 244, 41) text = 'S' img = Image.new('RGB', (500, 500), color=(255, 255, 255)) imgW, imgH = img.size fnt = ImageFont.truetype(font, 600) d = ImageDraw.Draw(img) w, h = d.textsize(text, fnt) nullH = (imgH-h) print(imgH, h) d.text