image-processing

How to crop each character on an image using Python OpenCV?

久未见 提交于 2020-04-11 04:29:50
问题 I have generated OpenCV image like this From the last line of code, how do I crop and show each character in the current image separately? Code labels = measure.label(thresh, connectivity=2, background=0) charCandidates = np.zeros(thresh.shape, dtype="uint8") for label in np.unique(labels): if label == 0: continue labelMask = np.zeros(thresh.shape, dtype="uint8") labelMask[labels == label] = 255 cnts = cv2.findContours(labelMask, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE) cnts = imutils.grab

format conversion of an image in python

萝らか妹 提交于 2020-04-08 09:22:31
问题 I have to write an application for image processing in python. does anyone know how to convert the file type of an image from JPEG to TIFF? 回答1: Check out the Python Image Library (PIL). See this tutorial, the PIL is quite easy to use. Supported image formats. To do the conversion you open the image and then save it with the new extension (which PIL uses to determine what format to use for saving). import Image im = Image.open('test.jpg') im.save('test.tiff') # or 'test.tif' Note that the

format conversion of an image in python

好久不见. 提交于 2020-04-08 09:21:34
问题 I have to write an application for image processing in python. does anyone know how to convert the file type of an image from JPEG to TIFF? 回答1: Check out the Python Image Library (PIL). See this tutorial, the PIL is quite easy to use. Supported image formats. To do the conversion you open the image and then save it with the new extension (which PIL uses to determine what format to use for saving). import Image im = Image.open('test.jpg') im.save('test.tiff') # or 'test.tif' Note that the

Get the location of all text present in image using opencv

萝らか妹 提交于 2020-04-07 13:50:30
问题 I have this image that contains text(numbers and alphabets) in it. I want to get the location of all the text and numbers present in this image. Also I want to extract all the text as well. How do I get the cordinates as well as the all the text(numbers and alphabets) in my image. For eg 10B, 44, 16, 38, 22B etc 回答1: Here's a potential approach using morphological operations to filter out non-text contours. The idea is: Obtain binary image. Load image, grayscale, then Otsu's threshold Remove

Mapping RGB data to values in legend

|▌冷眼眸甩不掉的悲伤 提交于 2020-04-07 08:06:54
问题 This is a follow-up to my previous question here I've been trying to convert the color data in a heatmap to RGB values. source image In the below image, to the left is a subplot present in panel D of the source image. This has 6 x 6 cells (6 rows and 6 columns). On the right, we see the binarized image, with white color highlighted in the cell that is clicked after running the code below. The input for running the code is the below image. The ouput is (mean = [ 27.72 26.83 144.17]) is the

Mapping RGB data to values in legend

亡梦爱人 提交于 2020-04-07 08:03:12
问题 This is a follow-up to my previous question here I've been trying to convert the color data in a heatmap to RGB values. source image In the below image, to the left is a subplot present in panel D of the source image. This has 6 x 6 cells (6 rows and 6 columns). On the right, we see the binarized image, with white color highlighted in the cell that is clicked after running the code below. The input for running the code is the below image. The ouput is (mean = [ 27.72 26.83 144.17]) is the

How do I make an inverse filled transparent rectangle with OpenCV?

一笑奈何 提交于 2020-04-07 03:47:46
问题 I want to make an inverse filled rectangle in this picture. The code I have: import cv2 lena = cv2.imread('lena.png') output = lena.copy() cv2.rectangle(lena, (100, 100), (200, 200), (0, 0, 255), -1) cv2.addWeighted(lena, 0.5, output, 1 - .5, 0, output) cv2.imshow('', output) What I want: 回答1: Here's what I would do: # initialize output output = np.zeros_like(lena, dtype=np.uint8) output[:,:,-1] = 255 # this is your box top_x tx,ly,bx,ry = 100,100,200,200 # copy lena to output output[tx:bx,ly

Copy two BufferedImages into one image side by side

大憨熊 提交于 2020-04-05 08:18:55
问题 I have two images and I'd like to copy these two images to a new image where the second image is beside the first image and not on top of it. BufferedImage imgb1 = img1; BufferedImage imgb2 = img2; BufferedImage imgResult = new BufferedImage(...); where imgResult contains the first and the second image next to each other. 回答1: I created a demo for you and also a unit test, hope it works! Code: import java.awt.Color; import java.awt.Graphics2D; import java.awt.image.BufferedImage; import java

Copy two BufferedImages into one image side by side

安稳与你 提交于 2020-04-05 08:17:27
问题 I have two images and I'd like to copy these two images to a new image where the second image is beside the first image and not on top of it. BufferedImage imgb1 = img1; BufferedImage imgb2 = img2; BufferedImage imgResult = new BufferedImage(...); where imgResult contains the first and the second image next to each other. 回答1: I created a demo for you and also a unit test, hope it works! Code: import java.awt.Color; import java.awt.Graphics2D; import java.awt.image.BufferedImage; import java

How to compare two images using Node.js

时光怂恿深爱的人放手 提交于 2020-04-05 08:11:28
问题 I am looking for a way to compare two images to see how similar they are. Googling it produces tons of image processing results (cropping, re-sizing, etc.), but nothing that would do approximate comparisons of images. There is one Node.js library, but it is version 0.0.1 and relies on various 3rd party system packages, so not stable or portable. Something along these lines: var imgComparator = require('some-awesome-image-comparator-module'); // result would be between 1.0 and 0.0, where 1.0